@amadeus-protocol/sdk 1.0.7 → 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 -54
  128. package/dist/index.js +39 -54
  129. package/dist/mnemonic.d.ts +99 -0
  130. package/dist/mnemonic.d.ts.map +1 -0
  131. package/dist/mnemonic.js +119 -0
  132. package/dist/mnemonic.js.map +1 -0
  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 +5 -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
@@ -1,18 +1,17 @@
1
- /**
2
- * Type Definitions for LockupPrime smart contract
3
- *
4
- * Replaces Zod schemas with plain TypeScript types and type guards.
5
- */
1
+ //#region src/contracts/lockup-prime/types.ts
6
2
  /** Runtime array of all valid tier keys (for validation) */
7
- export const LOCKUP_PRIME_TIER_KEYS = [
8
- '7d',
9
- '30d',
10
- '90d',
11
- '180d',
12
- '365d'
3
+ const LOCKUP_PRIME_TIER_KEYS = [
4
+ "7d",
5
+ "30d",
6
+ "90d",
7
+ "180d",
8
+ "365d"
13
9
  ];
14
10
  /** Type guard to check if a string is a valid tier key */
15
- export function isValidLockupPrimeTierKey(value) {
16
- return LOCKUP_PRIME_TIER_KEYS.includes(value);
11
+ function isValidLockupPrimeTierKey(value) {
12
+ return LOCKUP_PRIME_TIER_KEYS.includes(value);
17
13
  }
14
+ //#endregion
15
+ export { LOCKUP_PRIME_TIER_KEYS, isValidLockupPrimeTierKey };
16
+
18
17
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/contracts/lockup-prime/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,sBAAsB,GAAkC;IACpE,IAAI;IACJ,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;CACG,CAAA;AAEV,0DAA0D;AAC1D,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACtD,OAAQ,sBAA4C,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACrE,CAAC"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/contracts/lockup-prime/types.ts"],"sourcesContent":["/**\n * Type Definitions for LockupPrime smart contract\n *\n * Replaces Zod schemas with plain TypeScript types and type guards.\n */\n\n// ── Tier Key Union ──────────────────────────────────────────────────\n\n/** Valid lockup prime tier keys */\nexport type LockupPrimeTierKey = '7d' | '30d' | '90d' | '180d' | '365d'\n\n/** Runtime array of all valid tier keys (for validation) */\nexport const LOCKUP_PRIME_TIER_KEYS: readonly LockupPrimeTierKey[] = [\n\t'7d',\n\t'30d',\n\t'90d',\n\t'180d',\n\t'365d'\n] as const\n\n/** Type guard to check if a string is a valid tier key */\nexport function isValidLockupPrimeTierKey(value: string): value is LockupPrimeTierKey {\n\treturn (LOCKUP_PRIME_TIER_KEYS as readonly string[]).includes(value)\n}\n\n// ── Vault Types ─────────────────────────────────────────────────────\n\n/** Parsed LockupPrime vault */\nexport interface LockupPrimeVault {\n\ttier: LockupPrimeTierKey\n\tmultiplier: number\n\tunlockEpoch: number\n\tlockEpoch: number\n\tamount: number\n\tvaultIndex: number\n}\n\n/** Intermediate parse result from raw vault data string */\nexport interface RawLockupPrimeVaultData {\n\ttier: string\n\tmultiplier: number\n\tunlockEpoch: number\n\tamountFlat: number\n}\n\n/** Extended tier information with UI-specific fields */\nexport interface LockupTier {\n\ttier: string\n\tepochs: number\n\tmultiplier: number\n\tlabel: string\n\tdurationDays: number\n\trate?: number\n}\n\n// ── ABI Types ───────────────────────────────────────────────────────\n\nexport interface LockupPrimeAbiFunction {\n\ttype: 'function'\n\tname: string\n\tinputs: LockupPrimeAbiInput[]\n\toutputs: LockupPrimeAbiOutput[]\n\tstateMutability: 'nonpayable' | 'payable' | 'view' | 'pure'\n\tdescription?: string\n\trequirements?: string[]\n\tstorage?: {\n\t\treads?: LockupPrimeAbiStorageRead[]\n\t\twrites?: LockupPrimeAbiStorageWrite[]\n\t}\n}\n\nexport interface LockupPrimeAbiInput {\n\tname: string\n\ttype: string\n\tdescription?: string\n\tvalidation?: {\n\t\tmin?: string\n\t\tmax?: string\n\t\ttype?: string\n\t}\n\tenum?: string[]\n}\n\nexport interface LockupPrimeAbiOutput {\n\tname: string\n\ttype: string\n\tdescription?: string\n}\n\nexport interface LockupPrimeAbiError {\n\tname: string\n\tcode: string\n\tdescription: string\n}\n\nexport interface LockupPrimeAbiStorage {\n\tkeys: LockupPrimeAbiStorageKey[]\n}\n\nexport interface LockupPrimeAbiStorageKey {\n\tname: string\n\tpattern: string\n\ttype: 'mapping' | 'value' | 'array'\n\tdescription: string\n\tvalueFormat?: string\n\tvalueSchema?: Record<string, any>\n\tquery?: {\n\t\tmethod: string\n\t\tendpoint: string\n\t\tprefix?: string\n\t\tkey?: string\n\t\tdescription: string\n\t}\n}\n\nexport interface LockupPrimeAbiStorageRead {\n\tkey: string\n\tdescription?: string\n\tvalue?: string\n}\n\nexport interface LockupPrimeAbiStorageWrite {\n\tkey: string\n\tvalue?: string\n\toperation?: 'increment' | 'decrement' | 'create' | 'delete' | 'mint'\n\tamount?: string\n\tduration?: string\n\tdescription?: string\n\tcondition?: string\n\twrites?: LockupPrimeAbiStorageWrite[]\n}\n\nexport interface LockupPrimeAbiConstant {\n\ttiers: Record<LockupPrimeTierKey, { epochs: number; multiplier: number; label: string }>\n\tvalues: Record<string, string>\n}\n\n// ── Deprecated Aliases (backward compatibility) ─────────────────────\n\n/** @deprecated Use `LockupPrimeVault` instead */\nexport type LockupPrimeVaultSchema = LockupPrimeVault\n\n/** @deprecated Use `LockupPrimeTierKey` instead */\nexport type LockupTiersSchema = LockupPrimeTierKey\n"],"mappings":";;AAYA,MAAa,yBAAwD;CACpE;CACA;CACA;CACA;CACA;CACA;;AAGD,SAAgB,0BAA0B,OAA4C;CACrF,OAAQ,uBAA6C,SAAS,MAAM"}
@@ -0,0 +1,104 @@
1
+ //#region src/contracts/nft/abi.d.ts
2
+ /**
3
+ * Nft Smart Contract ABI
4
+ *
5
+ * Built-in NFT contract.
6
+ * Source of truth: ex/native/rdb/src/consensus/bic/nft.rs
7
+ */
8
+ declare const NFT_ABI: {
9
+ readonly contractName: "Nft";
10
+ readonly contractVersion: "1.0.0";
11
+ readonly abi: readonly [{
12
+ readonly type: "function";
13
+ readonly name: "transfer";
14
+ readonly inputs: readonly [{
15
+ readonly name: "receiver";
16
+ readonly type: "address";
17
+ readonly description: "Recipient public key (48-byte raw bytes)";
18
+ }, {
19
+ readonly name: "amount";
20
+ readonly type: "string";
21
+ readonly description: "Amount of token units to transfer (positive integer as string)";
22
+ }, {
23
+ readonly name: "collection";
24
+ readonly type: "string";
25
+ readonly description: "Collection name (ASCII alphanumeric, 1-32 chars)";
26
+ }, {
27
+ readonly name: "token";
28
+ readonly type: "string";
29
+ readonly description: "Token id within the collection (1-32 bytes)";
30
+ }];
31
+ readonly outputs: readonly [];
32
+ readonly stateMutability: "nonpayable";
33
+ readonly description: "Transfer NFT tokens to another account";
34
+ readonly requirements: readonly ["receiver must be a valid public key or burn address", "amount must be > 0", "caller must hold at least `amount` tokens of (collection, token)", "collection must not be soulbound"];
35
+ }, {
36
+ readonly type: "function";
37
+ readonly name: "create_collection";
38
+ readonly inputs: readonly [{
39
+ readonly name: "collection";
40
+ readonly type: "string";
41
+ readonly description: "Collection name (ASCII alphanumeric, 1-32 chars)";
42
+ }, {
43
+ readonly name: "soulbound";
44
+ readonly type: "string";
45
+ readonly description: "Soulbound flag — \"true\" to disable transfers, otherwise \"false\"";
46
+ }];
47
+ readonly outputs: readonly [];
48
+ readonly stateMutability: "nonpayable";
49
+ readonly description: "Create a new NFT collection owned by the caller";
50
+ readonly requirements: readonly ["collection name must be ASCII alphanumeric, 1-32 chars", "collection must not already exist", "collection name must not be reserved"];
51
+ }, {
52
+ readonly type: "function";
53
+ readonly name: "mint";
54
+ readonly inputs: readonly [{
55
+ readonly name: "receiver";
56
+ readonly type: "address";
57
+ readonly description: "Recipient public key (48-byte raw bytes)";
58
+ }, {
59
+ readonly name: "amount";
60
+ readonly type: "string";
61
+ readonly description: "Amount of token units to mint (positive integer as string)";
62
+ }, {
63
+ readonly name: "collection";
64
+ readonly type: "string";
65
+ readonly description: "Collection name";
66
+ }, {
67
+ readonly name: "token";
68
+ readonly type: "string";
69
+ readonly description: "Token id within the collection (1-32 bytes)";
70
+ }];
71
+ readonly outputs: readonly [];
72
+ readonly stateMutability: "nonpayable";
73
+ readonly description: "Mint new NFT tokens (only callable by the collection owner)";
74
+ readonly requirements: readonly ["collection must exist", "caller must be the collection owner (view_account)", "token id must be 1-32 bytes", "amount must be > 0"];
75
+ }];
76
+ readonly storage: {
77
+ readonly keys: readonly [{
78
+ readonly name: "balance";
79
+ readonly pattern: "account:{pk}:nft:{collection}:{token}";
80
+ readonly type: "mapping";
81
+ readonly description: "Per-token NFT balance for an account";
82
+ readonly valueFormat: "string";
83
+ readonly valueSchema: {
84
+ readonly type: "string";
85
+ readonly format: "i128";
86
+ readonly description: "Token balance as integer string";
87
+ };
88
+ }, {
89
+ readonly name: "view_account";
90
+ readonly pattern: "nft:{collection}:view_account";
91
+ readonly type: "value";
92
+ readonly description: "Owner of the collection (raw 48-byte pk)";
93
+ }, {
94
+ readonly name: "soulbound";
95
+ readonly pattern: "nft:{collection}:soulbound";
96
+ readonly type: "value";
97
+ readonly description: "Soulbound flag for the collection (\"true\" or absent)";
98
+ }];
99
+ };
100
+ readonly errors: readonly [];
101
+ };
102
+ //#endregion
103
+ export { NFT_ABI };
104
+ //# sourceMappingURL=abi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.d.ts","names":[],"sources":["../../../src/contracts/nft/abi.ts"],"mappings":";;AAMA;;;;;cAAa,OAAA;EAAA"}
@@ -0,0 +1,135 @@
1
+ //#region src/contracts/nft/abi.ts
2
+ /**
3
+ * Nft Smart Contract ABI
4
+ *
5
+ * Built-in NFT contract.
6
+ * Source of truth: ex/native/rdb/src/consensus/bic/nft.rs
7
+ */
8
+ const NFT_ABI = {
9
+ contractName: "Nft",
10
+ contractVersion: "1.0.0",
11
+ abi: [
12
+ {
13
+ type: "function",
14
+ name: "transfer",
15
+ inputs: [
16
+ {
17
+ name: "receiver",
18
+ type: "address",
19
+ description: "Recipient public key (48-byte raw bytes)"
20
+ },
21
+ {
22
+ name: "amount",
23
+ type: "string",
24
+ description: "Amount of token units to transfer (positive integer as string)"
25
+ },
26
+ {
27
+ name: "collection",
28
+ type: "string",
29
+ description: "Collection name (ASCII alphanumeric, 1-32 chars)"
30
+ },
31
+ {
32
+ name: "token",
33
+ type: "string",
34
+ description: "Token id within the collection (1-32 bytes)"
35
+ }
36
+ ],
37
+ outputs: [],
38
+ stateMutability: "nonpayable",
39
+ description: "Transfer NFT tokens to another account",
40
+ requirements: [
41
+ "receiver must be a valid public key or burn address",
42
+ "amount must be > 0",
43
+ "caller must hold at least `amount` tokens of (collection, token)",
44
+ "collection must not be soulbound"
45
+ ]
46
+ },
47
+ {
48
+ type: "function",
49
+ name: "create_collection",
50
+ inputs: [{
51
+ name: "collection",
52
+ type: "string",
53
+ description: "Collection name (ASCII alphanumeric, 1-32 chars)"
54
+ }, {
55
+ name: "soulbound",
56
+ type: "string",
57
+ description: "Soulbound flag — \"true\" to disable transfers, otherwise \"false\""
58
+ }],
59
+ outputs: [],
60
+ stateMutability: "nonpayable",
61
+ description: "Create a new NFT collection owned by the caller",
62
+ requirements: [
63
+ "collection name must be ASCII alphanumeric, 1-32 chars",
64
+ "collection must not already exist",
65
+ "collection name must not be reserved"
66
+ ]
67
+ },
68
+ {
69
+ type: "function",
70
+ name: "mint",
71
+ inputs: [
72
+ {
73
+ name: "receiver",
74
+ type: "address",
75
+ description: "Recipient public key (48-byte raw bytes)"
76
+ },
77
+ {
78
+ name: "amount",
79
+ type: "string",
80
+ description: "Amount of token units to mint (positive integer as string)"
81
+ },
82
+ {
83
+ name: "collection",
84
+ type: "string",
85
+ description: "Collection name"
86
+ },
87
+ {
88
+ name: "token",
89
+ type: "string",
90
+ description: "Token id within the collection (1-32 bytes)"
91
+ }
92
+ ],
93
+ outputs: [],
94
+ stateMutability: "nonpayable",
95
+ description: "Mint new NFT tokens (only callable by the collection owner)",
96
+ requirements: [
97
+ "collection must exist",
98
+ "caller must be the collection owner (view_account)",
99
+ "token id must be 1-32 bytes",
100
+ "amount must be > 0"
101
+ ]
102
+ }
103
+ ],
104
+ storage: { keys: [
105
+ {
106
+ name: "balance",
107
+ pattern: "account:{pk}:nft:{collection}:{token}",
108
+ type: "mapping",
109
+ description: "Per-token NFT balance for an account",
110
+ valueFormat: "string",
111
+ valueSchema: {
112
+ type: "string",
113
+ format: "i128",
114
+ description: "Token balance as integer string"
115
+ }
116
+ },
117
+ {
118
+ name: "view_account",
119
+ pattern: "nft:{collection}:view_account",
120
+ type: "value",
121
+ description: "Owner of the collection (raw 48-byte pk)"
122
+ },
123
+ {
124
+ name: "soulbound",
125
+ pattern: "nft:{collection}:soulbound",
126
+ type: "value",
127
+ description: "Soulbound flag for the collection (\"true\" or absent)"
128
+ }
129
+ ] },
130
+ errors: []
131
+ };
132
+ //#endregion
133
+ export { NFT_ABI };
134
+
135
+ //# sourceMappingURL=abi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.js","names":[],"sources":["../../../src/contracts/nft/abi.ts"],"sourcesContent":["/**\n * Nft Smart Contract ABI\n *\n * Built-in NFT contract.\n * Source of truth: ex/native/rdb/src/consensus/bic/nft.rs\n */\nexport const NFT_ABI = {\n\tcontractName: 'Nft',\n\tcontractVersion: '1.0.0',\n\tabi: [\n\t\t{\n\t\t\ttype: 'function',\n\t\t\tname: 'transfer',\n\t\t\tinputs: [\n\t\t\t\t{\n\t\t\t\t\tname: 'receiver',\n\t\t\t\t\ttype: 'address',\n\t\t\t\t\tdescription: 'Recipient public key (48-byte raw bytes)'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'amount',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'Amount of token units to transfer (positive integer as string)'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'collection',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'Collection name (ASCII alphanumeric, 1-32 chars)'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'token',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'Token id within the collection (1-32 bytes)'\n\t\t\t\t}\n\t\t\t],\n\t\t\toutputs: [],\n\t\t\tstateMutability: 'nonpayable',\n\t\t\tdescription: 'Transfer NFT tokens to another account',\n\t\t\trequirements: [\n\t\t\t\t'receiver must be a valid public key or burn address',\n\t\t\t\t'amount must be > 0',\n\t\t\t\t'caller must hold at least `amount` tokens of (collection, token)',\n\t\t\t\t'collection must not be soulbound'\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\ttype: 'function',\n\t\t\tname: 'create_collection',\n\t\t\tinputs: [\n\t\t\t\t{\n\t\t\t\t\tname: 'collection',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'Collection name (ASCII alphanumeric, 1-32 chars)'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'soulbound',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'Soulbound flag — \"true\" to disable transfers, otherwise \"false\"'\n\t\t\t\t}\n\t\t\t],\n\t\t\toutputs: [],\n\t\t\tstateMutability: 'nonpayable',\n\t\t\tdescription: 'Create a new NFT collection owned by the caller',\n\t\t\trequirements: [\n\t\t\t\t'collection name must be ASCII alphanumeric, 1-32 chars',\n\t\t\t\t'collection must not already exist',\n\t\t\t\t'collection name must not be reserved'\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\ttype: 'function',\n\t\t\tname: 'mint',\n\t\t\tinputs: [\n\t\t\t\t{\n\t\t\t\t\tname: 'receiver',\n\t\t\t\t\ttype: 'address',\n\t\t\t\t\tdescription: 'Recipient public key (48-byte raw bytes)'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'amount',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'Amount of token units to mint (positive integer as string)'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'collection',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'Collection name'\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tname: 'token',\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tdescription: 'Token id within the collection (1-32 bytes)'\n\t\t\t\t}\n\t\t\t],\n\t\t\toutputs: [],\n\t\t\tstateMutability: 'nonpayable',\n\t\t\tdescription: 'Mint new NFT tokens (only callable by the collection owner)',\n\t\t\trequirements: [\n\t\t\t\t'collection must exist',\n\t\t\t\t'caller must be the collection owner (view_account)',\n\t\t\t\t'token id must be 1-32 bytes',\n\t\t\t\t'amount must be > 0'\n\t\t\t]\n\t\t}\n\t],\n\tstorage: {\n\t\tkeys: [\n\t\t\t{\n\t\t\t\tname: 'balance',\n\t\t\t\tpattern: 'account:{pk}:nft:{collection}:{token}',\n\t\t\t\ttype: 'mapping',\n\t\t\t\tdescription: 'Per-token NFT balance for an account',\n\t\t\t\tvalueFormat: 'string',\n\t\t\t\tvalueSchema: {\n\t\t\t\t\ttype: 'string',\n\t\t\t\t\tformat: 'i128',\n\t\t\t\t\tdescription: 'Token balance as integer string'\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'view_account',\n\t\t\t\tpattern: 'nft:{collection}:view_account',\n\t\t\t\ttype: 'value',\n\t\t\t\tdescription: 'Owner of the collection (raw 48-byte pk)'\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'soulbound',\n\t\t\t\tpattern: 'nft:{collection}:soulbound',\n\t\t\t\ttype: 'value',\n\t\t\t\tdescription: 'Soulbound flag for the collection (\"true\" or absent)'\n\t\t\t}\n\t\t]\n\t},\n\terrors: []\n} as const\n"],"mappings":";;;;;;;AAMA,MAAa,UAAU;CACtB,cAAc;CACd,iBAAiB;CACjB,KAAK;EACJ;GACC,MAAM;GACN,MAAM;GACN,QAAQ;IACP;KACC,MAAM;KACN,MAAM;KACN,aAAa;KACb;IACD;KACC,MAAM;KACN,MAAM;KACN,aAAa;KACb;IACD;KACC,MAAM;KACN,MAAM;KACN,aAAa;KACb;IACD;KACC,MAAM;KACN,MAAM;KACN,aAAa;KACb;IACD;GACD,SAAS,EAAE;GACX,iBAAiB;GACjB,aAAa;GACb,cAAc;IACb;IACA;IACA;IACA;IACA;GACD;EACD;GACC,MAAM;GACN,MAAM;GACN,QAAQ,CACP;IACC,MAAM;IACN,MAAM;IACN,aAAa;IACb,EACD;IACC,MAAM;IACN,MAAM;IACN,aAAa;IACb,CACD;GACD,SAAS,EAAE;GACX,iBAAiB;GACjB,aAAa;GACb,cAAc;IACb;IACA;IACA;IACA;GACD;EACD;GACC,MAAM;GACN,MAAM;GACN,QAAQ;IACP;KACC,MAAM;KACN,MAAM;KACN,aAAa;KACb;IACD;KACC,MAAM;KACN,MAAM;KACN,aAAa;KACb;IACD;KACC,MAAM;KACN,MAAM;KACN,aAAa;KACb;IACD;KACC,MAAM;KACN,MAAM;KACN,aAAa;KACb;IACD;GACD,SAAS,EAAE;GACX,iBAAiB;GACjB,aAAa;GACb,cAAc;IACb;IACA;IACA;IACA;IACA;GACD;EACD;CACD,SAAS,EACR,MAAM;EACL;GACC,MAAM;GACN,SAAS;GACT,MAAM;GACN,aAAa;GACb,aAAa;GACb,aAAa;IACZ,MAAM;IACN,QAAQ;IACR,aAAa;IACb;GACD;EACD;GACC,MAAM;GACN,SAAS;GACT,MAAM;GACN,aAAa;GACb;EACD;GACC,MAAM;GACN,SAAS;GACT,MAAM;GACN,aAAa;GACb;EACD,EACD;CACD,QAAQ,EAAE;CACV"}
@@ -0,0 +1,21 @@
1
+ import { ContractCall } from "../contract-call.js";
2
+ import { NftCreateCollectionParams, NftMintParams, NftTransferParams } from "./types.js";
3
+
4
+ //#region src/contracts/nft/helpers.d.ts
5
+ /**
6
+ * Build an `Nft.transfer` ContractCall.
7
+ */
8
+ declare function buildNftTransfer(params: NftTransferParams): ContractCall;
9
+ /**
10
+ * Build an `Nft.mint` ContractCall.
11
+ *
12
+ * Only callable by the collection owner.
13
+ */
14
+ declare function buildNftMint(params: NftMintParams): ContractCall;
15
+ /**
16
+ * Build an `Nft.create_collection` ContractCall.
17
+ */
18
+ declare function buildNftCreateCollection(params: NftCreateCollectionParams): ContractCall;
19
+ //#endregion
20
+ export { buildNftCreateCollection, buildNftMint, buildNftTransfer };
21
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","names":[],"sources":["../../../src/contracts/nft/helpers.ts"],"mappings":";;;;;;;iBAwBgB,gBAAA,CAAiB,MAAA,EAAQ,iBAAA,GAAoB,YAAA;AAkB7D;;;;;AAAA,iBAAgB,YAAA,CAAa,MAAA,EAAQ,aAAA,GAAgB,YAAA;;;;iBAgBrC,wBAAA,CAAyB,MAAA,EAAQ,yBAAA,GAA4B,YAAA"}
@@ -0,0 +1,61 @@
1
+ import { fromBase58 } from "../../encoding.js";
2
+ //#region src/contracts/nft/helpers.ts
3
+ /**
4
+ * Builder helpers for the Nft built-in contract.
5
+ *
6
+ * Each helper returns a `ContractCall` that can be passed to `TransactionBuilder`
7
+ * for signing and submission. NFT amounts are integer counts (not atomic AMA), and
8
+ * `receiver` is decoded from Base58 to raw 48-byte public key bytes.
9
+ */
10
+ function amountToIntegerString(amount) {
11
+ if (typeof amount === "bigint") return amount.toString();
12
+ if (typeof amount === "string") return amount;
13
+ if (!Number.isFinite(amount) || !Number.isInteger(amount) || amount <= 0) throw new Error(`invalid_amount: ${amount}`);
14
+ return amount.toString();
15
+ }
16
+ /**
17
+ * Build an `Nft.transfer` ContractCall.
18
+ */
19
+ function buildNftTransfer(params) {
20
+ return {
21
+ contract: "Nft",
22
+ method: "transfer",
23
+ args: [
24
+ fromBase58(params.recipient),
25
+ amountToIntegerString(params.amount),
26
+ params.collection,
27
+ params.token
28
+ ]
29
+ };
30
+ }
31
+ /**
32
+ * Build an `Nft.mint` ContractCall.
33
+ *
34
+ * Only callable by the collection owner.
35
+ */
36
+ function buildNftMint(params) {
37
+ return {
38
+ contract: "Nft",
39
+ method: "mint",
40
+ args: [
41
+ fromBase58(params.recipient),
42
+ amountToIntegerString(params.amount),
43
+ params.collection,
44
+ params.token
45
+ ]
46
+ };
47
+ }
48
+ /**
49
+ * Build an `Nft.create_collection` ContractCall.
50
+ */
51
+ function buildNftCreateCollection(params) {
52
+ return {
53
+ contract: "Nft",
54
+ method: "create_collection",
55
+ args: [params.collection, params.soulbound ? "true" : "false"]
56
+ };
57
+ }
58
+ //#endregion
59
+ export { buildNftCreateCollection, buildNftMint, buildNftTransfer };
60
+
61
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","names":[],"sources":["../../../src/contracts/nft/helpers.ts"],"sourcesContent":["/**\n * Builder helpers for the Nft built-in contract.\n *\n * Each helper returns a `ContractCall` that can be passed to `TransactionBuilder`\n * for signing and submission. NFT amounts are integer counts (not atomic AMA), and\n * `receiver` is decoded from Base58 to raw 48-byte public key bytes.\n */\n\nimport { fromBase58 } from '../../encoding'\nimport type { ContractCall } from '../contract-call'\nimport type { NftTransferParams, NftMintParams, NftCreateCollectionParams } from './types'\n\nfunction amountToIntegerString(amount: number | string | bigint): string {\n\tif (typeof amount === 'bigint') return amount.toString()\n\tif (typeof amount === 'string') return amount\n\tif (!Number.isFinite(amount) || !Number.isInteger(amount) || amount <= 0) {\n\t\tthrow new Error(`invalid_amount: ${amount}`)\n\t}\n\treturn amount.toString()\n}\n\n/**\n * Build an `Nft.transfer` ContractCall.\n */\nexport function buildNftTransfer(params: NftTransferParams): ContractCall {\n\treturn {\n\t\tcontract: 'Nft',\n\t\tmethod: 'transfer',\n\t\targs: [\n\t\t\tfromBase58(params.recipient),\n\t\t\tamountToIntegerString(params.amount),\n\t\t\tparams.collection,\n\t\t\tparams.token\n\t\t]\n\t}\n}\n\n/**\n * Build an `Nft.mint` ContractCall.\n *\n * Only callable by the collection owner.\n */\nexport function buildNftMint(params: NftMintParams): ContractCall {\n\treturn {\n\t\tcontract: 'Nft',\n\t\tmethod: 'mint',\n\t\targs: [\n\t\t\tfromBase58(params.recipient),\n\t\t\tamountToIntegerString(params.amount),\n\t\t\tparams.collection,\n\t\t\tparams.token\n\t\t]\n\t}\n}\n\n/**\n * Build an `Nft.create_collection` ContractCall.\n */\nexport function buildNftCreateCollection(params: NftCreateCollectionParams): ContractCall {\n\treturn {\n\t\tcontract: 'Nft',\n\t\tmethod: 'create_collection',\n\t\targs: [params.collection, params.soulbound ? 'true' : 'false']\n\t}\n}\n"],"mappings":";;;;;;;;;AAYA,SAAS,sBAAsB,QAA0C;CACxE,IAAI,OAAO,WAAW,UAAU,OAAO,OAAO,UAAU;CACxD,IAAI,OAAO,WAAW,UAAU,OAAO;CACvC,IAAI,CAAC,OAAO,SAAS,OAAO,IAAI,CAAC,OAAO,UAAU,OAAO,IAAI,UAAU,GACtE,MAAM,IAAI,MAAM,mBAAmB,SAAS;CAE7C,OAAO,OAAO,UAAU;;;;;AAMzB,SAAgB,iBAAiB,QAAyC;CACzE,OAAO;EACN,UAAU;EACV,QAAQ;EACR,MAAM;GACL,WAAW,OAAO,UAAU;GAC5B,sBAAsB,OAAO,OAAO;GACpC,OAAO;GACP,OAAO;GACP;EACD;;;;;;;AAQF,SAAgB,aAAa,QAAqC;CACjE,OAAO;EACN,UAAU;EACV,QAAQ;EACR,MAAM;GACL,WAAW,OAAO,UAAU;GAC5B,sBAAsB,OAAO,OAAO;GACpC,OAAO;GACP,OAAO;GACP;EACD;;;;;AAMF,SAAgB,yBAAyB,QAAiD;CACzF,OAAO;EACN,UAAU;EACV,QAAQ;EACR,MAAM,CAAC,OAAO,YAAY,OAAO,YAAY,SAAS,QAAQ;EAC9D"}
@@ -0,0 +1,47 @@
1
+ //#region src/contracts/nft/types.d.ts
2
+ /**
3
+ * Type definitions for the Nft built-in contract.
4
+ */
5
+ /** Parameters for `Nft.transfer(receiver, amount, collection, token)` */
6
+ interface NftTransferParams {
7
+ /** Base58-encoded recipient address */
8
+ recipient: string;
9
+ /** Number of token units to transfer */
10
+ amount: number | string | bigint;
11
+ /** Collection name */
12
+ collection: string;
13
+ /** Token id within the collection */
14
+ token: string;
15
+ }
16
+ /** Parameters for `Nft.mint(receiver, amount, collection, token)` */
17
+ interface NftMintParams {
18
+ /** Base58-encoded recipient address */
19
+ recipient: string;
20
+ /** Number of token units to mint */
21
+ amount: number | string | bigint;
22
+ /** Collection name */
23
+ collection: string;
24
+ /** Token id within the collection */
25
+ token: string;
26
+ }
27
+ /** Parameters for `Nft.create_collection(collection, soulbound)` */
28
+ interface NftCreateCollectionParams {
29
+ /** Collection name (ASCII alphanumeric, 1-32 chars) */
30
+ collection: string;
31
+ /** When true, tokens cannot be transferred after minting */
32
+ soulbound?: boolean;
33
+ }
34
+ /** Inputs for builder convenience methods that need a private key */
35
+ interface NftTransferInput extends NftTransferParams {
36
+ /** Base58-encoded sender private key (seed) */
37
+ senderPrivkey: string;
38
+ }
39
+ interface NftMintInput extends NftMintParams {
40
+ senderPrivkey: string;
41
+ }
42
+ interface NftCreateCollectionInput extends NftCreateCollectionParams {
43
+ senderPrivkey: string;
44
+ }
45
+ //#endregion
46
+ export { NftCreateCollectionInput, NftCreateCollectionParams, NftMintInput, NftMintParams, NftTransferInput, NftTransferParams };
47
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/contracts/nft/types.ts"],"mappings":";;AAKA;;;UAAiB,iBAAA;EAEhB;EAAA,SAAA;EAIA;EAFA,MAAA;EAIK;EAFL,UAAA;EAMgB;EAJhB,KAAA;AAAA;;UAIgB,aAAA;EAIhB;EAFA,SAAA;EAMA;EAJA,MAAA;EAIK;EAFL,UAAA;EAMyC;EAJzC,KAAA;AAAA;;UAIgB,yBAAA;EAQiB;EANjC,UAAA;EAMyC;EAJzC,SAAA;AAAA;;UAIgB,gBAAA,SAAyB,iBAAA;EAKJ;EAHrC,aAAA;AAAA;AAAA,UAGgB,YAAA,SAAqB,aAAA;EACrC,aAAA;AAAA;AAAA,UAGgB,wBAAA,SAAiC,yBAAA;EACjD,aAAA;AAAA"}
@@ -1,3 +1,4 @@
1
+ //#region src/conversion.d.ts
1
2
  /**
2
3
  * Token Conversion Utilities
3
4
  *
@@ -16,7 +17,7 @@
16
17
  * const ama = fromAtomicAma(1000000000) // Returns 1.0
17
18
  * ```
18
19
  */
19
- export declare function fromAtomicAma(atomicAma: number | string): number;
20
+ declare function fromAtomicAma(atomicAma: number | string): number;
20
21
  /**
21
22
  * Convert human-readable AMA amount to atomic units
22
23
  *
@@ -32,5 +33,7 @@ export declare function fromAtomicAma(atomicAma: number | string): number;
32
33
  * const atomic = toAtomicAma('1.00000001') // Returns 1000000010
33
34
  * ```
34
35
  */
35
- export declare function toAtomicAma(ama: number | string): number;
36
+ declare function toAtomicAma(ama: number | string): number;
37
+ //#endregion
38
+ export { fromAtomicAma, toAtomicAma };
36
39
  //# sourceMappingURL=conversion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversion.d.ts","sourceRoot":"","sources":["../src/conversion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAgBhE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAIxD"}
1
+ {"version":3,"file":"conversion.d.ts","names":[],"sources":["../src/conversion.ts"],"mappings":";;AAqBA;;;;;AAiCA;;;;;;;;;;;;AAAA,iBAjCgB,aAAA,CAAc,SAAA;;;;;;;;;;;;;;;;iBAiCd,WAAA,CAAY,GAAA"}
@@ -1,56 +1,51 @@
1
+ import { AMA_TOKEN_DECIMALS_MULTIPLIER } from "./constants.js";
2
+ //#region src/conversion.ts
1
3
  /**
2
- * Token Conversion Utilities
3
- *
4
- * This module provides functions for converting between atomic units
5
- * and human-readable token amounts for the AMA token.
6
- */
7
- import { AMA_TOKEN_DECIMALS, AMA_TOKEN_DECIMALS_MULTIPLIER } from './constants';
4
+ * Token Conversion Utilities
5
+ *
6
+ * This module provides functions for converting between atomic units
7
+ * and human-readable token amounts for the AMA token.
8
+ */
8
9
  /**
9
- * Convert atomic AMA units to human-readable AMA amount
10
- *
11
- * @param atomicAma - Atomic units (as number or string)
12
- * @returns Human-readable AMA amount
13
- * @throws Error if the value is invalid
14
- *
15
- * @example
16
- * ```ts
17
- * const ama = fromAtomicAma(1000000000) // Returns 1.0
18
- * ```
19
- */
20
- export function fromAtomicAma(atomicAma) {
21
- const atomicAmaAmount = typeof atomicAma === 'string' ? parseFloat(atomicAma) : atomicAma;
22
- if (isNaN(atomicAmaAmount) || atomicAmaAmount === 0) {
23
- return 0;
24
- }
25
- if (atomicAmaAmount < 0) {
26
- throw new Error('Negative value not allowed');
27
- }
28
- if (atomicAmaAmount < 1) {
29
- throw new Error('Value is less than 1');
30
- }
31
- if (atomicAmaAmount > Number.MAX_SAFE_INTEGER) {
32
- throw new Error('Value exceeds maximum safe integer');
33
- }
34
- return atomicAmaAmount / AMA_TOKEN_DECIMALS_MULTIPLIER;
10
+ * Convert atomic AMA units to human-readable AMA amount
11
+ *
12
+ * @param atomicAma - Atomic units (as number or string)
13
+ * @returns Human-readable AMA amount
14
+ * @throws Error if the value is invalid
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const ama = fromAtomicAma(1000000000) // Returns 1.0
19
+ * ```
20
+ */
21
+ function fromAtomicAma(atomicAma) {
22
+ const atomicAmaAmount = typeof atomicAma === "string" ? parseFloat(atomicAma) : atomicAma;
23
+ if (isNaN(atomicAmaAmount) || atomicAmaAmount === 0) return 0;
24
+ if (atomicAmaAmount < 0) throw new Error("Negative value not allowed");
25
+ if (atomicAmaAmount < 1) throw new Error("Value is less than 1");
26
+ if (atomicAmaAmount > Number.MAX_SAFE_INTEGER) throw new Error("Value exceeds maximum safe integer");
27
+ return atomicAmaAmount / AMA_TOKEN_DECIMALS_MULTIPLIER;
35
28
  }
36
29
  /**
37
- * Convert human-readable AMA amount to atomic units
38
- *
39
- * Uses string splitting to avoid floating-point precision issues
40
- * while preserving truncation (never rounds up) for safety.
41
- *
42
- * @param ama - Human-readable AMA amount (number or string)
43
- * @returns Atomic units (integer)
44
- *
45
- * @example
46
- * ```ts
47
- * const atomic = toAtomicAma(1.5) // Returns 1500000000
48
- * const atomic = toAtomicAma('1.00000001') // Returns 1000000010
49
- * ```
50
- */
51
- export function toAtomicAma(ama) {
52
- const num = typeof ama === 'string' ? parseFloat(ama) : ama;
53
- const [int, frac = ''] = num.toFixed(AMA_TOKEN_DECIMALS).split('.');
54
- return parseInt(int + frac, 10);
30
+ * Convert human-readable AMA amount to atomic units
31
+ *
32
+ * Uses string splitting to avoid floating-point precision issues
33
+ * while preserving truncation (never rounds up) for safety.
34
+ *
35
+ * @param ama - Human-readable AMA amount (number or string)
36
+ * @returns Atomic units (integer)
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const atomic = toAtomicAma(1.5) // Returns 1500000000
41
+ * const atomic = toAtomicAma('1.00000001') // Returns 1000000010
42
+ * ```
43
+ */
44
+ function toAtomicAma(ama) {
45
+ const [int, frac = ""] = (typeof ama === "string" ? parseFloat(ama) : ama).toFixed(9).split(".");
46
+ return parseInt(int + frac, 10);
55
47
  }
48
+ //#endregion
49
+ export { fromAtomicAma, toAtomicAma };
50
+
56
51
  //# sourceMappingURL=conversion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"conversion.js","sourceRoot":"","sources":["../src/conversion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,SAA0B;IACvD,MAAM,eAAe,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAEzF,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,eAAe,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,CAAC,CAAA;IACT,CAAC;IACD,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;IAC9C,CAAC;IACD,IAAI,eAAe,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACxC,CAAC;IACD,IAAI,eAAe,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,eAAe,GAAG,6BAA6B,CAAA;AACvD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,WAAW,CAAC,GAAoB;IAC/C,MAAM,GAAG,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IAC3D,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnE,OAAO,QAAQ,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,CAAA;AAChC,CAAC"}
1
+ {"version":3,"file":"conversion.js","names":[],"sources":["../src/conversion.ts"],"sourcesContent":["/**\n * Token Conversion Utilities\n *\n * This module provides functions for converting between atomic units\n * and human-readable token amounts for the AMA token.\n */\n\nimport { AMA_TOKEN_DECIMALS, AMA_TOKEN_DECIMALS_MULTIPLIER } from './constants'\n\n/**\n * Convert atomic AMA units to human-readable AMA amount\n *\n * @param atomicAma - Atomic units (as number or string)\n * @returns Human-readable AMA amount\n * @throws Error if the value is invalid\n *\n * @example\n * ```ts\n * const ama = fromAtomicAma(1000000000) // Returns 1.0\n * ```\n */\nexport function fromAtomicAma(atomicAma: number | string): number {\n\tconst atomicAmaAmount = typeof atomicAma === 'string' ? parseFloat(atomicAma) : atomicAma\n\n\tif (isNaN(atomicAmaAmount) || atomicAmaAmount === 0) {\n\t\treturn 0\n\t}\n\tif (atomicAmaAmount < 0) {\n\t\tthrow new Error('Negative value not allowed')\n\t}\n\tif (atomicAmaAmount < 1) {\n\t\tthrow new Error('Value is less than 1')\n\t}\n\tif (atomicAmaAmount > Number.MAX_SAFE_INTEGER) {\n\t\tthrow new Error('Value exceeds maximum safe integer')\n\t}\n\treturn atomicAmaAmount / AMA_TOKEN_DECIMALS_MULTIPLIER\n}\n\n/**\n * Convert human-readable AMA amount to atomic units\n *\n * Uses string splitting to avoid floating-point precision issues\n * while preserving truncation (never rounds up) for safety.\n *\n * @param ama - Human-readable AMA amount (number or string)\n * @returns Atomic units (integer)\n *\n * @example\n * ```ts\n * const atomic = toAtomicAma(1.5) // Returns 1500000000\n * const atomic = toAtomicAma('1.00000001') // Returns 1000000010\n * ```\n */\nexport function toAtomicAma(ama: number | string): number {\n\tconst num = typeof ama === 'string' ? parseFloat(ama) : ama\n\tconst [int, frac = ''] = num.toFixed(AMA_TOKEN_DECIMALS).split('.')\n\treturn parseInt(int + frac, 10)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,cAAc,WAAoC;CACjE,MAAM,kBAAkB,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;CAEhF,IAAI,MAAM,gBAAgB,IAAI,oBAAoB,GACjD,OAAO;CAER,IAAI,kBAAkB,GACrB,MAAM,IAAI,MAAM,6BAA6B;CAE9C,IAAI,kBAAkB,GACrB,MAAM,IAAI,MAAM,uBAAuB;CAExC,IAAI,kBAAkB,OAAO,kBAC5B,MAAM,IAAI,MAAM,qCAAqC;CAEtD,OAAO,kBAAkB;;;;;;;;;;;;;;;;;AAkB1B,SAAgB,YAAY,KAA8B;CAEzD,MAAM,CAAC,KAAK,OAAO,OADP,OAAO,QAAQ,WAAW,WAAW,IAAI,GAAG,KAC3B,QAAA,EAA2B,CAAC,MAAM,IAAI;CACnE,OAAO,SAAS,MAAM,MAAM,GAAG"}