@amadeus-protocol/sdk 1.0.8 → 1.1.1
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.
- package/README.md +215 -30
- package/dist/api/chain.d.ts +144 -117
- package/dist/api/chain.d.ts.map +1 -1
- package/dist/api/chain.js +175 -146
- package/dist/api/chain.js.map +1 -1
- package/dist/api/contract.d.ts +78 -60
- package/dist/api/contract.d.ts.map +1 -1
- package/dist/api/contract.js +102 -75
- package/dist/api/contract.js.map +1 -1
- package/dist/api/epoch.d.ts +65 -66
- package/dist/api/epoch.d.ts.map +1 -1
- package/dist/api/epoch.js +90 -98
- package/dist/api/epoch.js.map +1 -1
- package/dist/api/peer.d.ts +77 -78
- package/dist/api/peer.d.ts.map +1 -1
- package/dist/api/peer.js +93 -94
- package/dist/api/peer.js.map +1 -1
- package/dist/api/proof.d.ts +44 -23
- package/dist/api/proof.d.ts.map +1 -1
- package/dist/api/proof.js +56 -29
- package/dist/api/proof.js.map +1 -1
- package/dist/api/transaction.d.ts +68 -69
- package/dist/api/transaction.d.ts.map +1 -1
- package/dist/api/transaction.js +84 -84
- package/dist/api/transaction.js.map +1 -1
- package/dist/api/wallet.d.ts +36 -37
- package/dist/api/wallet.d.ts.map +1 -1
- package/dist/api/wallet.js +47 -50
- package/dist/api/wallet.js.map +1 -1
- package/dist/client.d.ts +66 -68
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +231 -276
- package/dist/client.js.map +1 -1
- package/dist/constants.d.ts +13 -10
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +49 -45
- package/dist/constants.js.map +1 -1
- package/dist/contract-state.d.ts +6 -3
- package/dist/contract-state.d.ts.map +1 -1
- package/dist/contract-state.js +88 -106
- package/dist/contract-state.js.map +1 -1
- package/dist/contracts/abi-types.d.ts +32 -32
- package/dist/contracts/abi-types.d.ts.map +1 -1
- package/dist/contracts/coin.d.ts +13 -20
- package/dist/contracts/coin.d.ts.map +1 -1
- package/dist/contracts/coin.js +42 -38
- package/dist/contracts/coin.js.map +1 -1
- package/dist/contracts/contract-call.d.ts +14 -16
- package/dist/contracts/contract-call.d.ts.map +1 -1
- package/dist/contracts/contract-call.js +45 -54
- package/dist/contracts/contract-call.js.map +1 -1
- package/dist/contracts/contract.d.ts +24 -55
- package/dist/contracts/contract.d.ts.map +1 -1
- package/dist/contracts/contract.js +63 -101
- package/dist/contracts/contract.js.map +1 -1
- package/dist/contracts/lockup/abi.d.ts +54 -51
- package/dist/contracts/lockup/abi.d.ts.map +1 -1
- package/dist/contracts/lockup/abi.js +65 -74
- package/dist/contracts/lockup/abi.js.map +1 -1
- package/dist/contracts/lockup/helpers.d.ts +22 -18
- package/dist/contracts/lockup/helpers.d.ts.map +1 -1
- package/dist/contracts/lockup/helpers.js +44 -47
- package/dist/contracts/lockup/helpers.js.map +1 -1
- package/dist/contracts/lockup/parsers.d.ts +7 -3
- package/dist/contracts/lockup/parsers.d.ts.map +1 -1
- package/dist/contracts/lockup/parsers.js +51 -55
- package/dist/contracts/lockup/parsers.js.map +1 -1
- package/dist/contracts/lockup/storage-keys.d.ts +5 -2
- package/dist/contracts/lockup/storage-keys.d.ts.map +1 -1
- package/dist/contracts/lockup/storage-keys.js +54 -70
- package/dist/contracts/lockup/storage-keys.js.map +1 -1
- package/dist/contracts/lockup/types.d.ts +73 -70
- package/dist/contracts/lockup/types.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/abi.d.ts +328 -325
- package/dist/contracts/lockup-prime/abi.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/abi.js +397 -417
- package/dist/contracts/lockup-prime/abi.js.map +1 -1
- package/dist/contracts/lockup-prime/helpers.d.ts +35 -31
- package/dist/contracts/lockup-prime/helpers.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/helpers.js +131 -137
- package/dist/contracts/lockup-prime/helpers.js.map +1 -1
- package/dist/contracts/lockup-prime/parsers.d.ts +9 -5
- package/dist/contracts/lockup-prime/parsers.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/parsers.js +61 -61
- package/dist/contracts/lockup-prime/parsers.js.map +1 -1
- package/dist/contracts/lockup-prime/storage-keys.d.ts +7 -4
- package/dist/contracts/lockup-prime/storage-keys.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/storage-keys.js +64 -80
- package/dist/contracts/lockup-prime/storage-keys.js.map +1 -1
- package/dist/contracts/lockup-prime/types.d.ts +92 -89
- package/dist/contracts/lockup-prime/types.d.ts.map +1 -1
- package/dist/contracts/lockup-prime/types.js +12 -13
- package/dist/contracts/lockup-prime/types.js.map +1 -1
- package/dist/contracts/nft/abi.d.ts +104 -0
- package/dist/contracts/nft/abi.d.ts.map +1 -0
- package/dist/contracts/nft/abi.js +135 -0
- package/dist/contracts/nft/abi.js.map +1 -0
- package/dist/contracts/nft/helpers.d.ts +21 -0
- package/dist/contracts/nft/helpers.d.ts.map +1 -0
- package/dist/contracts/nft/helpers.js +61 -0
- package/dist/contracts/nft/helpers.js.map +1 -0
- package/dist/contracts/nft/types.d.ts +47 -0
- package/dist/contracts/nft/types.d.ts.map +1 -0
- package/dist/conversion.d.ts +5 -2
- package/dist/conversion.d.ts.map +1 -1
- package/dist/conversion.js +45 -50
- package/dist/conversion.js.map +1 -1
- package/dist/crypto.d.ts +14 -16
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +121 -140
- package/dist/crypto.js.map +1 -1
- package/dist/encoding.d.ts +11 -8
- package/dist/encoding.d.ts.map +1 -1
- package/dist/encoding.js +123 -144
- package/dist/encoding.js.map +1 -1
- package/dist/encryption.d.ts +15 -12
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +119 -117
- package/dist/encryption.js.map +1 -1
- package/dist/explorer.d.ts +10 -7
- package/dist/explorer.d.ts.map +1 -1
- package/dist/explorer.js +51 -48
- package/dist/explorer.js.map +1 -1
- package/dist/formatters.d.ts +8 -5
- package/dist/formatters.d.ts.map +1 -1
- package/dist/formatters.js +67 -68
- package/dist/formatters.js.map +1 -1
- package/dist/index.d.ts +42 -55
- package/dist/index.js +39 -55
- package/dist/mnemonic.d.ts +12 -9
- package/dist/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic.js +105 -114
- package/dist/mnemonic.js.map +1 -1
- package/dist/networks.d.ts +14 -17
- package/dist/networks.d.ts.map +1 -1
- package/dist/networks.js +40 -36
- package/dist/networks.js.map +1 -1
- package/dist/schemas.js +75 -79
- package/dist/schemas.js.map +1 -1
- package/dist/sdk.d.ts +69 -65
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +126 -117
- package/dist/sdk.js.map +1 -1
- package/dist/serialization.d.ts +8 -18
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +207 -260
- package/dist/serialization.js.map +1 -1
- package/dist/signing.js +67 -67
- package/dist/signing.js.map +1 -1
- package/dist/transaction-builder.d.ts +175 -184
- package/dist/transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder.js +295 -344
- package/dist/transaction-builder.js.map +1 -1
- package/dist/transaction-errors.d.ts +10 -12
- package/dist/transaction-errors.d.ts.map +1 -1
- package/dist/transaction-errors.js +145 -166
- package/dist/transaction-errors.js.map +1 -1
- package/dist/types.d.ts +530 -450
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +169 -183
- package/dist/types.js.map +1 -1
- package/dist/validation.d.ts +24 -26
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +194 -192
- package/dist/validation.js.map +1 -1
- package/package.json +4 -3
- package/dist/api/index.d.ts +0 -8
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -8
- package/dist/api/index.js.map +0 -1
- package/dist/contracts/abi-types.js +0 -8
- package/dist/contracts/abi-types.js.map +0 -1
- package/dist/contracts/index.d.ts +0 -7
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -7
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/lockup/calls.d.ts +0 -23
- package/dist/contracts/lockup/calls.d.ts.map +0 -1
- package/dist/contracts/lockup/calls.js +0 -25
- package/dist/contracts/lockup/calls.js.map +0 -1
- package/dist/contracts/lockup/index.d.ts +0 -6
- package/dist/contracts/lockup/index.d.ts.map +0 -1
- package/dist/contracts/lockup/index.js +0 -6
- package/dist/contracts/lockup/index.js.map +0 -1
- package/dist/contracts/lockup/types.js +0 -7
- package/dist/contracts/lockup/types.js.map +0 -1
- package/dist/contracts/lockup-prime/calls.d.ts +0 -53
- package/dist/contracts/lockup-prime/calls.d.ts.map +0 -1
- package/dist/contracts/lockup-prime/calls.js +0 -60
- package/dist/contracts/lockup-prime/calls.js.map +0 -1
- package/dist/contracts/lockup-prime/index.d.ts +0 -6
- package/dist/contracts/lockup-prime/index.d.ts.map +0 -1
- package/dist/contracts/lockup-prime/index.js +0 -6
- package/dist/contracts/lockup-prime/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/schemas.d.ts +0 -67
- package/dist/schemas.d.ts.map +0 -1
- package/dist/signing.d.ts +0 -39
- 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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
16
|
-
|
|
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","
|
|
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"}
|
package/dist/conversion.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
36
|
+
declare function toAtomicAma(ama: number | string): number;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { fromAtomicAma, toAtomicAma };
|
|
36
39
|
//# sourceMappingURL=conversion.d.ts.map
|
package/dist/conversion.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.d.ts","
|
|
1
|
+
{"version":3,"file":"conversion.d.ts","names":[],"sources":["../src/conversion.ts"],"mappings":";;AAqBA;;;;;AAiCA;;;;;;;;;;;;AAAA,iBAjCgB,aAAA,CAAc,SAAA;;;;;;;;;;;;;;;;iBAiCd,WAAA,CAAY,GAAA"}
|
package/dist/conversion.js
CHANGED
|
@@ -1,56 +1,51 @@
|
|
|
1
|
+
import { AMA_TOKEN_DECIMALS_MULTIPLIER } from "./constants.js";
|
|
2
|
+
//#region src/conversion.ts
|
|
1
3
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
package/dist/conversion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversion.js","
|
|
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"}
|