@amadeus-protocol/sdk 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/api/chain.d.ts +144 -117
  2. package/dist/api/chain.d.ts.map +1 -1
  3. package/dist/api/chain.js +175 -146
  4. package/dist/api/chain.js.map +1 -1
  5. package/dist/api/contract.d.ts +78 -60
  6. package/dist/api/contract.d.ts.map +1 -1
  7. package/dist/api/contract.js +102 -75
  8. package/dist/api/contract.js.map +1 -1
  9. package/dist/api/epoch.d.ts +65 -66
  10. package/dist/api/epoch.d.ts.map +1 -1
  11. package/dist/api/epoch.js +90 -98
  12. package/dist/api/epoch.js.map +1 -1
  13. package/dist/api/peer.d.ts +77 -78
  14. package/dist/api/peer.d.ts.map +1 -1
  15. package/dist/api/peer.js +93 -94
  16. package/dist/api/peer.js.map +1 -1
  17. package/dist/api/proof.d.ts +44 -23
  18. package/dist/api/proof.d.ts.map +1 -1
  19. package/dist/api/proof.js +56 -29
  20. package/dist/api/proof.js.map +1 -1
  21. package/dist/api/transaction.d.ts +68 -69
  22. package/dist/api/transaction.d.ts.map +1 -1
  23. package/dist/api/transaction.js +84 -84
  24. package/dist/api/transaction.js.map +1 -1
  25. package/dist/api/wallet.d.ts +36 -37
  26. package/dist/api/wallet.d.ts.map +1 -1
  27. package/dist/api/wallet.js +47 -50
  28. package/dist/api/wallet.js.map +1 -1
  29. package/dist/client.d.ts +66 -68
  30. package/dist/client.d.ts.map +1 -1
  31. package/dist/client.js +231 -276
  32. package/dist/client.js.map +1 -1
  33. package/dist/constants.d.ts +13 -10
  34. package/dist/constants.d.ts.map +1 -1
  35. package/dist/constants.js +49 -45
  36. package/dist/constants.js.map +1 -1
  37. package/dist/contract-state.d.ts +6 -3
  38. package/dist/contract-state.d.ts.map +1 -1
  39. package/dist/contract-state.js +88 -106
  40. package/dist/contract-state.js.map +1 -1
  41. package/dist/contracts/abi-types.d.ts +32 -32
  42. package/dist/contracts/abi-types.d.ts.map +1 -1
  43. package/dist/contracts/coin.d.ts +13 -20
  44. package/dist/contracts/coin.d.ts.map +1 -1
  45. package/dist/contracts/coin.js +42 -38
  46. package/dist/contracts/coin.js.map +1 -1
  47. package/dist/contracts/contract-call.d.ts +14 -16
  48. package/dist/contracts/contract-call.d.ts.map +1 -1
  49. package/dist/contracts/contract-call.js +45 -54
  50. package/dist/contracts/contract-call.js.map +1 -1
  51. package/dist/contracts/contract.d.ts +24 -55
  52. package/dist/contracts/contract.d.ts.map +1 -1
  53. package/dist/contracts/contract.js +63 -101
  54. package/dist/contracts/contract.js.map +1 -1
  55. package/dist/contracts/lockup/abi.d.ts +54 -51
  56. package/dist/contracts/lockup/abi.d.ts.map +1 -1
  57. package/dist/contracts/lockup/abi.js +65 -74
  58. package/dist/contracts/lockup/abi.js.map +1 -1
  59. package/dist/contracts/lockup/helpers.d.ts +22 -18
  60. package/dist/contracts/lockup/helpers.d.ts.map +1 -1
  61. package/dist/contracts/lockup/helpers.js +44 -47
  62. package/dist/contracts/lockup/helpers.js.map +1 -1
  63. package/dist/contracts/lockup/parsers.d.ts +7 -3
  64. package/dist/contracts/lockup/parsers.d.ts.map +1 -1
  65. package/dist/contracts/lockup/parsers.js +51 -55
  66. package/dist/contracts/lockup/parsers.js.map +1 -1
  67. package/dist/contracts/lockup/storage-keys.d.ts +5 -2
  68. package/dist/contracts/lockup/storage-keys.d.ts.map +1 -1
  69. package/dist/contracts/lockup/storage-keys.js +54 -70
  70. package/dist/contracts/lockup/storage-keys.js.map +1 -1
  71. package/dist/contracts/lockup/types.d.ts +73 -70
  72. package/dist/contracts/lockup/types.d.ts.map +1 -1
  73. package/dist/contracts/lockup-prime/abi.d.ts +328 -325
  74. package/dist/contracts/lockup-prime/abi.d.ts.map +1 -1
  75. package/dist/contracts/lockup-prime/abi.js +397 -417
  76. package/dist/contracts/lockup-prime/abi.js.map +1 -1
  77. package/dist/contracts/lockup-prime/helpers.d.ts +35 -31
  78. package/dist/contracts/lockup-prime/helpers.d.ts.map +1 -1
  79. package/dist/contracts/lockup-prime/helpers.js +131 -137
  80. package/dist/contracts/lockup-prime/helpers.js.map +1 -1
  81. package/dist/contracts/lockup-prime/parsers.d.ts +9 -5
  82. package/dist/contracts/lockup-prime/parsers.d.ts.map +1 -1
  83. package/dist/contracts/lockup-prime/parsers.js +61 -61
  84. package/dist/contracts/lockup-prime/parsers.js.map +1 -1
  85. package/dist/contracts/lockup-prime/storage-keys.d.ts +7 -4
  86. package/dist/contracts/lockup-prime/storage-keys.d.ts.map +1 -1
  87. package/dist/contracts/lockup-prime/storage-keys.js +64 -80
  88. package/dist/contracts/lockup-prime/storage-keys.js.map +1 -1
  89. package/dist/contracts/lockup-prime/types.d.ts +92 -89
  90. package/dist/contracts/lockup-prime/types.d.ts.map +1 -1
  91. package/dist/contracts/lockup-prime/types.js +12 -13
  92. package/dist/contracts/lockup-prime/types.js.map +1 -1
  93. package/dist/contracts/nft/abi.d.ts +104 -0
  94. package/dist/contracts/nft/abi.d.ts.map +1 -0
  95. package/dist/contracts/nft/abi.js +135 -0
  96. package/dist/contracts/nft/abi.js.map +1 -0
  97. package/dist/contracts/nft/helpers.d.ts +21 -0
  98. package/dist/contracts/nft/helpers.d.ts.map +1 -0
  99. package/dist/contracts/nft/helpers.js +61 -0
  100. package/dist/contracts/nft/helpers.js.map +1 -0
  101. package/dist/contracts/nft/types.d.ts +47 -0
  102. package/dist/contracts/nft/types.d.ts.map +1 -0
  103. package/dist/conversion.d.ts +5 -2
  104. package/dist/conversion.d.ts.map +1 -1
  105. package/dist/conversion.js +45 -50
  106. package/dist/conversion.js.map +1 -1
  107. package/dist/crypto.d.ts +14 -16
  108. package/dist/crypto.d.ts.map +1 -1
  109. package/dist/crypto.js +121 -140
  110. package/dist/crypto.js.map +1 -1
  111. package/dist/encoding.d.ts +11 -8
  112. package/dist/encoding.d.ts.map +1 -1
  113. package/dist/encoding.js +123 -144
  114. package/dist/encoding.js.map +1 -1
  115. package/dist/encryption.d.ts +15 -12
  116. package/dist/encryption.d.ts.map +1 -1
  117. package/dist/encryption.js +119 -117
  118. package/dist/encryption.js.map +1 -1
  119. package/dist/explorer.d.ts +10 -7
  120. package/dist/explorer.d.ts.map +1 -1
  121. package/dist/explorer.js +51 -48
  122. package/dist/explorer.js.map +1 -1
  123. package/dist/formatters.d.ts +8 -5
  124. package/dist/formatters.d.ts.map +1 -1
  125. package/dist/formatters.js +67 -68
  126. package/dist/formatters.js.map +1 -1
  127. package/dist/index.d.ts +42 -55
  128. package/dist/index.js +39 -55
  129. package/dist/mnemonic.d.ts +12 -9
  130. package/dist/mnemonic.d.ts.map +1 -1
  131. package/dist/mnemonic.js +105 -114
  132. package/dist/mnemonic.js.map +1 -1
  133. package/dist/networks.d.ts +14 -17
  134. package/dist/networks.d.ts.map +1 -1
  135. package/dist/networks.js +40 -36
  136. package/dist/networks.js.map +1 -1
  137. package/dist/schemas.js +75 -79
  138. package/dist/schemas.js.map +1 -1
  139. package/dist/sdk.d.ts +69 -65
  140. package/dist/sdk.d.ts.map +1 -1
  141. package/dist/sdk.js +126 -117
  142. package/dist/sdk.js.map +1 -1
  143. package/dist/serialization.d.ts +8 -18
  144. package/dist/serialization.d.ts.map +1 -1
  145. package/dist/serialization.js +207 -260
  146. package/dist/serialization.js.map +1 -1
  147. package/dist/signing.js +67 -67
  148. package/dist/signing.js.map +1 -1
  149. package/dist/transaction-builder.d.ts +175 -184
  150. package/dist/transaction-builder.d.ts.map +1 -1
  151. package/dist/transaction-builder.js +295 -344
  152. package/dist/transaction-builder.js.map +1 -1
  153. package/dist/transaction-errors.d.ts +10 -12
  154. package/dist/transaction-errors.d.ts.map +1 -1
  155. package/dist/transaction-errors.js +145 -166
  156. package/dist/transaction-errors.js.map +1 -1
  157. package/dist/types.d.ts +530 -450
  158. package/dist/types.d.ts.map +1 -1
  159. package/dist/types.js +169 -183
  160. package/dist/types.js.map +1 -1
  161. package/dist/validation.d.ts +24 -26
  162. package/dist/validation.d.ts.map +1 -1
  163. package/dist/validation.js +194 -192
  164. package/dist/validation.js.map +1 -1
  165. package/package.json +4 -3
  166. package/dist/api/index.d.ts +0 -8
  167. package/dist/api/index.d.ts.map +0 -1
  168. package/dist/api/index.js +0 -8
  169. package/dist/api/index.js.map +0 -1
  170. package/dist/contracts/abi-types.js +0 -8
  171. package/dist/contracts/abi-types.js.map +0 -1
  172. package/dist/contracts/index.d.ts +0 -7
  173. package/dist/contracts/index.d.ts.map +0 -1
  174. package/dist/contracts/index.js +0 -7
  175. package/dist/contracts/index.js.map +0 -1
  176. package/dist/contracts/lockup/calls.d.ts +0 -23
  177. package/dist/contracts/lockup/calls.d.ts.map +0 -1
  178. package/dist/contracts/lockup/calls.js +0 -25
  179. package/dist/contracts/lockup/calls.js.map +0 -1
  180. package/dist/contracts/lockup/index.d.ts +0 -6
  181. package/dist/contracts/lockup/index.d.ts.map +0 -1
  182. package/dist/contracts/lockup/index.js +0 -6
  183. package/dist/contracts/lockup/index.js.map +0 -1
  184. package/dist/contracts/lockup/types.js +0 -7
  185. package/dist/contracts/lockup/types.js.map +0 -1
  186. package/dist/contracts/lockup-prime/calls.d.ts +0 -53
  187. package/dist/contracts/lockup-prime/calls.d.ts.map +0 -1
  188. package/dist/contracts/lockup-prime/calls.js +0 -60
  189. package/dist/contracts/lockup-prime/calls.js.map +0 -1
  190. package/dist/contracts/lockup-prime/index.d.ts +0 -6
  191. package/dist/contracts/lockup-prime/index.d.ts.map +0 -1
  192. package/dist/contracts/lockup-prime/index.js +0 -6
  193. package/dist/contracts/lockup-prime/index.js.map +0 -1
  194. package/dist/index.d.ts.map +0 -1
  195. package/dist/index.js.map +0 -1
  196. package/dist/schemas.d.ts +0 -67
  197. package/dist/schemas.d.ts.map +0 -1
  198. package/dist/signing.d.ts +0 -39
  199. package/dist/signing.d.ts.map +0 -1
package/dist/constants.js CHANGED
@@ -1,46 +1,50 @@
1
- /**
2
- * Amadeus Protocol Constants
3
- *
4
- * This module contains all protocol-level constants used throughout the SDK.
5
- */
6
- /**
7
- * SDK version
8
- */
9
- export const SDK_VERSION = '1.0.0';
10
- /**
11
- * Byte length of an Amadeus public key (BLS12-381 public key)
12
- */
13
- export const AMADEUS_PUBLIC_KEY_BYTE_LENGTH = 48;
14
- /**
15
- * Byte length of an Amadeus seed (private key seed)
16
- */
17
- export const AMADEUS_SEED_BYTE_LENGTH = 64;
18
- /**
19
- * Number of decimal places for AMA token
20
- */
21
- export const AMA_TOKEN_DECIMALS = 9;
22
- /**
23
- * Multiplier for converting between atomic units and AMA tokens
24
- */
25
- export const AMA_TOKEN_DECIMALS_MULTIPLIER = 10 ** AMA_TOKEN_DECIMALS;
26
- /**
27
- * Minimum transferable amount in AMA (1 atomic unit)
28
- */
29
- export const MIN_TRANSFERABLE_AMOUNT = 1 / AMA_TOKEN_DECIMALS_MULTIPLIER;
30
- /**
31
- * Flat network transfer fee in AMA for standard transfers
32
- */
33
- export const AMA_TRANSFER_FEE = 0.02;
34
- /**
35
- * Default explorer URL
36
- */
37
- export const EXPLORER_URL = 'https://explorer.ama.one';
38
- /**
39
- * Default node API URL
40
- */
41
- export const NODE_API_URL = 'https://mainnet-rpc.ama.one/api';
42
- /**
43
- * Default request timeout in milliseconds
44
- */
45
- export const DEFAULT_TIMEOUT = 30000;
1
+ //#region src/constants.ts
2
+ /**
3
+ * Amadeus Protocol Constants
4
+ *
5
+ * This module contains all protocol-level constants used throughout the SDK.
6
+ */
7
+ /**
8
+ * SDK version
9
+ */
10
+ const SDK_VERSION = "1.0.0";
11
+ /**
12
+ * Byte length of an Amadeus public key (BLS12-381 public key)
13
+ */
14
+ const AMADEUS_PUBLIC_KEY_BYTE_LENGTH = 48;
15
+ /**
16
+ * Byte length of an Amadeus seed (private key seed)
17
+ */
18
+ const AMADEUS_SEED_BYTE_LENGTH = 64;
19
+ /**
20
+ * Number of decimal places for AMA token
21
+ */
22
+ const AMA_TOKEN_DECIMALS = 9;
23
+ /**
24
+ * Multiplier for converting between atomic units and AMA tokens
25
+ */
26
+ const AMA_TOKEN_DECIMALS_MULTIPLIER = 10 ** 9;
27
+ /**
28
+ * Minimum transferable amount in AMA (1 atomic unit)
29
+ */
30
+ const MIN_TRANSFERABLE_AMOUNT = 1 / AMA_TOKEN_DECIMALS_MULTIPLIER;
31
+ /**
32
+ * Flat network transfer fee in AMA for standard transfers
33
+ */
34
+ const AMA_TRANSFER_FEE = .02;
35
+ /**
36
+ * Default explorer URL
37
+ */
38
+ const EXPLORER_URL = "https://explorer.ama.one";
39
+ /**
40
+ * Default node API URL
41
+ */
42
+ const NODE_API_URL = "https://mainnet-rpc.ama.one/api";
43
+ /**
44
+ * Default request timeout in milliseconds
45
+ */
46
+ const DEFAULT_TIMEOUT = 3e4;
47
+ //#endregion
48
+ export { AMADEUS_PUBLIC_KEY_BYTE_LENGTH, AMADEUS_SEED_BYTE_LENGTH, AMA_TOKEN_DECIMALS, AMA_TOKEN_DECIMALS_MULTIPLIER, AMA_TRANSFER_FEE, DEFAULT_TIMEOUT, EXPLORER_URL, MIN_TRANSFERABLE_AMOUNT, NODE_API_URL, SDK_VERSION };
49
+
46
50
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,CAAA;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,IAAI,kBAAkB,CAAA;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,6BAA6B,CAAA;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAA;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,0BAA0B,CAAA;AAEtD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,iCAAiC,CAAA;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Amadeus Protocol Constants\n *\n * This module contains all protocol-level constants used throughout the SDK.\n */\n\n/**\n * SDK version\n */\nexport const SDK_VERSION = '1.0.0'\n\n/**\n * Byte length of an Amadeus public key (BLS12-381 public key)\n */\nexport const AMADEUS_PUBLIC_KEY_BYTE_LENGTH = 48\n\n/**\n * Byte length of an Amadeus seed (private key seed)\n */\nexport const AMADEUS_SEED_BYTE_LENGTH = 64\n\n/**\n * Number of decimal places for AMA token\n */\nexport const AMA_TOKEN_DECIMALS = 9\n\n/**\n * Multiplier for converting between atomic units and AMA tokens\n */\nexport const AMA_TOKEN_DECIMALS_MULTIPLIER = 10 ** AMA_TOKEN_DECIMALS\n\n/**\n * Minimum transferable amount in AMA (1 atomic unit)\n */\nexport const MIN_TRANSFERABLE_AMOUNT = 1 / AMA_TOKEN_DECIMALS_MULTIPLIER\n\n/**\n * Flat network transfer fee in AMA for standard transfers\n */\nexport const AMA_TRANSFER_FEE = 0.02\n\n/**\n * Default explorer URL\n */\nexport const EXPLORER_URL = 'https://explorer.ama.one'\n\n/**\n * Default node API URL\n */\nexport const NODE_API_URL = 'https://mainnet-rpc.ama.one/api'\n\n/**\n * Default request timeout in milliseconds\n */\nexport const DEFAULT_TIMEOUT = 30000\n"],"mappings":";;;;;;;;;AASA,MAAa,cAAc;;;;AAK3B,MAAa,iCAAiC;;;;AAK9C,MAAa,2BAA2B;;;;AAKxC,MAAa,qBAAqB;;;;AAKlC,MAAa,gCAAgC,MAAA;;;;AAK7C,MAAa,0BAA0B,IAAI;;;;AAK3C,MAAa,mBAAmB;;;;AAKhC,MAAa,eAAe;;;;AAK5B,MAAa,eAAe;;;;AAK5B,MAAa,kBAAkB"}
@@ -1,3 +1,4 @@
1
+ //#region src/contract-state.d.ts
1
2
  /**
2
3
  * Contract State Utilities
3
4
  *
@@ -21,7 +22,7 @@
21
22
  * // entries: [["base64key", "base64value"], ...]
22
23
  * ```
23
24
  */
24
- export declare function decodeContractStateToBase64(bytes: Uint8Array | ArrayBuffer): Array<[string, string]>;
25
+ declare function decodeContractStateToBase64(bytes: Uint8Array | ArrayBuffer): Array<[string, string]>;
25
26
  /**
26
27
  * Parse a contract state value as a number.
27
28
  *
@@ -42,7 +43,7 @@ export declare function decodeContractStateToBase64(bytes: Uint8Array | ArrayBuf
42
43
  * parseStateNumber(null) // 0
43
44
  * ```
44
45
  */
45
- export declare function parseStateNumber(value: string | number | Uint8Array | null | undefined): number;
46
+ declare function parseStateNumber(value: string | number | Uint8Array | null | undefined): number;
46
47
  /**
47
48
  * Parse a contract state value as a string.
48
49
  *
@@ -55,5 +56,7 @@ export declare function parseStateNumber(value: string | number | Uint8Array | n
55
56
  * @param value - Raw contract state value
56
57
  * @returns Parsed string or null
57
58
  */
58
- export declare function parseStateString(value: string | number | Uint8Array | null | undefined): string | null;
59
+ declare function parseStateString(value: string | number | Uint8Array | null | undefined): string | null;
60
+ //#endregion
61
+ export { decodeContractStateToBase64, parseStateNumber, parseStateString };
59
62
  //# sourceMappingURL=contract-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-state.d.ts","sourceRoot":"","sources":["../src/contract-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CAC1C,KAAK,EAAE,UAAU,GAAG,WAAW,GAC7B,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAKzB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,GACpD,MAAM,CAWR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,GACpD,MAAM,GAAG,IAAI,CAQf"}
1
+ {"version":3,"file":"contract-state.d.ts","names":[],"sources":["../src/contract-state.ts"],"mappings":";;AA2BA;;;;;;;;;;;;;;AA6BA;;;;;AAyBA;;;iBAtDgB,2BAAA,CACf,KAAA,EAAO,UAAA,GAAa,WAAA,GAClB,KAAA;;;;;;;;;;;;;;;;;;;;;iBA2Ba,gBAAA,CAAiB,KAAA,oBAAyB,UAAA;;;;;;;;;;;;;iBAyB1C,gBAAA,CACf,KAAA,oBAAyB,UAAA"}
@@ -1,117 +1,99 @@
1
+ import { decodeContractState } from "./serialization.js";
2
+ import { uint8ArrayToBase64 } from "./encoding.js";
3
+ //#region src/contract-state.ts
1
4
  /**
2
- * Contract State Utilities
3
- *
4
- * Provides functions for parsing contract state values returned by the Amadeus chain.
5
- * Contract state values are stored as binary (Uint8Array) and need to be decoded
6
- * into usable types (numbers, strings, etc.).
7
- */
8
- import { uint8ArrayToBase64 } from './encoding';
9
- import { decodeContractState } from './serialization';
5
+ * Contract State Utilities
6
+ *
7
+ * Provides functions for parsing contract state values returned by the Amadeus chain.
8
+ * Contract state values are stored as binary (Uint8Array) and need to be decoded
9
+ * into usable types (numbers, strings, etc.).
10
+ */
10
11
  /**
11
- * Decode VecPack-encoded contract state and convert keys/values to Base64 strings.
12
- *
13
- * Useful for serializing decoded contract state for Redux or other stores
14
- * that require JSON-serializable values.
15
- *
16
- * @param bytes - VecPack-encoded bytes (Uint8Array or ArrayBuffer)
17
- * @returns Array of [key, value] tuples as Base64 strings
18
- *
19
- * @example
20
- * ```ts
21
- * const buffer = await response.arrayBuffer()
22
- * const entries = decodeContractStateToBase64(buffer)
23
- * // entries: [["base64key", "base64value"], ...]
24
- * ```
25
- */
26
- export function decodeContractStateToBase64(bytes) {
27
- const pairs = decodeContractState(bytes);
28
- return pairs
29
- .filter(([key, value]) => key.length > 0 && value.length > 0)
30
- .map(([key, value]) => [uint8ArrayToBase64(key), uint8ArrayToBase64(value)]);
12
+ * Decode VecPack-encoded contract state and convert keys/values to Base64 strings.
13
+ *
14
+ * Useful for serializing decoded contract state for Redux or other stores
15
+ * that require JSON-serializable values.
16
+ *
17
+ * @param bytes - VecPack-encoded bytes (Uint8Array or ArrayBuffer)
18
+ * @returns Array of [key, value] tuples as Base64 strings
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const buffer = await response.arrayBuffer()
23
+ * const entries = decodeContractStateToBase64(buffer)
24
+ * // entries: [["base64key", "base64value"], ...]
25
+ * ```
26
+ */
27
+ function decodeContractStateToBase64(bytes) {
28
+ return decodeContractState(bytes).filter(([key, value]) => key.length > 0 && value.length > 0).map(([key, value]) => [uint8ArrayToBase64(key), uint8ArrayToBase64(value)]);
31
29
  }
32
30
  /**
33
- * Parse a contract state value as a number.
34
- *
35
- * Handles multiple input types:
36
- * - `number` — returned directly
37
- * - `string` — parsed as integer
38
- * - `Uint8Array` — first tries UTF-8 digit string, then little-endian binary
39
- * - `null`/`undefined` — returns 0
40
- *
41
- * @param value - Raw contract state value
42
- * @returns Parsed number (0 if unparseable)
43
- *
44
- * @example
45
- * ```ts
46
- * parseStateNumber(new TextEncoder().encode('42')) // 42
47
- * parseStateNumber(new Uint8Array([0x2a, 0x00])) // 42 (little-endian)
48
- * parseStateNumber('100') // 100
49
- * parseStateNumber(null) // 0
50
- * ```
51
- */
52
- export function parseStateNumber(value) {
53
- if (value === null || value === undefined)
54
- return 0;
55
- if (typeof value === 'number')
56
- return Number.isInteger(value) && value >= 0 ? value : 0;
57
- if (typeof value === 'string') {
58
- const parsed = parseInt(value, 10);
59
- return isNaN(parsed) || parsed < 0 ? 0 : parsed;
60
- }
61
- if (value instanceof Uint8Array) {
62
- return decodeUint8ArrayAsNumber(value);
63
- }
64
- return 0;
31
+ * Parse a contract state value as a number.
32
+ *
33
+ * Handles multiple input types:
34
+ * - `number` — returned directly
35
+ * - `string` — parsed as integer
36
+ * - `Uint8Array` — first tries UTF-8 digit string, then little-endian binary
37
+ * - `null`/`undefined` — returns 0
38
+ *
39
+ * @param value - Raw contract state value
40
+ * @returns Parsed number (0 if unparseable)
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * parseStateNumber(new TextEncoder().encode('42')) // 42
45
+ * parseStateNumber(new Uint8Array([0x2a, 0x00])) // 42 (little-endian)
46
+ * parseStateNumber('100') // 100
47
+ * parseStateNumber(null) // 0
48
+ * ```
49
+ */
50
+ function parseStateNumber(value) {
51
+ if (value === null || value === void 0) return 0;
52
+ if (typeof value === "number") return Number.isInteger(value) && value >= 0 ? value : 0;
53
+ if (typeof value === "string") {
54
+ const parsed = parseInt(value, 10);
55
+ return isNaN(parsed) || parsed < 0 ? 0 : parsed;
56
+ }
57
+ if (value instanceof Uint8Array) return decodeUint8ArrayAsNumber(value);
58
+ return 0;
65
59
  }
66
60
  /**
67
- * Parse a contract state value as a string.
68
- *
69
- * Handles multiple input types:
70
- * - `string` — returned directly
71
- * - `number` — converted to string
72
- * - `Uint8Array` — decoded as UTF-8
73
- * - `null`/`undefined` — returns null
74
- *
75
- * @param value - Raw contract state value
76
- * @returns Parsed string or null
77
- */
78
- export function parseStateString(value) {
79
- if (value === null || value === undefined)
80
- return null;
81
- if (typeof value === 'string')
82
- return value;
83
- if (typeof value === 'number')
84
- return value.toString();
85
- if (value instanceof Uint8Array) {
86
- return new TextDecoder().decode(value);
87
- }
88
- return null;
61
+ * Parse a contract state value as a string.
62
+ *
63
+ * Handles multiple input types:
64
+ * - `string` — returned directly
65
+ * - `number` — converted to string
66
+ * - `Uint8Array` — decoded as UTF-8
67
+ * - `null`/`undefined` — returns null
68
+ *
69
+ * @param value - Raw contract state value
70
+ * @returns Parsed string or null
71
+ */
72
+ function parseStateString(value) {
73
+ if (value === null || value === void 0) return null;
74
+ if (typeof value === "string") return value;
75
+ if (typeof value === "number") return value.toString();
76
+ if (value instanceof Uint8Array) return new TextDecoder().decode(value);
77
+ return null;
89
78
  }
90
79
  /**
91
- * Decode a Uint8Array contract state value as a number.
92
- * Tries UTF-8 digit string first, falls back to little-endian binary.
93
- */
80
+ * Decode a Uint8Array contract state value as a number.
81
+ * Tries UTF-8 digit string first, falls back to little-endian binary.
82
+ */
94
83
  function decodeUint8ArrayAsNumber(value) {
95
- if (!value.length)
96
- return 0;
97
- // First try to interpret as UTF-8 digits
98
- try {
99
- const str = new TextDecoder().decode(value);
100
- const parsed = parseInt(str, 10);
101
- if (!isNaN(parsed)) {
102
- return parsed;
103
- }
104
- }
105
- catch {
106
- // Fallthrough to binary parsing
107
- }
108
- // Fallback: parse as little-endian integer (u32/u64)
109
- let result = 0n;
110
- const bytesToRead = Math.min(value.length, 8);
111
- for (let i = 0; i < bytesToRead; i++) {
112
- result |= BigInt(value[i]) << BigInt(i * 8);
113
- }
114
- const asNumber = Number(result);
115
- return Number.isSafeInteger(asNumber) ? asNumber : 0;
84
+ if (!value.length) return 0;
85
+ try {
86
+ const str = new TextDecoder().decode(value);
87
+ const parsed = parseInt(str, 10);
88
+ if (!isNaN(parsed)) return parsed;
89
+ } catch {}
90
+ let result = 0n;
91
+ const bytesToRead = Math.min(value.length, 8);
92
+ for (let i = 0; i < bytesToRead; i++) result |= BigInt(value[i]) << BigInt(i * 8);
93
+ const asNumber = Number(result);
94
+ return Number.isSafeInteger(asNumber) ? asNumber : 0;
116
95
  }
96
+ //#endregion
97
+ export { decodeContractStateToBase64, parseStateNumber, parseStateString };
98
+
117
99
  //# sourceMappingURL=contract-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-state.js","sourceRoot":"","sources":["../src/contract-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,M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,MAAM,CAAC,MAAM,CAAC,CAAA;IAC/B,OAAO,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC"}
1
+ {"version":3,"file":"contract-state.js","names":[],"sources":["../src/contract-state.ts"],"sourcesContent":["/**\n * Contract State Utilities\n *\n * Provides functions for parsing contract state values returned by the Amadeus chain.\n * Contract state values are stored as binary (Uint8Array) and need to be decoded\n * into usable types (numbers, strings, etc.).\n */\n\nimport { uint8ArrayToBase64 } from './encoding'\nimport { decodeContractState } from './serialization'\n\n/**\n * Decode VecPack-encoded contract state and convert keys/values to Base64 strings.\n *\n * Useful for serializing decoded contract state for Redux or other stores\n * that require JSON-serializable values.\n *\n * @param bytes - VecPack-encoded bytes (Uint8Array or ArrayBuffer)\n * @returns Array of [key, value] tuples as Base64 strings\n *\n * @example\n * ```ts\n * const buffer = await response.arrayBuffer()\n * const entries = decodeContractStateToBase64(buffer)\n * // entries: [[\"base64key\", \"base64value\"], ...]\n * ```\n */\nexport function decodeContractStateToBase64(\n\tbytes: Uint8Array | ArrayBuffer\n): Array<[string, string]> {\n\tconst pairs = decodeContractState(bytes)\n\treturn pairs\n\t\t.filter(([key, value]) => key.length > 0 && value.length > 0)\n\t\t.map(([key, value]) => [uint8ArrayToBase64(key), uint8ArrayToBase64(value)])\n}\n\n/**\n * Parse a contract state value as a number.\n *\n * Handles multiple input types:\n * - `number` — returned directly\n * - `string` — parsed as integer\n * - `Uint8Array` — first tries UTF-8 digit string, then little-endian binary\n * - `null`/`undefined` — returns 0\n *\n * @param value - Raw contract state value\n * @returns Parsed number (0 if unparseable)\n *\n * @example\n * ```ts\n * parseStateNumber(new TextEncoder().encode('42')) // 42\n * parseStateNumber(new Uint8Array([0x2a, 0x00])) // 42 (little-endian)\n * parseStateNumber('100') // 100\n * parseStateNumber(null) // 0\n * ```\n */\nexport function parseStateNumber(value: string | number | Uint8Array | null | undefined): number {\n\tif (value === null || value === undefined) return 0\n\tif (typeof value === 'number') return Number.isInteger(value) && value >= 0 ? value : 0\n\tif (typeof value === 'string') {\n\t\tconst parsed = parseInt(value, 10)\n\t\treturn isNaN(parsed) || parsed < 0 ? 0 : parsed\n\t}\n\tif (value instanceof Uint8Array) {\n\t\treturn decodeUint8ArrayAsNumber(value)\n\t}\n\treturn 0\n}\n\n/**\n * Parse a contract state value as a string.\n *\n * Handles multiple input types:\n * - `string` — returned directly\n * - `number` — converted to string\n * - `Uint8Array` — decoded as UTF-8\n * - `null`/`undefined` — returns null\n *\n * @param value - Raw contract state value\n * @returns Parsed string or null\n */\nexport function parseStateString(\n\tvalue: string | number | Uint8Array | null | undefined\n): string | null {\n\tif (value === null || value === undefined) return null\n\tif (typeof value === 'string') return value\n\tif (typeof value === 'number') return value.toString()\n\tif (value instanceof Uint8Array) {\n\t\treturn new TextDecoder().decode(value)\n\t}\n\treturn null\n}\n\n/**\n * Decode a Uint8Array contract state value as a number.\n * Tries UTF-8 digit string first, falls back to little-endian binary.\n */\nfunction decodeUint8ArrayAsNumber(value: Uint8Array): number {\n\tif (!value.length) return 0\n\n\t// First try to interpret as UTF-8 digits\n\ttry {\n\t\tconst str = new TextDecoder().decode(value)\n\t\tconst parsed = parseInt(str, 10)\n\t\tif (!isNaN(parsed)) {\n\t\t\treturn parsed\n\t\t}\n\t} catch {\n\t\t// Fallthrough to binary parsing\n\t}\n\n\t// Fallback: parse as little-endian integer (u32/u64)\n\tlet result = 0n\n\tconst bytesToRead = Math.min(value.length, 8)\n\tfor (let i = 0; i < bytesToRead; i++) {\n\t\tresult |= BigInt(value[i]!) << BigInt(i * 8)\n\t}\n\n\tconst asNumber = Number(result)\n\treturn Number.isSafeInteger(asNumber) ? asNumber : 0\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAgB,4BACf,OAC0B;CAE1B,OADc,oBAAoB,MACtB,CACV,QAAQ,CAAC,KAAK,WAAW,IAAI,SAAS,K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**
2
3
  * Generic ABI Type Extractors
3
4
  *
@@ -7,39 +8,39 @@
7
8
  /**
8
9
  * Shape of an ABI function input
9
10
  */
10
- export interface AbiInput {
11
- readonly name: string;
12
- readonly type: string;
13
- readonly description?: string;
14
- readonly validation?: {
15
- readonly min?: string;
16
- readonly max?: string;
17
- readonly type?: string;
18
- };
19
- readonly enum?: readonly string[];
11
+ interface AbiInput {
12
+ readonly name: string;
13
+ readonly type: string;
14
+ readonly description?: string;
15
+ readonly validation?: {
16
+ readonly min?: string;
17
+ readonly max?: string;
18
+ readonly type?: string;
19
+ };
20
+ readonly enum?: readonly string[];
20
21
  }
21
22
  /**
22
23
  * Shape of an ABI function entry
23
24
  */
24
- export interface AbiFunction {
25
- readonly type: 'function';
26
- readonly name: string;
27
- readonly inputs: readonly AbiInput[];
28
- readonly outputs: readonly unknown[];
29
- readonly stateMutability: string;
30
- readonly description?: string;
31
- readonly requirements?: readonly string[];
32
- readonly storage?: unknown;
25
+ interface AbiFunction {
26
+ readonly type: 'function';
27
+ readonly name: string;
28
+ readonly inputs: readonly AbiInput[];
29
+ readonly outputs: readonly unknown[];
30
+ readonly stateMutability: string;
31
+ readonly description?: string;
32
+ readonly requirements?: readonly string[];
33
+ readonly storage?: unknown;
33
34
  }
34
35
  /**
35
36
  * Shape of any ABI definition (contractName, abi[], errors[], storage)
36
37
  */
37
- export interface AbiDefinition {
38
- readonly contractName: string;
39
- readonly contractVersion?: string;
40
- readonly abi: readonly AbiFunction[];
41
- readonly errors?: readonly unknown[];
42
- readonly storage?: unknown;
38
+ interface AbiDefinition {
39
+ readonly contractName: string;
40
+ readonly contractVersion?: string;
41
+ readonly abi: readonly AbiFunction[];
42
+ readonly errors?: readonly unknown[];
43
+ readonly storage?: unknown;
43
44
  }
44
45
  /**
45
46
  * Extract the literal contract name from an ABI definition
@@ -50,7 +51,7 @@ export interface AbiDefinition {
50
51
  * // => 'LockupPrime'
51
52
  * ```
52
53
  */
53
- export type ExtractContractName<T extends AbiDefinition> = T['contractName'];
54
+ type ExtractContractName<T extends AbiDefinition> = T['contractName'];
54
55
  /**
55
56
  * Extract a union of all function names from an ABI definition
56
57
  *
@@ -60,12 +61,12 @@ export type ExtractContractName<T extends AbiDefinition> = T['contractName'];
60
61
  * // => 'lock' | 'unlock' | 'daily_checkin'
61
62
  * ```
62
63
  */
63
- export type ExtractFunctionNames<T extends AbiDefinition> = T['abi'][number]['name'];
64
+ type ExtractFunctionNames<T extends AbiDefinition> = T['abi'][number]['name'];
64
65
  /**
65
66
  * Find a specific function entry in the ABI by name
66
67
  */
67
68
  type FindFunction<TAbi extends AbiDefinition, TFn extends string> = Extract<TAbi['abi'][number], {
68
- readonly name: TFn;
69
+ readonly name: TFn;
69
70
  }>;
70
71
  /**
71
72
  * Extract the inputs array for a specific function
@@ -80,8 +81,7 @@ type FunctionInputs<TAbi extends AbiDefinition, TFn extends string> = FindFuncti
80
81
  * // => { amount: string; tier: string }
81
82
  * ```
82
83
  */
83
- export type FunctionParams<TAbi extends AbiDefinition, TFn extends string> = {
84
- [K in FunctionInputs<TAbi, TFn>[number] as K['name']]: string;
85
- };
86
- export {};
84
+ type FunctionParams<TAbi extends AbiDefinition, TFn extends string> = { [K in FunctionInputs<TAbi, TFn>[number] as K['name']]: string };
85
+ //#endregion
86
+ export { AbiDefinition, AbiFunction, AbiInput, ExtractContractName, ExtractFunctionNames, FunctionParams };
87
87
  //# sourceMappingURL=abi-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"abi-types.d.ts","sourceRoot":"","sources":["../../src/contracts/abi-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE;QACrB,QAAQ,CAAC,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qC,OAAA,CACnE,IAAA;EAAA,SACW,IAAA,EAAM,GAAA;AAAA;;;;KAMb,cAAA,cAA4B,aAAA,wBAAqC,YAAA,CACrE,IAAA,EACA,GAAA;;;;;;AARoB;;;;KAoBT,cAAA,cAA4B,aAAA,gCACjC,cAAA,CAAe,IAAA,EAAM,GAAA,aAAgB,CAAA"}
@@ -1,25 +1,16 @@
1
- /**
2
- * Coin Contract (Special Case)
3
- *
4
- * The Coin contract is a built-in native contract with no WASM ABI file.
5
- * It differs from WASM contracts:
6
- * - First arg (recipient) is raw binary Uint8Array from fromBase58(), not a UTF-8 string
7
- * - Amount requires toAtomicAma() conversion
8
- *
9
- * This module provides a dedicated builder that handles these special encodings
10
- * while returning a standard ContractCall for uniform consumption by TransactionBuilder.
11
- */
12
- import type { ContractCall } from './contract-call';
1
+ import { ContractCall } from "./contract-call.js";
2
+
3
+ //#region src/contracts/coin.d.ts
13
4
  /**
14
5
  * Parameters for building a Coin transfer call
15
6
  */
16
- export interface CoinTransferParams {
17
- /** Base58-encoded recipient address */
18
- recipient: string;
19
- /** Amount in human-readable units (e.g. 10.5 AMA) */
20
- amount: number | string;
21
- /** Token symbol (e.g. 'AMA') */
22
- symbol: string;
7
+ interface CoinTransferParams {
8
+ /** Base58-encoded recipient address */
9
+ recipient: string;
10
+ /** Amount in human-readable units (e.g. 10.5 AMA) */
11
+ amount: number | string;
12
+ /** Token symbol (e.g. 'AMA') */
13
+ symbol: string;
23
14
  }
24
15
  /**
25
16
  * Build a Coin transfer ContractCall.
@@ -38,5 +29,7 @@ export interface CoinTransferParams {
38
29
  * TransactionBuilder.signCall(privateKey, call)
39
30
  * ```
40
31
  */
41
- export declare function buildCoinTransfer(params: CoinTransferParams): ContractCall;
32
+ declare function buildCoinTransfer(params: CoinTransferParams): ContractCall;
33
+ //#endregion
34
+ export { CoinTransferParams, buildCoinTransfer };
42
35
  //# sourceMappingURL=coin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coin.d.ts","sourceRoot":"","sources":["../../src/contracts/coin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,qDAAqD;IACrD,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;IACvB,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAU1E"}
1
+ {"version":3,"file":"coin.d.ts","names":[],"sources":["../../src/contracts/coin.ts"],"mappings":";;;AA6CA;;;AAAA,UA1BiB,kBAAA;EA0ByB;EAxBzC,SAAA;EAwB8D;EAtB9D,MAAA;EAsB0E;EApB1E,MAAA;AAAA;;;;;;;;;;;;;;;;;;iBAoBe,iBAAA,CAAkB,MAAA,EAAQ,kBAAA,GAAqB,YAAA"}
@@ -1,42 +1,46 @@
1
+ import { fromBase58 } from "../encoding.js";
2
+ import { toAtomicAma } from "../conversion.js";
3
+ //#region src/contracts/coin.ts
1
4
  /**
2
- * Coin Contract (Special Case)
3
- *
4
- * The Coin contract is a built-in native contract with no WASM ABI file.
5
- * It differs from WASM contracts:
6
- * - First arg (recipient) is raw binary Uint8Array from fromBase58(), not a UTF-8 string
7
- * - Amount requires toAtomicAma() conversion
8
- *
9
- * This module provides a dedicated builder that handles these special encodings
10
- * while returning a standard ContractCall for uniform consumption by TransactionBuilder.
11
- */
12
- import { toAtomicAma } from '../conversion';
13
- import { fromBase58 } from '../encoding';
5
+ * Coin Contract (Special Case)
6
+ *
7
+ * The Coin contract is a built-in native contract with no WASM ABI file.
8
+ * It differs from WASM contracts:
9
+ * - First arg (recipient) is raw binary Uint8Array from fromBase58(), not a UTF-8 string
10
+ * - Amount requires toAtomicAma() conversion
11
+ *
12
+ * This module provides a dedicated builder that handles these special encodings
13
+ * while returning a standard ContractCall for uniform consumption by TransactionBuilder.
14
+ */
14
15
  /**
15
- * Build a Coin transfer ContractCall.
16
- *
17
- * Handles the special encoding requirements of the Coin contract:
18
- * - recipient is decoded from Base58 to raw Uint8Array
19
- * - amount is converted to atomic units via toAtomicAma()
20
- *
21
- * @example
22
- * ```ts
23
- * const call = buildCoinTransfer({
24
- * recipient: '5Kd3N...',
25
- * amount: 10.5,
26
- * symbol: 'AMA'
27
- * })
28
- * TransactionBuilder.signCall(privateKey, call)
29
- * ```
30
- */
31
- export function buildCoinTransfer(params) {
32
- return {
33
- contract: 'Coin',
34
- method: 'transfer',
35
- args: [
36
- fromBase58(params.recipient),
37
- toAtomicAma(params.amount).toString(),
38
- params.symbol
39
- ]
40
- };
16
+ * Build a Coin transfer ContractCall.
17
+ *
18
+ * Handles the special encoding requirements of the Coin contract:
19
+ * - recipient is decoded from Base58 to raw Uint8Array
20
+ * - amount is converted to atomic units via toAtomicAma()
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const call = buildCoinTransfer({
25
+ * recipient: '5Kd3N...',
26
+ * amount: 10.5,
27
+ * symbol: 'AMA'
28
+ * })
29
+ * TransactionBuilder.signCall(privateKey, call)
30
+ * ```
31
+ */
32
+ function buildCoinTransfer(params) {
33
+ return {
34
+ contract: "Coin",
35
+ method: "transfer",
36
+ args: [
37
+ fromBase58(params.recipient),
38
+ toAtomicAma(params.amount).toString(),
39
+ params.symbol
40
+ ]
41
+ };
41
42
  }
43
+ //#endregion
44
+ export { buildCoinTransfer };
45
+
42
46
  //# sourceMappingURL=coin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"coin.js","sourceRoot":"","sources":["../../src/contracts/coin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAexC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA0B;IAC3D,OAAO;QACN,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE;YACL,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC;YAC5B,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;YACrC,MAAM,CAAC,MAAM;SACb;KACD,CAAA;AACF,CAAC"}
1
+ {"version":3,"file":"coin.js","names":[],"sources":["../../src/contracts/coin.ts"],"sourcesContent":["/**\n * Coin Contract (Special Case)\n *\n * The Coin contract is a built-in native contract with no WASM ABI file.\n * It differs from WASM contracts:\n * - First arg (recipient) is raw binary Uint8Array from fromBase58(), not a UTF-8 string\n * - Amount requires toAtomicAma() conversion\n *\n * This module provides a dedicated builder that handles these special encodings\n * while returning a standard ContractCall for uniform consumption by TransactionBuilder.\n */\n\nimport { toAtomicAma } from '../conversion'\nimport { fromBase58 } from '../encoding'\nimport type { ContractCall } from './contract-call'\n\n/**\n * Parameters for building a Coin transfer call\n */\nexport interface CoinTransferParams {\n\t/** Base58-encoded recipient address */\n\trecipient: string\n\t/** Amount in human-readable units (e.g. 10.5 AMA) */\n\tamount: number | string\n\t/** Token symbol (e.g. 'AMA') */\n\tsymbol: string\n}\n\n/**\n * Build a Coin transfer ContractCall.\n *\n * Handles the special encoding requirements of the Coin contract:\n * - recipient is decoded from Base58 to raw Uint8Array\n * - amount is converted to atomic units via toAtomicAma()\n *\n * @example\n * ```ts\n * const call = buildCoinTransfer({\n * recipient: '5Kd3N...',\n * amount: 10.5,\n * symbol: 'AMA'\n * })\n * TransactionBuilder.signCall(privateKey, call)\n * ```\n */\nexport function buildCoinTransfer(params: CoinTransferParams): ContractCall {\n\treturn {\n\t\tcontract: 'Coin',\n\t\tmethod: 'transfer',\n\t\targs: [fromBase58(params.recipient), toAtomicAma(params.amount).toString(), params.symbol]\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,kBAAkB,QAA0C;CAC3E,OAAO;EACN,UAAU;EACV,QAAQ;EACR,MAAM;GAAC,WAAW,OAAO,UAAU;GAAE,YAAY,OAAO,OAAO,CAAC,UAAU;GAAE,OAAO;GAAO;EAC1F"}