Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekctek committed Nov 10, 2023
1 parent e691834 commit 40d7e04
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/Agent/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Contents

- [Account](#T-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account 'EdjCase.ICP.Agent.Standards.ICRC1.Models.Account')
- [#ctor(owner,subaccount)](#M-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account-#ctor-EdjCase-ICP-Candid-Models-Principal,EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}}- 'EdjCase.ICP.Agent.Standards.ICRC1.Models.Account.#ctor(EdjCase.ICP.Candid.Models.Principal,EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}})')
- [#ctor(owner,subaccount)](#M-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account-#ctor-EdjCase-ICP-Candid-Models-Principal,EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]}- 'EdjCase.ICP.Agent.Standards.ICRC1.Models.Account.#ctor(EdjCase.ICP.Candid.Models.Principal,EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]})')
- [Owner](#P-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account-Owner 'EdjCase.ICP.Agent.Standards.ICRC1.Models.Account.Owner')
- [Subaccount](#P-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account-Subaccount 'EdjCase.ICP.Agent.Standards.ICRC1.Models.Account.Subaccount')
- [AlgorithmIdentifier](#T-EdjCase-ICP-Agent-AlgorithmIdentifier 'EdjCase.ICP.Agent.AlgorithmIdentifier')
Expand Down Expand Up @@ -288,7 +288,7 @@
- [Name](#P-EdjCase-ICP-Agent-Standards-ICRC1-Models-SupportedStandard-Name 'EdjCase.ICP.Agent.Standards.ICRC1.Models.SupportedStandard.Name')
- [Url](#P-EdjCase-ICP-Agent-Standards-ICRC1-Models-SupportedStandard-Url 'EdjCase.ICP.Agent.Standards.ICRC1.Models.SupportedStandard.Url')
- [TransferArgs](#T-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs 'EdjCase.ICP.Agent.Standards.ICRC1.Models.TransferArgs')
- [#ctor(fromSubaccount,to,amount,fee,memo,createdAtTime)](#M-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs-#ctor-EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}},EdjCase-ICP-Agent-Standards-ICRC1-Models-Account,EdjCase-ICP-Candid-Models-UnboundedUInt,EdjCase-ICP-Candid-Models-OptionalValue{EdjCase-ICP-Candid-Models-UnboundedUInt},EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}},EdjCase-ICP-Candid-Models-OptionalValue{System-UInt64}- 'EdjCase.ICP.Agent.Standards.ICRC1.Models.TransferArgs.#ctor(EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}},EdjCase.ICP.Agent.Standards.ICRC1.Models.Account,EdjCase.ICP.Candid.Models.UnboundedUInt,EdjCase.ICP.Candid.Models.OptionalValue{EdjCase.ICP.Candid.Models.UnboundedUInt},EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}},EdjCase.ICP.Candid.Models.OptionalValue{System.UInt64})')
- [#ctor(fromSubaccount,to,amount,fee,memo,createdAtTime)](#M-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs-#ctor-EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]},EdjCase-ICP-Agent-Standards-ICRC1-Models-Account,EdjCase-ICP-Candid-Models-UnboundedUInt,EdjCase-ICP-Candid-Models-OptionalValue{EdjCase-ICP-Candid-Models-UnboundedUInt},EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]},EdjCase-ICP-Candid-Models-OptionalValue{System-UInt64}- 'EdjCase.ICP.Agent.Standards.ICRC1.Models.TransferArgs.#ctor(EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]},EdjCase.ICP.Agent.Standards.ICRC1.Models.Account,EdjCase.ICP.Candid.Models.UnboundedUInt,EdjCase.ICP.Candid.Models.OptionalValue{EdjCase.ICP.Candid.Models.UnboundedUInt},EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]},EdjCase.ICP.Candid.Models.OptionalValue{System.UInt64})')
- [Amount](#P-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs-Amount 'EdjCase.ICP.Agent.Standards.ICRC1.Models.TransferArgs.Amount')
- [CreatedAtTime](#P-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs-CreatedAtTime 'EdjCase.ICP.Agent.Standards.ICRC1.Models.TransferArgs.CreatedAtTime')
- [Fee](#P-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs-Fee 'EdjCase.ICP.Agent.Standards.ICRC1.Models.TransferArgs.Fee')
Expand Down Expand Up @@ -347,7 +347,7 @@ EdjCase.ICP.Agent.Standards.ICRC1.Models

This class represents an ICRC1 account

<a name='M-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account-#ctor-EdjCase-ICP-Candid-Models-Principal,EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}}-'></a>
<a name='M-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account-#ctor-EdjCase-ICP-Candid-Models-Principal,EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]}-'></a>
### #ctor(owner,subaccount) `constructor`

##### Summary
Expand All @@ -359,7 +359,7 @@ Primary constructor for the Account class
| Name | Type | Description |
| ---- | ---- | ----------- |
| owner | [EdjCase.ICP.Candid.Models.Principal](#T-EdjCase-ICP-Candid-Models-Principal 'EdjCase.ICP.Candid.Models.Principal') | The owner of the account, represented as a Principal object |
| subaccount | [EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}}](#T-EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}} 'EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}}') | The subaccount of the account, represented as an OptionalValue object |
| subaccount | [EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]}](#T-EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]} 'EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]}') | The subaccount of the account, represented as an OptionalValue object |

<a name='P-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account-Owner'></a>
### Owner `property`
Expand Down Expand Up @@ -3563,7 +3563,7 @@ EdjCase.ICP.Agent.Standards.ICRC1.Models

This class represents the arguments for transferring an ICRC1 token

<a name='M-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs-#ctor-EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}},EdjCase-ICP-Agent-Standards-ICRC1-Models-Account,EdjCase-ICP-Candid-Models-UnboundedUInt,EdjCase-ICP-Candid-Models-OptionalValue{EdjCase-ICP-Candid-Models-UnboundedUInt},EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}},EdjCase-ICP-Candid-Models-OptionalValue{System-UInt64}-'></a>
<a name='M-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs-#ctor-EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]},EdjCase-ICP-Agent-Standards-ICRC1-Models-Account,EdjCase-ICP-Candid-Models-UnboundedUInt,EdjCase-ICP-Candid-Models-OptionalValue{EdjCase-ICP-Candid-Models-UnboundedUInt},EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]},EdjCase-ICP-Candid-Models-OptionalValue{System-UInt64}-'></a>
### #ctor(fromSubaccount,to,amount,fee,memo,createdAtTime) `constructor`

##### Summary
Expand All @@ -3574,11 +3574,11 @@ Primary constructor for the TransferArgs class

| Name | Type | Description |
| ---- | ---- | ----------- |
| fromSubaccount | [EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}}](#T-EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}} 'EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}}') | The subaccount from which the transfer is made, represented as an OptionalValue object |
| fromSubaccount | [EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]}](#T-EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]} 'EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]}') | The subaccount from which the transfer is made, represented as an OptionalValue object |
| to | [EdjCase.ICP.Agent.Standards.ICRC1.Models.Account](#T-EdjCase-ICP-Agent-Standards-ICRC1-Models-Account 'EdjCase.ICP.Agent.Standards.ICRC1.Models.Account') | The account to which the transfer is made, represented as an Account object |
| amount | [EdjCase.ICP.Candid.Models.UnboundedUInt](#T-EdjCase-ICP-Candid-Models-UnboundedUInt 'EdjCase.ICP.Candid.Models.UnboundedUInt') | The amount of the token being transferred, represented as an UnboundedUInt object |
| fee | [EdjCase.ICP.Candid.Models.OptionalValue{EdjCase.ICP.Candid.Models.UnboundedUInt}](#T-EdjCase-ICP-Candid-Models-OptionalValue{EdjCase-ICP-Candid-Models-UnboundedUInt} 'EdjCase.ICP.Candid.Models.OptionalValue{EdjCase.ICP.Candid.Models.UnboundedUInt}') | The fee for the transfer, represented as an OptionalValue object |
| memo | [EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}}](#T-EdjCase-ICP-Candid-Models-OptionalValue{System-Collections-Generic-List{System-Byte}} 'EdjCase.ICP.Candid.Models.OptionalValue{System.Collections.Generic.List{System.Byte}}') | The memo for the transfer, represented as an OptionalValue object |
| memo | [EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]}](#T-EdjCase-ICP-Candid-Models-OptionalValue{System-Byte[]} 'EdjCase.ICP.Candid.Models.OptionalValue{System.Byte[]}') | The memo for the transfer, represented as an OptionalValue object |
| createdAtTime | [EdjCase.ICP.Candid.Models.OptionalValue{System.UInt64}](#T-EdjCase-ICP-Candid-Models-OptionalValue{System-UInt64} 'EdjCase.ICP.Candid.Models.OptionalValue{System.UInt64}') | The time at which the transfer is created, represented as an OptionalValue object |

<a name='P-EdjCase-ICP-Agent-Standards-ICRC1-Models-TransferArgs-Amount'></a>
Expand Down
4 changes: 2 additions & 2 deletions src/Agent/API.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/Agent/Standards/ICRC1/Models/TransferArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class TransferArgs
/// The memo for the transfer, represented as an OptionalValue object
/// </summary>
[CandidName("memo")]
public OptionalValue<Subaccount> Memo { get; set; }
public OptionalValue<byte[]> Memo { get; set; }

/// <summary>
/// The time at which the transfer is created, represented as an OptionalValue object
Expand All @@ -55,7 +55,7 @@ public class TransferArgs
/// <param name="fee">The fee for the transfer, represented as an OptionalValue object</param>
/// <param name="memo">The memo for the transfer, represented as an OptionalValue object</param>
/// <param name="createdAtTime">The time at which the transfer is created, represented as an OptionalValue object</param>
public TransferArgs(OptionalValue<Subaccount> fromSubaccount, Account to, UnboundedUInt amount, OptionalValue<UnboundedUInt> fee, OptionalValue<Subaccount> memo, OptionalValue<Timestamp> createdAtTime)
public TransferArgs(OptionalValue<byte[]> fromSubaccount, Account to, UnboundedUInt amount, OptionalValue<UnboundedUInt> fee, OptionalValue<byte[]> memo, OptionalValue<Timestamp> createdAtTime)
{
this.FromSubaccount = fromSubaccount ?? throw new ArgumentNullException(nameof(fromSubaccount));
this.To = to ?? throw new ArgumentNullException(nameof(to));
Expand Down
41 changes: 41 additions & 0 deletions src/Candid/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@
- [Reserved](#F-EdjCase-ICP-Candid-Models-Values-PrimitiveType-Reserved 'EdjCase.ICP.Candid.Models.Values.PrimitiveType.Reserved')
- [Text](#F-EdjCase-ICP-Candid-Models-Values-PrimitiveType-Text 'EdjCase.ICP.Candid.Models.Values.PrimitiveType.Text')
- [Principal](#T-EdjCase-ICP-Candid-Models-Principal 'EdjCase.ICP.Candid.Models.Principal')
- [accountIdPrefix](#F-EdjCase-ICP-Candid-Models-Principal-accountIdPrefix 'EdjCase.ICP.Candid.Models.Principal.accountIdPrefix')
- [Raw](#P-EdjCase-ICP-Candid-Models-Principal-Raw 'EdjCase.ICP.Candid.Models.Principal.Raw')
- [Type](#P-EdjCase-ICP-Candid-Models-Principal-Type 'EdjCase.ICP.Candid.Models.Principal.Type')
- [Anonymous()](#M-EdjCase-ICP-Candid-Models-Principal-Anonymous 'EdjCase.ICP.Candid.Models.Principal.Anonymous')
Expand All @@ -570,6 +571,7 @@
- [ManagementCanisterId()](#M-EdjCase-ICP-Candid-Models-Principal-ManagementCanisterId 'EdjCase.ICP.Candid.Models.Principal.ManagementCanisterId')
- [SelfAuthenticating(derEncodedPublicKey)](#M-EdjCase-ICP-Candid-Models-Principal-SelfAuthenticating-System-Byte[]- 'EdjCase.ICP.Candid.Models.Principal.SelfAuthenticating(System.Byte[])')
- [ToHex()](#M-EdjCase-ICP-Candid-Models-Principal-ToHex 'EdjCase.ICP.Candid.Models.Principal.ToHex')
- [ToLedgerAccount(subAccount)](#M-EdjCase-ICP-Candid-Models-Principal-ToLedgerAccount-System-Byte[]- 'EdjCase.ICP.Candid.Models.Principal.ToLedgerAccount(System.Byte[])')
- [ToString()](#M-EdjCase-ICP-Candid-Models-Principal-ToString 'EdjCase.ICP.Candid.Models.Principal.ToString')
- [ToText()](#M-EdjCase-ICP-Candid-Models-Principal-ToText 'EdjCase.ICP.Candid.Models.Principal.ToText')
- [op_Equality()](#M-EdjCase-ICP-Candid-Models-Principal-op_Equality-EdjCase-ICP-Candid-Models-Principal,EdjCase-ICP-Candid-Models-Principal- 'EdjCase.ICP.Candid.Models.Principal.op_Equality(EdjCase.ICP.Candid.Models.Principal,EdjCase.ICP.Candid.Models.Principal)')
Expand Down Expand Up @@ -7638,6 +7640,9 @@ EdjCase.ICP.Candid.Models

A model representing a principal byte value with helper functions

<a name='F-EdjCase-ICP-Candid-Models-Principal-accountIdPrefix'></a>
### accountIdPrefix `constants`

<a name='P-EdjCase-ICP-Candid-Models-Principal-Raw'></a>
### Raw `property`

Expand Down Expand Up @@ -7809,6 +7814,42 @@ Hex value as a string

This method has no parameters.

<a name='M-EdjCase-ICP-Candid-Models-Principal-ToLedgerAccount-System-Byte[]-'></a>
### ToLedgerAccount(subAccount) `method`

##### Summary

Generates an account identifier from a sub-account byte array.

##### Returns

A byte array representing the account identifier.

##### Parameters

| Name | Type | Description |
| ---- | ---- | ----------- |
| subAccount | [System.Byte[]](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.Byte[] 'System.Byte[]') | Optional. The sub-account byte array, expected to be 32 bytes in length.If not specified, will not use a subaccount |

##### Exceptions

| Name | Description |
| ---- | ----------- |
| [System.ArgumentException](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.ArgumentException 'System.ArgumentException') | Thrown when the sub-account byte array is not 32 bytes in length. |

##### Remarks

This method constructs a ledger account identifier by concatenating a fixed prefix, the principal's raw byte array,
and a sub-account byte array. It computes a SHA-224 hash on this concatenated byte array, then calculates a CRC-32
checksum of the hash. The resulting account identifier is a concatenation of the CRC-32 checksum and the SHA-224 hash.

The method expects a sub-account byte array of exactly 32 bytes in length. If the provided array does not meet this
requirement, an [ArgumentException](http://msdn.microsoft.com/query/dev14.query?appId=Dev14IDEF1&l=EN-US&k=k:System.ArgumentException 'System.ArgumentException') is thrown.

The account identifier format follows the specification:
account_identifier(principal, subaccount_identifier) = CRC32(h) || h
where h = sha224("\x0Aaccount-id" || principal || subaccount_identifier).

<a name='M-EdjCase-ICP-Candid-Models-Principal-ToString'></a>
### ToString() `method`

Expand Down
23 changes: 23 additions & 0 deletions src/Candid/API.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 40d7e04

Please sign in to comment.