@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.
- 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
package/dist/signing.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
import { bls12_381 as bls } from '@noble/curves/bls12-381';
|
|
9
|
-
import { sha256 } from '@noble/hashes/sha2';
|
|
10
|
-
import { deriveSkAndSeed64FromBase58Seed, getPublicKey } from './crypto';
|
|
11
|
-
import { toBase58 } from './encoding';
|
|
12
|
-
import { encode } from './serialization';
|
|
1
|
+
import { encode } from "./serialization.js";
|
|
2
|
+
import { toBase58 } from "./encoding.js";
|
|
3
|
+
import { deriveSkAndSeed64FromBase58Seed, getPublicKey } from "./crypto.js";
|
|
4
|
+
import { bls12_381 } from "@noble/curves/bls12-381";
|
|
5
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
6
|
+
//#region src/signing.ts
|
|
13
7
|
/** Domain Separation Tag for transaction signatures */
|
|
14
|
-
const TX_DST =
|
|
8
|
+
const TX_DST = "AMADEUS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_TX_";
|
|
15
9
|
/** Generate a transaction nonce based on current timestamp */
|
|
16
10
|
function generateNonce() {
|
|
17
|
-
|
|
11
|
+
return BigInt(Date.now()) * 1000000n;
|
|
18
12
|
}
|
|
19
13
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
* Normalize a signer secret key to PrivKey format.
|
|
15
|
+
* Accepts Base58 strings, raw Uint8Array, or already-derived PrivKey.
|
|
16
|
+
*/
|
|
17
|
+
function normalizeSignerSk(signerSk) {
|
|
18
|
+
if (typeof signerSk === "string") {
|
|
19
|
+
const { sk } = deriveSkAndSeed64FromBase58Seed(signerSk);
|
|
20
|
+
return sk;
|
|
21
|
+
}
|
|
22
|
+
return signerSk;
|
|
29
23
|
}
|
|
30
24
|
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
* Build an unsigned transaction from raw contract/method/args.
|
|
26
|
+
*/
|
|
27
|
+
function buildUnsigned(signerPk, contract, method, args) {
|
|
28
|
+
const action = {
|
|
29
|
+
op: "call",
|
|
30
|
+
contract,
|
|
31
|
+
function: method,
|
|
32
|
+
args
|
|
33
|
+
};
|
|
34
|
+
const tx = {
|
|
35
|
+
signer: signerPk,
|
|
36
|
+
nonce: generateNonce(),
|
|
37
|
+
action
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
tx,
|
|
41
|
+
hash: sha256(encode(tx))
|
|
42
|
+
};
|
|
48
43
|
}
|
|
49
44
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
* Sign an already-built unsigned transaction.
|
|
46
|
+
*/
|
|
47
|
+
function signUnsigned(unsignedTx, signerSk) {
|
|
48
|
+
const sk = normalizeSignerSk(signerSk);
|
|
49
|
+
const signature = bls12_381.sign(unsignedTx.hash, sk, { DST: TX_DST });
|
|
50
|
+
return {
|
|
51
|
+
txHash: toBase58(unsignedTx.hash),
|
|
52
|
+
txPacked: encode({
|
|
53
|
+
tx: unsignedTx.tx,
|
|
54
|
+
hash: unsignedTx.hash,
|
|
55
|
+
signature
|
|
56
|
+
})
|
|
57
|
+
};
|
|
59
58
|
}
|
|
60
59
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return signUnsigned(unsignedTx, signerSk);
|
|
60
|
+
* Build and sign a transaction from raw contract/method/args.
|
|
61
|
+
*/
|
|
62
|
+
function buildAndSignRaw(signerPk, signerSk, contract, method, args) {
|
|
63
|
+
return signUnsigned(buildUnsigned(signerPk, contract, method, args), signerSk);
|
|
66
64
|
}
|
|
67
65
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
* Build an unsigned transaction from a ContractCall.
|
|
67
|
+
*/
|
|
68
|
+
function buildUnsignedFromCall(signerPk, call) {
|
|
69
|
+
return buildUnsigned(signerPk, call.contract, call.method, call.args);
|
|
72
70
|
}
|
|
73
71
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return buildAndSignRaw(signerPubKey, sk, call.contract, call.method, call.args);
|
|
72
|
+
* Highest-level: derive keys from a Base58 private key and sign a ContractCall.
|
|
73
|
+
*
|
|
74
|
+
* This is the core function behind `TransactionBuilder.signCall()` and
|
|
75
|
+
* `createContract(ABI).connect(key).method()`.
|
|
76
|
+
*/
|
|
77
|
+
function signContractCall(senderPrivkey, call) {
|
|
78
|
+
const { seed64, sk } = deriveSkAndSeed64FromBase58Seed(senderPrivkey);
|
|
79
|
+
return buildAndSignRaw(getPublicKey(seed64), sk, call.contract, call.method, call.args);
|
|
83
80
|
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { buildAndSignRaw, buildUnsigned, buildUnsignedFromCall, normalizeSignerSk, signContractCall, signUnsigned };
|
|
83
|
+
|
|
84
84
|
//# sourceMappingURL=signing.js.map
|
package/dist/signing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signing.js","
|
|
1
|
+
{"version":3,"file":"signing.js","names":["bls"],"sources":["../src/signing.ts"],"sourcesContent":["/**\n * Transaction Signing Primitives\n *\n * Stateless, standalone functions for building and signing Amadeus transactions.\n * This module is the source of truth for the signing pipeline — both\n * TransactionBuilder and createContract().connect() delegate to these functions.\n */\n\nimport type { PrivKey } from '@noble/curves/abstract/utils'\nimport { bls12_381 as bls } from '@noble/curves/bls12-381'\nimport { sha256 } from '@noble/hashes/sha2'\n\nimport { deriveSkAndSeed64FromBase58Seed, getPublicKey } from './crypto'\nimport { toBase58 } from './encoding'\nimport { encode } from './serialization'\nimport type {\n\tBuildTransactionResult,\n\tSerializableValue,\n\tTransactionAction,\n\tUnsignedTransaction,\n\tUnsignedTransactionWithHash\n} from './types'\nimport type { ContractCall } from './contracts/contract-call'\n\n/** Domain Separation Tag for transaction signatures */\nconst TX_DST = 'AMADEUS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_TX_'\n\n/** Generate a transaction nonce based on current timestamp */\nfunction generateNonce(): bigint {\n\treturn BigInt(Date.now()) * 1_000_000n\n}\n\n/**\n * Normalize a signer secret key to PrivKey format.\n * Accepts Base58 strings, raw Uint8Array, or already-derived PrivKey.\n */\nexport function normalizeSignerSk(signerSk: PrivKey | string | Uint8Array): PrivKey {\n\tif (typeof signerSk === 'string') {\n\t\tconst { sk } = deriveSkAndSeed64FromBase58Seed(signerSk)\n\t\treturn sk\n\t}\n\treturn signerSk\n}\n\n/**\n * Build an unsigned transaction from raw contract/method/args.\n */\nexport function buildUnsigned(\n\tsignerPk: Uint8Array,\n\tcontract: string,\n\tmethod: string,\n\targs: SerializableValue[]\n): UnsignedTransactionWithHash {\n\tconst action: TransactionAction = {\n\t\top: 'call',\n\t\tcontract,\n\t\tfunction: method,\n\t\targs\n\t}\n\tconst tx: UnsignedTransaction = {\n\t\tsigner: signerPk,\n\t\tnonce: generateNonce(),\n\t\taction\n\t}\n\tconst txEncoded = encode(tx)\n\tconst hash = sha256(txEncoded)\n\treturn { tx, hash }\n}\n\n/**\n * Sign an already-built unsigned transaction.\n */\nexport function signUnsigned(\n\tunsignedTx: UnsignedTransactionWithHash,\n\tsignerSk: PrivKey | string | Uint8Array\n): BuildTransactionResult {\n\tconst sk = normalizeSignerSk(signerSk)\n\tconst signature = bls.sign(unsignedTx.hash, sk, { DST: TX_DST })\n\treturn {\n\t\ttxHash: toBase58(unsignedTx.hash),\n\t\ttxPacked: encode({ tx: unsignedTx.tx, hash: unsignedTx.hash, signature })\n\t}\n}\n\n/**\n * Build and sign a transaction from raw contract/method/args.\n */\nexport function buildAndSignRaw(\n\tsignerPk: Uint8Array,\n\tsignerSk: PrivKey | string | Uint8Array,\n\tcontract: string,\n\tmethod: string,\n\targs: SerializableValue[]\n): BuildTransactionResult {\n\tconst unsignedTx = buildUnsigned(signerPk, contract, method, args)\n\treturn signUnsigned(unsignedTx, signerSk)\n}\n\n/**\n * Build an unsigned transaction from a ContractCall.\n */\nexport function buildUnsignedFromCall(\n\tsignerPk: Uint8Array,\n\tcall: ContractCall\n): UnsignedTransactionWithHash {\n\treturn buildUnsigned(signerPk, call.contract, call.method, call.args)\n}\n\n/**\n * Highest-level: derive keys from a Base58 private key and sign a ContractCall.\n *\n * This is the core function behind `TransactionBuilder.signCall()` and\n * `createContract(ABI).connect(key).method()`.\n */\nexport function signContractCall(\n\tsenderPrivkey: string,\n\tcall: ContractCall\n): BuildTransactionResult {\n\tconst { seed64, sk } = deriveSkAndSeed64FromBase58Seed(senderPrivkey)\n\tconst signerPubKey = getPublicKey(seed64)\n\treturn buildAndSignRaw(signerPubKey, sk, call.contract, call.method, call.args)\n}\n"],"mappings":";;;;;;;AAyBA,MAAM,SAAS;;AAGf,SAAS,gBAAwB;CAChC,OAAO,OAAO,KAAK,KAAK,CAAC,GAAG;;;;;;AAO7B,SAAgB,kBAAkB,UAAkD;CACnF,IAAI,OAAO,aAAa,UAAU;EACjC,MAAM,EAAE,OAAO,gCAAgC,SAAS;EACxD,OAAO;;CAER,OAAO;;;;;AAMR,SAAgB,cACf,UACA,UACA,QACA,MAC8B;CAC9B,MAAM,SAA4B;EACjC,IAAI;EACJ;EACA,UAAU;EACV;EACA;CACD,MAAM,KAA0B;EAC/B,QAAQ;EACR,OAAO,eAAe;EACtB;EACA;CAGD,OAAO;EAAE;EAAI,MADA,OADK,OAAO,GACI,CACZ;EAAE;;;;;AAMpB,SAAgB,aACf,YACA,UACyB;CACzB,MAAM,KAAK,kBAAkB,SAAS;CACtC,MAAM,YAAYA,UAAI,KAAK,WAAW,MAAM,IAAI,EAAE,KAAK,QAAQ,CAAC;CAChE,OAAO;EACN,QAAQ,SAAS,WAAW,KAAK;EACjC,UAAU,OAAO;GAAE,IAAI,WAAW;GAAI,MAAM,WAAW;GAAM;GAAW,CAAC;EACzE;;;;;AAMF,SAAgB,gBACf,UACA,UACA,UACA,QACA,MACyB;CAEzB,OAAO,aADY,cAAc,UAAU,UAAU,QAAQ,KAC/B,EAAE,SAAS;;;;;AAM1C,SAAgB,sBACf,UACA,MAC8B;CAC9B,OAAO,cAAc,UAAU,KAAK,UAAU,KAAK,QAAQ,KAAK,KAAK;;;;;;;;AAStE,SAAgB,iBACf,eACA,MACyB;CACzB,MAAM,EAAE,QAAQ,OAAO,gCAAgC,cAAc;CAErE,OAAO,gBADc,aAAa,OACC,EAAE,IAAI,KAAK,UAAU,KAAK,QAAQ,KAAK,KAAK"}
|
|
@@ -1,34 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { TransactionBuilder, LOCKUP_PRIME_ABI, toAtomicAma } from '@amadeus-protocol/sdk'
|
|
12
|
-
*
|
|
13
|
-
* // Via builder.contract(abi) — typed methods, auto-signed:
|
|
14
|
-
* const builder = new TransactionBuilder('5Kd3N...')
|
|
15
|
-
* const result = builder.contract(LOCKUP_PRIME_ABI).lock({
|
|
16
|
-
* amount: toAtomicAma(100).toString(),
|
|
17
|
-
* tier: '30d'
|
|
18
|
-
* })
|
|
19
|
-
*
|
|
20
|
-
* // Or standalone:
|
|
21
|
-
* import { createContract } from '@amadeus-protocol/sdk'
|
|
22
|
-
* const lockupPrime = createContract(LOCKUP_PRIME_ABI)
|
|
23
|
-
* const call = lockupPrime.lock({ amount: toAtomicAma(100).toString(), tier: '30d' })
|
|
24
|
-
* const result = TransactionBuilder.signCall('5Kd3N...', call)
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
import type { PrivKey } from '@noble/curves/abstract/utils';
|
|
28
|
-
import type { BuildTransactionResult, LockupPrimeDailyCheckinInput, LockupPrimeLockInput, LockupPrimeUnlockInput, LockupUnlockInput, SerializableValue, TransferTransactionInput, UnsignedTransactionWithHash } from './types';
|
|
29
|
-
import type { AbiDefinition } from './contracts/abi-types';
|
|
30
|
-
import type { ContractCall } from './contracts/contract-call';
|
|
31
|
-
import { type SignedContract } from './contracts/contract';
|
|
1
|
+
import { BuildTransactionResult, LockupPrimeDailyCheckinInput, LockupPrimeLockInput, LockupPrimeUnlockInput, LockupUnlockInput, SerializableValue, TransferTransactionInput, UnsignedTransactionWithHash } from "./types.js";
|
|
2
|
+
import { AbiDefinition } from "./contracts/abi-types.js";
|
|
3
|
+
import { ContractCall } from "./contracts/contract-call.js";
|
|
4
|
+
import { SignedContract } from "./contracts/contract.js";
|
|
5
|
+
import { NftCreateCollectionInput, NftCreateCollectionParams, NftMintInput, NftMintParams, NftTransferInput, NftTransferParams } from "./contracts/nft/types.js";
|
|
6
|
+
import { PrivKey } from "@noble/curves/abstract/utils";
|
|
7
|
+
|
|
8
|
+
//#region src/transaction-builder.d.ts
|
|
32
9
|
/**
|
|
33
10
|
* Transaction Builder for Amadeus Protocol
|
|
34
11
|
*
|
|
@@ -51,158 +28,172 @@ import { type SignedContract } from './contracts/contract';
|
|
|
51
28
|
* ])
|
|
52
29
|
* ```
|
|
53
30
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
31
|
+
declare class TransactionBuilder {
|
|
32
|
+
private readonly privateKey;
|
|
33
|
+
private signerPk;
|
|
34
|
+
private signerSk;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new TransactionBuilder instance
|
|
37
|
+
*
|
|
38
|
+
* @param privateKey - Optional Base58 encoded private key (seed). If provided,
|
|
39
|
+
* the builder will use this key for all transactions.
|
|
40
|
+
*/
|
|
41
|
+
constructor(privateKey?: string);
|
|
42
|
+
/**
|
|
43
|
+
* Initialize signer keys from the private key
|
|
44
|
+
*/
|
|
45
|
+
private initializeKeys;
|
|
46
|
+
/**
|
|
47
|
+
* Get the signer's secret key (normalizes to PrivKey format)
|
|
48
|
+
*/
|
|
49
|
+
private getSignerSk;
|
|
50
|
+
private requirePk;
|
|
51
|
+
/**
|
|
52
|
+
* Get a typed, signer-bound contract interface from an ABI definition.
|
|
53
|
+
*
|
|
54
|
+
* Each ABI function becomes a method that builds and signs in one step,
|
|
55
|
+
* returning `BuildTransactionResult` directly.
|
|
56
|
+
*
|
|
57
|
+
* @param abi - An ABI definition object (declared `as const`)
|
|
58
|
+
* @returns A `SignedContract<TAbi>` with typed methods for each ABI function
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const builder = new TransactionBuilder('5Kd3N...')
|
|
63
|
+
*
|
|
64
|
+
* // LockupPrime — all methods auto-detected from ABI:
|
|
65
|
+
* const result = builder.contract(LOCKUP_PRIME_ABI).lock({
|
|
66
|
+
* amount: toAtomicAma(100).toString(),
|
|
67
|
+
* tier: '30d'
|
|
68
|
+
* })
|
|
69
|
+
*
|
|
70
|
+
* builder.contract(LOCKUP_PRIME_ABI).unlock({ vaultIndex: '3' })
|
|
71
|
+
* builder.contract(LOCKUP_PRIME_ABI).daily_checkin({ vaultIndex: '7' })
|
|
72
|
+
*
|
|
73
|
+
* // Lockup:
|
|
74
|
+
* builder.contract(LOCKUP_ABI).unlock({ vaultIndex: '5' })
|
|
75
|
+
*
|
|
76
|
+
* // Any future contract — just pass its ABI:
|
|
77
|
+
* builder.contract(SOME_NEW_ABI).someFunction({ param: 'value' })
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
contract<TAbi extends AbiDefinition>(abi: TAbi): SignedContract<TAbi>;
|
|
81
|
+
/**
|
|
82
|
+
* Derive keys from a Base58 private key and sign a ContractCall.
|
|
83
|
+
*
|
|
84
|
+
* @param senderPrivkey - Base58 encoded private key (seed)
|
|
85
|
+
* @param call - A ContractCall from createContract(), buildContractCall(), or buildCoinTransfer()
|
|
86
|
+
* @returns Transaction hash and packed transaction
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const lockupPrime = createContract(LOCKUP_PRIME_ABI)
|
|
91
|
+
* const call = lockupPrime.lock({ amount: '100000000000', tier: '30d' })
|
|
92
|
+
* const { txHash, txPacked } = TransactionBuilder.signCall('5Kd3N...', call)
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
static signCall(senderPrivkey: string, call: ContractCall): BuildTransactionResult;
|
|
96
|
+
/**
|
|
97
|
+
* Build an unsigned transaction from a ContractCall (static)
|
|
98
|
+
*/
|
|
99
|
+
static buildFromCall(call: ContractCall, signerPk: Uint8Array): UnsignedTransactionWithHash;
|
|
100
|
+
/**
|
|
101
|
+
* Build and sign a transaction from a ContractCall (static)
|
|
102
|
+
*/
|
|
103
|
+
static buildAndSignCall(signerPk: Uint8Array, signerSk: PrivKey | string | Uint8Array, call: ContractCall): BuildTransactionResult;
|
|
104
|
+
/**
|
|
105
|
+
* Build an unsigned transaction from a ContractCall (instance)
|
|
106
|
+
*/
|
|
107
|
+
buildFromCall(call: ContractCall): UnsignedTransactionWithHash;
|
|
108
|
+
/**
|
|
109
|
+
* Build and sign a transaction from a ContractCall (instance)
|
|
110
|
+
*/
|
|
111
|
+
buildAndSignCall(call: ContractCall): BuildTransactionResult;
|
|
112
|
+
/**
|
|
113
|
+
* Build an unsigned transaction (instance)
|
|
114
|
+
*/
|
|
115
|
+
build(contract: string, method: string, args: SerializableValue[], signerPk?: Uint8Array): UnsignedTransactionWithHash;
|
|
116
|
+
/**
|
|
117
|
+
* Sign an unsigned transaction (instance)
|
|
118
|
+
*/
|
|
119
|
+
sign(unsignedTx: UnsignedTransactionWithHash, signerSk?: PrivKey | string | Uint8Array): BuildTransactionResult;
|
|
120
|
+
/**
|
|
121
|
+
* Build and sign a generic transaction (instance)
|
|
122
|
+
*/
|
|
123
|
+
buildAndSign(contract: string, method: string, args: SerializableValue[], signerPk?: Uint8Array, signerSk?: PrivKey | string | Uint8Array): BuildTransactionResult;
|
|
124
|
+
/**
|
|
125
|
+
* Build an unsigned transaction (static)
|
|
126
|
+
*/
|
|
127
|
+
static build(signerPk: Uint8Array, contract: string, method: string, args: SerializableValue[]): UnsignedTransactionWithHash;
|
|
128
|
+
/**
|
|
129
|
+
* Sign an unsigned transaction (static)
|
|
130
|
+
*/
|
|
131
|
+
static sign(unsignedTx: UnsignedTransactionWithHash, signerSk: PrivKey | string | Uint8Array): BuildTransactionResult;
|
|
132
|
+
/**
|
|
133
|
+
* Build and sign a generic transaction (static)
|
|
134
|
+
*/
|
|
135
|
+
static buildAndSign(signerPk: Uint8Array, signerSk: PrivKey | string | Uint8Array, contract: string, method: string, args: SerializableValue[]): BuildTransactionResult;
|
|
136
|
+
/**
|
|
137
|
+
* Build an unsigned Coin transfer transaction
|
|
138
|
+
*/
|
|
139
|
+
buildTransfer(input: Omit<TransferTransactionInput, 'senderPrivkey'>): UnsignedTransactionWithHash;
|
|
140
|
+
/**
|
|
141
|
+
* Build and sign a Coin transfer transaction
|
|
142
|
+
*/
|
|
143
|
+
transfer(input: Omit<TransferTransactionInput, 'senderPrivkey'>): BuildTransactionResult;
|
|
144
|
+
/**
|
|
145
|
+
* Build an unsigned Coin transfer transaction (static)
|
|
146
|
+
*/
|
|
147
|
+
static buildTransfer(input: Omit<TransferTransactionInput, 'senderPrivkey'>, signerPk: Uint8Array): UnsignedTransactionWithHash;
|
|
148
|
+
/**
|
|
149
|
+
* Build and sign a Coin transfer transaction (static)
|
|
150
|
+
*/
|
|
151
|
+
static buildSignedTransfer(input: TransferTransactionInput): BuildTransactionResult;
|
|
152
|
+
/**
|
|
153
|
+
* Build and sign a LockupPrime lock transaction
|
|
154
|
+
*/
|
|
155
|
+
lockupPrimeLock(input: Omit<LockupPrimeLockInput, 'senderPrivkey'>): BuildTransactionResult;
|
|
156
|
+
/**
|
|
157
|
+
* Build and sign a LockupPrime unlock transaction
|
|
158
|
+
*/
|
|
159
|
+
lockupPrimeUnlock(input: Omit<LockupPrimeUnlockInput, 'senderPrivkey'>): BuildTransactionResult;
|
|
160
|
+
/**
|
|
161
|
+
* Build and sign a LockupPrime daily check-in transaction
|
|
162
|
+
*/
|
|
163
|
+
lockupPrimeDailyCheckin(input: Omit<LockupPrimeDailyCheckinInput, 'senderPrivkey'>): BuildTransactionResult;
|
|
164
|
+
/**
|
|
165
|
+
* Build and sign a Lockup unlock transaction
|
|
166
|
+
*/
|
|
167
|
+
lockupUnlock(input: Omit<LockupUnlockInput, 'senderPrivkey'>): BuildTransactionResult;
|
|
168
|
+
/**
|
|
169
|
+
* Build and sign a LockupPrime lock transaction (static)
|
|
170
|
+
*/
|
|
171
|
+
static buildSignedLockupPrimeLock(input: LockupPrimeLockInput): BuildTransactionResult;
|
|
172
|
+
/**
|
|
173
|
+
* Build and sign a LockupPrime unlock transaction (static)
|
|
174
|
+
*/
|
|
175
|
+
static buildSignedLockupPrimeUnlock(input: LockupPrimeUnlockInput): BuildTransactionResult;
|
|
176
|
+
/**
|
|
177
|
+
* Build and sign a LockupPrime daily check-in transaction (static)
|
|
178
|
+
*/
|
|
179
|
+
static buildSignedLockupPrimeDailyCheckin(input: LockupPrimeDailyCheckinInput): BuildTransactionResult;
|
|
180
|
+
/**
|
|
181
|
+
* Build and sign a Lockup unlock transaction (static)
|
|
182
|
+
*/
|
|
183
|
+
static buildSignedLockupUnlock(input: LockupUnlockInput): BuildTransactionResult;
|
|
184
|
+
/** Build and sign an `Nft.transfer` transaction */
|
|
185
|
+
nftTransfer(input: NftTransferParams): BuildTransactionResult;
|
|
186
|
+
/** Build and sign an `Nft.mint` transaction (collection owner only) */
|
|
187
|
+
nftMint(input: NftMintParams): BuildTransactionResult;
|
|
188
|
+
/** Build and sign an `Nft.create_collection` transaction */
|
|
189
|
+
nftCreateCollection(input: NftCreateCollectionParams): BuildTransactionResult;
|
|
190
|
+
/** Build and sign an `Nft.transfer` transaction (static) */
|
|
191
|
+
static buildSignedNftTransfer(input: NftTransferInput): BuildTransactionResult;
|
|
192
|
+
/** Build and sign an `Nft.mint` transaction (static) */
|
|
193
|
+
static buildSignedNftMint(input: NftMintInput): BuildTransactionResult;
|
|
194
|
+
/** Build and sign an `Nft.create_collection` transaction (static) */
|
|
195
|
+
static buildSignedNftCreateCollection(input: NftCreateCollectionInput): BuildTransactionResult;
|
|
207
196
|
}
|
|
197
|
+
//#endregion
|
|
198
|
+
export { TransactionBuilder };
|
|
208
199
|
//# sourceMappingURL=transaction-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-builder.d.ts","
|
|
1
|
+
{"version":3,"file":"transaction-builder.d.ts","names":[],"sources":["../src/transaction-builder.ts"],"mappings":"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"}
|