@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
package/dist/contracts/coin.d.ts
CHANGED
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* The Coin contract is a built-in native contract with no WASM ABI file.
|
|
5
|
-
* It differs from WASM contracts:
|
|
6
|
-
* - First arg (recipient) is raw binary Uint8Array from fromBase58(), not a UTF-8 string
|
|
7
|
-
* - Amount requires toAtomicAma() conversion
|
|
8
|
-
*
|
|
9
|
-
* This module provides a dedicated builder that handles these special encodings
|
|
10
|
-
* while returning a standard ContractCall for uniform consumption by TransactionBuilder.
|
|
11
|
-
*/
|
|
12
|
-
import type { ContractCall } from './contract-call';
|
|
1
|
+
import { ContractCall } from "./contract-call.js";
|
|
2
|
+
|
|
3
|
+
//#region src/contracts/coin.d.ts
|
|
13
4
|
/**
|
|
14
5
|
* Parameters for building a Coin transfer call
|
|
15
6
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
interface CoinTransferParams {
|
|
8
|
+
/** Base58-encoded recipient address */
|
|
9
|
+
recipient: string;
|
|
10
|
+
/** Amount in human-readable units (e.g. 10.5 AMA) */
|
|
11
|
+
amount: number | string;
|
|
12
|
+
/** Token symbol (e.g. 'AMA') */
|
|
13
|
+
symbol: string;
|
|
23
14
|
}
|
|
24
15
|
/**
|
|
25
16
|
* Build a Coin transfer ContractCall.
|
|
@@ -38,5 +29,7 @@ export interface CoinTransferParams {
|
|
|
38
29
|
* TransactionBuilder.signCall(privateKey, call)
|
|
39
30
|
* ```
|
|
40
31
|
*/
|
|
41
|
-
|
|
32
|
+
declare function buildCoinTransfer(params: CoinTransferParams): ContractCall;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { CoinTransferParams, buildCoinTransfer };
|
|
42
35
|
//# sourceMappingURL=coin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coin.d.ts","
|
|
1
|
+
{"version":3,"file":"coin.d.ts","names":[],"sources":["../../src/contracts/coin.ts"],"mappings":";;;AA6CA;;;AAAA,UA1BiB,kBAAA;EA0ByB;EAxBzC,SAAA;EAwB8D;EAtB9D,MAAA;EAsB0E;EApB1E,MAAA;AAAA;;;;;;;;;;;;;;;;;;iBAoBe,iBAAA,CAAkB,MAAA,EAAQ,kBAAA,GAAqB,YAAA"}
|
package/dist/contracts/coin.js
CHANGED
|
@@ -1,42 +1,46 @@
|
|
|
1
|
+
import { fromBase58 } from "../encoding.js";
|
|
2
|
+
import { toAtomicAma } from "../conversion.js";
|
|
3
|
+
//#region src/contracts/coin.ts
|
|
1
4
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { toAtomicAma } from '../conversion';
|
|
13
|
-
import { fromBase58 } from '../encoding';
|
|
5
|
+
* Coin Contract (Special Case)
|
|
6
|
+
*
|
|
7
|
+
* The Coin contract is a built-in native contract with no WASM ABI file.
|
|
8
|
+
* It differs from WASM contracts:
|
|
9
|
+
* - First arg (recipient) is raw binary Uint8Array from fromBase58(), not a UTF-8 string
|
|
10
|
+
* - Amount requires toAtomicAma() conversion
|
|
11
|
+
*
|
|
12
|
+
* This module provides a dedicated builder that handles these special encodings
|
|
13
|
+
* while returning a standard ContractCall for uniform consumption by TransactionBuilder.
|
|
14
|
+
*/
|
|
14
15
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
16
|
+
* Build a Coin transfer ContractCall.
|
|
17
|
+
*
|
|
18
|
+
* Handles the special encoding requirements of the Coin contract:
|
|
19
|
+
* - recipient is decoded from Base58 to raw Uint8Array
|
|
20
|
+
* - amount is converted to atomic units via toAtomicAma()
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const call = buildCoinTransfer({
|
|
25
|
+
* recipient: '5Kd3N...',
|
|
26
|
+
* amount: 10.5,
|
|
27
|
+
* symbol: 'AMA'
|
|
28
|
+
* })
|
|
29
|
+
* TransactionBuilder.signCall(privateKey, call)
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function buildCoinTransfer(params) {
|
|
33
|
+
return {
|
|
34
|
+
contract: "Coin",
|
|
35
|
+
method: "transfer",
|
|
36
|
+
args: [
|
|
37
|
+
fromBase58(params.recipient),
|
|
38
|
+
toAtomicAma(params.amount).toString(),
|
|
39
|
+
params.symbol
|
|
40
|
+
]
|
|
41
|
+
};
|
|
41
42
|
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { buildCoinTransfer };
|
|
45
|
+
|
|
42
46
|
//# sourceMappingURL=coin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coin.js","
|
|
1
|
+
{"version":3,"file":"coin.js","names":[],"sources":["../../src/contracts/coin.ts"],"sourcesContent":["/**\n * Coin Contract (Special Case)\n *\n * The Coin contract is a built-in native contract with no WASM ABI file.\n * It differs from WASM contracts:\n * - First arg (recipient) is raw binary Uint8Array from fromBase58(), not a UTF-8 string\n * - Amount requires toAtomicAma() conversion\n *\n * This module provides a dedicated builder that handles these special encodings\n * while returning a standard ContractCall for uniform consumption by TransactionBuilder.\n */\n\nimport { toAtomicAma } from '../conversion'\nimport { fromBase58 } from '../encoding'\nimport type { ContractCall } from './contract-call'\n\n/**\n * Parameters for building a Coin transfer call\n */\nexport interface CoinTransferParams {\n\t/** Base58-encoded recipient address */\n\trecipient: string\n\t/** Amount in human-readable units (e.g. 10.5 AMA) */\n\tamount: number | string\n\t/** Token symbol (e.g. 'AMA') */\n\tsymbol: string\n}\n\n/**\n * Build a Coin transfer ContractCall.\n *\n * Handles the special encoding requirements of the Coin contract:\n * - recipient is decoded from Base58 to raw Uint8Array\n * - amount is converted to atomic units via toAtomicAma()\n *\n * @example\n * ```ts\n * const call = buildCoinTransfer({\n * recipient: '5Kd3N...',\n * amount: 10.5,\n * symbol: 'AMA'\n * })\n * TransactionBuilder.signCall(privateKey, call)\n * ```\n */\nexport function buildCoinTransfer(params: CoinTransferParams): ContractCall {\n\treturn {\n\t\tcontract: 'Coin',\n\t\tmethod: 'transfer',\n\t\targs: [fromBase58(params.recipient), toAtomicAma(params.amount).toString(), params.symbol]\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,SAAgB,kBAAkB,QAA0C;CAC3E,OAAO;EACN,UAAU;EACV,QAAQ;EACR,MAAM;GAAC,WAAW,OAAO,UAAU;GAAE,YAAY,OAAO,OAAO,CAAC,UAAU;GAAE,OAAO;GAAO;EAC1F"}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* compile-time type safety and runtime validation.
|
|
6
|
-
*/
|
|
7
|
-
import type { SerializableValue } from '../types';
|
|
8
|
-
import type { AbiDefinition, ExtractFunctionNames, FunctionParams } from './abi-types';
|
|
1
|
+
import { SerializableValue } from "../types.js";
|
|
2
|
+
import { AbiDefinition, ExtractFunctionNames, FunctionParams } from "./abi-types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/contract-call.d.ts
|
|
9
5
|
/**
|
|
10
6
|
* A fully-resolved contract call ready for TransactionBuilder.
|
|
11
7
|
*
|
|
12
8
|
* The type parameters are optional and used only for documentation;
|
|
13
9
|
* at runtime this is just `{ contract, method, args }`.
|
|
14
10
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
interface ContractCall<_TAbi extends AbiDefinition = AbiDefinition, _TFn extends string = string> {
|
|
12
|
+
/** Contract name (e.g. 'LockupPrime', 'Lockup', 'Coin') */
|
|
13
|
+
readonly contract: string;
|
|
14
|
+
/** Function/method name (e.g. 'lock', 'unlock', 'transfer') */
|
|
15
|
+
readonly method: string;
|
|
16
|
+
/** Serialized args array ready for VecPack encoding */
|
|
17
|
+
readonly args: SerializableValue[];
|
|
22
18
|
}
|
|
23
19
|
/**
|
|
24
20
|
* Build a type-safe ContractCall from an ABI definition.
|
|
@@ -45,5 +41,7 @@ export interface ContractCall<_TAbi extends AbiDefinition = AbiDefinition, _TFn
|
|
|
45
41
|
* // call.args === ['1000000000', '30d']
|
|
46
42
|
* ```
|
|
47
43
|
*/
|
|
48
|
-
|
|
44
|
+
declare function buildContractCall<TAbi extends AbiDefinition, TFn extends ExtractFunctionNames<TAbi>>(abi: TAbi, functionName: TFn, params: FunctionParams<TAbi, TFn & string>): ContractCall<TAbi, TFn & string>;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { ContractCall, buildContractCall };
|
|
49
47
|
//# sourceMappingURL=contract-call.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-call.d.ts","
|
|
1
|
+
{"version":3,"file":"contract-call.d.ts","names":[],"sources":["../../src/contracts/contract-call.ts"],"mappings":";;;;;;;;;;UAqBiB,YAAA,eACF,aAAA,GAAgB,aAAA;EAC9B;EAAA,SAGS,QAAA;EAEA;EAAA,SAAA,MAAA;EAEM;EAAA,SAAN,IAAA,EAAM,iBAAA;AAAA;AA4BhB;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iBAAgB,iBAAA,cACF,aAAA,cACD,oBAAA,CAAqB,IAAA,EAAA,CAEjC,GAAA,EAAK,IAAA,EACL,YAAA,EAAc,GAAA,EACd,MAAA,EAAQ,cAAA,CAAe,IAAA,EAAM,GAAA,aAC3B,YAAA,CAAa,IAAA,EAAM,GAAA"}
|
|
@@ -1,57 +1,48 @@
|
|
|
1
|
+
//#region src/contracts/contract-call.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (input.enum && input.enum.length > 0) {
|
|
44
|
-
if (!input.enum.includes(value)) {
|
|
45
|
-
throw new Error(`Invalid value "${value}" for parameter "${input.name}". ` +
|
|
46
|
-
`Expected one of: ${input.enum.join(', ')}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
args.push(value);
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
contract: abi.contractName,
|
|
53
|
-
method: functionName,
|
|
54
|
-
args
|
|
55
|
-
};
|
|
3
|
+
* Build a type-safe ContractCall from an ABI definition.
|
|
4
|
+
*
|
|
5
|
+
* Compile-time:
|
|
6
|
+
* - `functionName` is constrained to the ABI's function name union
|
|
7
|
+
* - `params` is typed per the function's declared inputs
|
|
8
|
+
*
|
|
9
|
+
* Runtime:
|
|
10
|
+
* - Validates function exists in ABI
|
|
11
|
+
* - Validates all required params are present
|
|
12
|
+
* - Validates enum constraints on inputs that declare them
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { LOCKUP_PRIME_ABI } from './lockup-prime/abi'
|
|
17
|
+
*
|
|
18
|
+
* const call = buildContractCall(LOCKUP_PRIME_ABI, 'lock', {
|
|
19
|
+
* amount: '1000000000',
|
|
20
|
+
* tier: '30d'
|
|
21
|
+
* })
|
|
22
|
+
* // call.contract === 'LockupPrime'
|
|
23
|
+
* // call.method === 'lock'
|
|
24
|
+
* // call.args === ['1000000000', '30d']
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
function buildContractCall(abi, functionName, params) {
|
|
28
|
+
const fn = abi.abi.find((f) => f.name === functionName);
|
|
29
|
+
if (!fn) throw new Error(`Function "${String(functionName)}" not found in ${abi.contractName} ABI`);
|
|
30
|
+
const args = [];
|
|
31
|
+
for (const input of fn.inputs) {
|
|
32
|
+
const value = params[input.name];
|
|
33
|
+
if (value === void 0 || value === null) throw new Error(`Missing required parameter "${input.name}" for ${abi.contractName}.${String(functionName)}`);
|
|
34
|
+
if (input.enum && input.enum.length > 0) {
|
|
35
|
+
if (!input.enum.includes(value)) throw new Error(`Invalid value "${value}" for parameter "${input.name}". Expected one of: ${input.enum.join(", ")}`);
|
|
36
|
+
}
|
|
37
|
+
args.push(value);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
contract: abi.contractName,
|
|
41
|
+
method: functionName,
|
|
42
|
+
args
|
|
43
|
+
};
|
|
56
44
|
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { buildContractCall };
|
|
47
|
+
|
|
57
48
|
//# sourceMappingURL=contract-call.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-call.js","
|
|
1
|
+
{"version":3,"file":"contract-call.js","names":[],"sources":["../../src/contracts/contract-call.ts"],"sourcesContent":["/**\n * Core ContractCall Abstraction\n *\n * Provides a generic, ABI-driven way to build contract calls with both\n * compile-time type safety and runtime validation.\n */\n\nimport type { SerializableValue } from '../types'\nimport type {\n\tAbiDefinition,\n\tExtractContractName,\n\tExtractFunctionNames,\n\tFunctionParams\n} from './abi-types'\n\n/**\n * A fully-resolved contract call ready for TransactionBuilder.\n *\n * The type parameters are optional and used only for documentation;\n * at runtime this is just `{ contract, method, args }`.\n */\nexport interface ContractCall<\n\t_TAbi extends AbiDefinition = AbiDefinition,\n\t_TFn extends string = string\n> {\n\t/** Contract name (e.g. 'LockupPrime', 'Lockup', 'Coin') */\n\treadonly contract: string\n\t/** Function/method name (e.g. 'lock', 'unlock', 'transfer') */\n\treadonly method: string\n\t/** Serialized args array ready for VecPack encoding */\n\treadonly args: SerializableValue[]\n}\n\n/**\n * Build a type-safe ContractCall from an ABI definition.\n *\n * Compile-time:\n * - `functionName` is constrained to the ABI's function name union\n * - `params` is typed per the function's declared inputs\n *\n * Runtime:\n * - Validates function exists in ABI\n * - Validates all required params are present\n * - Validates enum constraints on inputs that declare them\n *\n * @example\n * ```ts\n * import { LOCKUP_PRIME_ABI } from './lockup-prime/abi'\n *\n * const call = buildContractCall(LOCKUP_PRIME_ABI, 'lock', {\n * amount: '1000000000',\n * tier: '30d'\n * })\n * // call.contract === 'LockupPrime'\n * // call.method === 'lock'\n * // call.args === ['1000000000', '30d']\n * ```\n */\nexport function buildContractCall<\n\tTAbi extends AbiDefinition,\n\tTFn extends ExtractFunctionNames<TAbi>\n>(\n\tabi: TAbi,\n\tfunctionName: TFn,\n\tparams: FunctionParams<TAbi, TFn & string>\n): ContractCall<TAbi, TFn & string> {\n\tconst fn = abi.abi.find((f) => f.name === functionName)\n\tif (!fn) {\n\t\tthrow new Error(`Function \"${String(functionName)}\" not found in ${abi.contractName} ABI`)\n\t}\n\n\tconst args: SerializableValue[] = []\n\tfor (const input of fn.inputs) {\n\t\tconst value = (params as Record<string, string>)[input.name]\n\t\tif (value === undefined || value === null) {\n\t\t\tthrow new Error(\n\t\t\t\t`Missing required parameter \"${input.name}\" for ${abi.contractName}.${String(functionName)}`\n\t\t\t)\n\t\t}\n\n\t\tif (input.enum && input.enum.length > 0) {\n\t\t\tif (!input.enum.includes(value)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid value \"${value}\" for parameter \"${input.name}\". ` +\n\t\t\t\t\t\t`Expected one of: ${input.enum.join(', ')}`\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\n\t\targs.push(value)\n\t}\n\n\treturn {\n\t\tcontract: abi.contractName as ExtractContractName<TAbi>,\n\t\tmethod: functionName as string,\n\t\targs\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgB,kBAIf,KACA,cACA,QACmC;CACnC,MAAM,KAAK,IAAI,IAAI,MAAM,MAAM,EAAE,SAAS,aAAa;CACvD,IAAI,CAAC,IACJ,MAAM,IAAI,MAAM,aAAa,OAAO,aAAa,CAAC,iBAAiB,IAAI,aAAa,MAAM;CAG3F,MAAM,OAA4B,EAAE;CACpC,KAAK,MAAM,SAAS,GAAG,QAAQ;EAC9B,MAAM,QAAS,OAAkC,MAAM;EACvD,IAAI,UAAU,KAAA,KAAa,UAAU,MACpC,MAAM,IAAI,MACT,+BAA+B,MAAM,KAAK,QAAQ,IAAI,aAAa,GAAG,OAAO,aAAa,GAC1F;EAGF,IAAI,MAAM,QAAQ,MAAM,KAAK,SAAS;OACjC,CAAC,MAAM,KAAK,SAAS,MAAM,EAC9B,MAAM,IAAI,MACT,kBAAkB,MAAM,mBAAmB,MAAM,KAAK,sBACjC,MAAM,KAAK,KAAK,KAAK,GAC1C;;EAIH,KAAK,KAAK,MAAM;;CAGjB,OAAO;EACN,UAAU,IAAI;EACd,QAAQ;EACR;EACA"}
|
|
@@ -1,51 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* Each function declared in the ABI becomes a typed method on the contract
|
|
8
|
-
* object — with autocomplete for function names and typed params derived
|
|
9
|
-
* from the ABI inputs.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { createContract, LOCKUP_PRIME_ABI, toAtomicAma } from '@amadeus-protocol/sdk'
|
|
14
|
-
*
|
|
15
|
-
* // Unsigned — returns ContractCall for TransactionBuilder.signCall()
|
|
16
|
-
* const lockupPrime = createContract(LOCKUP_PRIME_ABI)
|
|
17
|
-
* const call = lockupPrime.lock({ amount: toAtomicAma(100).toString(), tier: '30d' })
|
|
18
|
-
* const { txHash, txPacked } = TransactionBuilder.signCall(privateKey, call)
|
|
19
|
-
*
|
|
20
|
-
* // Signed — bind a private key, methods return BuildTransactionResult directly
|
|
21
|
-
* const signed = createContract(LOCKUP_PRIME_ABI).connect(privateKey)
|
|
22
|
-
* const result = signed.lock({ amount: toAtomicAma(100).toString(), tier: '30d' })
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
import type { BuildTransactionResult } from '../types';
|
|
26
|
-
import type { AbiDefinition, AbiInput } from './abi-types';
|
|
27
|
-
import type { ContractCall } from './contract-call';
|
|
1
|
+
import { BuildTransactionResult } from "../types.js";
|
|
2
|
+
import { AbiDefinition, AbiInput } from "./abi-types.js";
|
|
3
|
+
import { ContractCall } from "./contract-call.js";
|
|
4
|
+
|
|
5
|
+
//#region src/contracts/contract.d.ts
|
|
28
6
|
/**
|
|
29
7
|
* Map an ABI inputs tuple to a params object: `{ inputName: string }`
|
|
30
8
|
*/
|
|
31
|
-
type InputsToParams<Inputs extends readonly AbiInput[]> = {
|
|
32
|
-
readonly [I in Inputs[number] as I['name']]: string;
|
|
33
|
-
};
|
|
9
|
+
type InputsToParams<Inputs extends readonly AbiInput[]> = { readonly [I in Inputs[number] as I['name']]: string };
|
|
34
10
|
/**
|
|
35
11
|
* For each function in the ABI, generate a typed method signature.
|
|
36
12
|
*
|
|
37
13
|
* - Functions with inputs → `(params: { name: string, ... }) => ContractCall`
|
|
38
14
|
* - Functions without inputs → `() => ContractCall`
|
|
39
15
|
*/
|
|
40
|
-
type ContractMethods<TAbi extends AbiDefinition> = {
|
|
41
|
-
readonly [F in TAbi['abi'][number] as F['name']]: F['inputs'] extends readonly [] ? () => ContractCall : (params: InputsToParams<F['inputs']>) => ContractCall;
|
|
42
|
-
};
|
|
16
|
+
type ContractMethods<TAbi extends AbiDefinition> = { readonly [F in TAbi['abi'][number] as F['name']]: F['inputs'] extends readonly [] ? () => ContractCall : (params: InputsToParams<F['inputs']>) => ContractCall };
|
|
43
17
|
/**
|
|
44
18
|
* Same as ContractMethods but methods return signed `BuildTransactionResult`.
|
|
45
19
|
*/
|
|
46
|
-
type SignedContractMethods<TAbi extends AbiDefinition> = {
|
|
47
|
-
readonly [F in TAbi['abi'][number] as F['name']]: F['inputs'] extends readonly [] ? () => BuildTransactionResult : (params: InputsToParams<F['inputs']>) => BuildTransactionResult;
|
|
48
|
-
};
|
|
20
|
+
type SignedContractMethods<TAbi extends AbiDefinition> = { readonly [F in TAbi['abi'][number] as F['name']]: F['inputs'] extends readonly [] ? () => BuildTransactionResult : (params: InputsToParams<F['inputs']>) => BuildTransactionResult };
|
|
49
21
|
/**
|
|
50
22
|
* A typed contract interface generated from an ABI definition.
|
|
51
23
|
*
|
|
@@ -55,18 +27,16 @@ type SignedContractMethods<TAbi extends AbiDefinition> = {
|
|
|
55
27
|
* Call `.connect(privateKey)` to get a `SignedContract` where methods
|
|
56
28
|
* return `BuildTransactionResult` directly.
|
|
57
29
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
*/
|
|
69
|
-
connect(privateKey: string): SignedContract<TAbi>;
|
|
30
|
+
type TypedContract<TAbi extends AbiDefinition> = ContractMethods<TAbi> & {
|
|
31
|
+
/** The original ABI definition */readonly abi: TAbi; /** Contract name extracted from ABI */
|
|
32
|
+
readonly contractName: TAbi['contractName'];
|
|
33
|
+
/**
|
|
34
|
+
* Bind a signer to produce a `SignedContract` where every method
|
|
35
|
+
* derives keys, builds, and signs in one step.
|
|
36
|
+
*
|
|
37
|
+
* @param privateKey - Base58 encoded private key (seed)
|
|
38
|
+
*/
|
|
39
|
+
connect(privateKey: string): SignedContract<TAbi>;
|
|
70
40
|
};
|
|
71
41
|
/**
|
|
72
42
|
* A signer-bound contract interface.
|
|
@@ -74,11 +44,9 @@ export type TypedContract<TAbi extends AbiDefinition> = ContractMethods<TAbi> &
|
|
|
74
44
|
* Every ABI function is a method that returns `BuildTransactionResult`
|
|
75
45
|
* (txHash + txPacked ready for submission).
|
|
76
46
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/** Contract name extracted from ABI */
|
|
81
|
-
readonly contractName: TAbi['contractName'];
|
|
47
|
+
type SignedContract<TAbi extends AbiDefinition> = SignedContractMethods<TAbi> & {
|
|
48
|
+
/** The original ABI definition */readonly abi: TAbi; /** Contract name extracted from ABI */
|
|
49
|
+
readonly contractName: TAbi['contractName'];
|
|
82
50
|
};
|
|
83
51
|
/**
|
|
84
52
|
* Create a typed contract interface from an ABI definition.
|
|
@@ -108,6 +76,7 @@ export type SignedContract<TAbi extends AbiDefinition> = SignedContractMethods<T
|
|
|
108
76
|
* const result = signed.lock({ amount: '100000000000', tier: '30d' })
|
|
109
77
|
* ```
|
|
110
78
|
*/
|
|
111
|
-
|
|
112
|
-
|
|
79
|
+
declare function createContract<TAbi extends AbiDefinition>(abi: TAbi): TypedContract<TAbi>;
|
|
80
|
+
//#endregion
|
|
81
|
+
export { SignedContract, TypedContract, createContract };
|
|
113
82
|
//# sourceMappingURL=contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","
|
|
1
|
+
{"version":3,"file":"contract.d.ts","names":[],"sources":["../../src/contracts/contract.ts"],"mappings":";;;;;;;;KAoCK,cAAA,yBAAuC,QAAA,uBAC5B,MAAA,YAAkB,CAAA;;;;;;;KAS7B,eAAA,cAA6B,aAAA,qBAClB,IAAA,mBAAuB,CAAA,WAAY,CAAA,uCACzC,YAAA,IACL,MAAA,EAAQ,cAAA,CAAe,CAAA,gBAAiB,YAAA;;;;KAMxC,qBAAA,cAAmC,aAAA,qBACxB,IAAA,mBAAuB,CAAA,WAAY,CAAA,uCACzC,sBAAA,IACL,MAAA,EAAQ,cAAA,CAAe,CAAA,gBAAiB,sBAAA;;;;;;;;;;KAcjC,aAAA,cAA2B,aAAA,IAAiB,eAAA,CAAgB,IAAA;EAdL,2CAgBzD,GAAA,EAAK,IAAA,EAnByB;EAAA,SAqB9B,YAAA,EAAc,IAAA;EApBR;;;;;;EA2Bf,OAAA,CAAQ,UAAA,WAAqB,cAAA,CAAe,IAAA;AAAA;;;AAX7C;;;;KAoBY,cAAA,cAA4B,aAAA,IAAiB,qBAAA,CAAsB,IAAA;EApBvB,2CAsB9C,GAAA,EAAK,IAAA,EAlBS;EAAA,SAoBd,YAAA,EAAc,IAAA;AAAA;;;;;;;;;;;;;;;;;AAJxB;;;;;;;;;;;;iBAqCgB,cAAA,cAA4B,aAAA,CAAA,CAAe,GAAA,EAAK,IAAA,GAAO,aAAA,CAAc,IAAA"}
|
|
@@ -1,107 +1,69 @@
|
|
|
1
|
+
import { signContractCall } from "../signing.js";
|
|
2
|
+
import { buildContractCall } from "./contract-call.js";
|
|
3
|
+
//#region src/contracts/contract.ts
|
|
1
4
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
* const { txHash, txPacked } = TransactionBuilder.signCall(privateKey, call)
|
|
50
|
-
*
|
|
51
|
-
* // Or bind a signer:
|
|
52
|
-
* const signed = lockupPrime.connect(privateKey)
|
|
53
|
-
* const result = signed.lock({ amount: '100000000000', tier: '30d' })
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
export function createContract(abi) {
|
|
57
|
-
if (!abi || typeof abi !== 'object') {
|
|
58
|
-
throw new Error('Invalid ABI: expected an object');
|
|
59
|
-
}
|
|
60
|
-
if (typeof abi.contractName !== 'string' || !abi.contractName) {
|
|
61
|
-
throw new Error('Invalid ABI: missing or empty "contractName"');
|
|
62
|
-
}
|
|
63
|
-
if (!Array.isArray(abi.abi)) {
|
|
64
|
-
throw new Error(`Invalid ABI for ${abi.contractName}: "abi" must be an array of functions`);
|
|
65
|
-
}
|
|
66
|
-
for (const fn of abi.abi) {
|
|
67
|
-
if (fn.type !== 'function') {
|
|
68
|
-
throw new Error(`Invalid ABI for ${abi.contractName}: entry "${fn.name ?? '?'}" has type "${fn.type}", expected "function"`);
|
|
69
|
-
}
|
|
70
|
-
if (typeof fn.name !== 'string' || !fn.name) {
|
|
71
|
-
throw new Error(`Invalid ABI for ${abi.contractName}: function entry missing "name"`);
|
|
72
|
-
}
|
|
73
|
-
if (!Array.isArray(fn.inputs)) {
|
|
74
|
-
throw new Error(`Invalid ABI for ${abi.contractName}: function "${fn.name}" missing "inputs" array`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const contract = {
|
|
78
|
-
abi,
|
|
79
|
-
contractName: abi.contractName,
|
|
80
|
-
connect(privateKey) {
|
|
81
|
-
return createSignedContract(abi, privateKey);
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
for (const fn of abi.abi) {
|
|
85
|
-
contract[fn.name] = (params) => {
|
|
86
|
-
return buildContractCall(abi, fn.name, (params ?? {}));
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
return contract;
|
|
5
|
+
* Create a typed contract interface from an ABI definition.
|
|
6
|
+
*
|
|
7
|
+
* Returns an object where each ABI function is a method with fully typed
|
|
8
|
+
* params (derived from ABI inputs) and autocomplete on function names.
|
|
9
|
+
*
|
|
10
|
+
* @param abi - An ABI definition object (must be declared `as const`)
|
|
11
|
+
* @returns A typed `TypedContract<TAbi>` with methods for each ABI function
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { createContract, LOCKUP_PRIME_ABI, LOCKUP_ABI, toAtomicAma } from '@amadeus-protocol/sdk'
|
|
16
|
+
*
|
|
17
|
+
* // Each ABI function becomes a typed method:
|
|
18
|
+
* const lockupPrime = createContract(LOCKUP_PRIME_ABI)
|
|
19
|
+
* lockupPrime.lock({ amount: toAtomicAma(100).toString(), tier: '30d' }) // typed
|
|
20
|
+
* lockupPrime.unlock({ vaultIndex: '3' }) // typed
|
|
21
|
+
* lockupPrime.daily_checkin({ vaultIndex: '7' }) // typed
|
|
22
|
+
*
|
|
23
|
+
* // Sign the call:
|
|
24
|
+
* const call = lockupPrime.lock({ amount: '100000000000', tier: '30d' })
|
|
25
|
+
* const { txHash, txPacked } = TransactionBuilder.signCall(privateKey, call)
|
|
26
|
+
*
|
|
27
|
+
* // Or bind a signer:
|
|
28
|
+
* const signed = lockupPrime.connect(privateKey)
|
|
29
|
+
* const result = signed.lock({ amount: '100000000000', tier: '30d' })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function createContract(abi) {
|
|
33
|
+
if (!abi || typeof abi !== "object") throw new Error("Invalid ABI: expected an object");
|
|
34
|
+
if (typeof abi.contractName !== "string" || !abi.contractName) throw new Error("Invalid ABI: missing or empty \"contractName\"");
|
|
35
|
+
if (!Array.isArray(abi.abi)) throw new Error(`Invalid ABI for ${abi.contractName}: "abi" must be an array of functions`);
|
|
36
|
+
for (const fn of abi.abi) {
|
|
37
|
+
if (fn.type !== "function") throw new Error(`Invalid ABI for ${abi.contractName}: entry "${fn.name ?? "?"}" has type "${fn.type}", expected "function"`);
|
|
38
|
+
if (typeof fn.name !== "string" || !fn.name) throw new Error(`Invalid ABI for ${abi.contractName}: function entry missing "name"`);
|
|
39
|
+
if (!Array.isArray(fn.inputs)) throw new Error(`Invalid ABI for ${abi.contractName}: function "${fn.name}" missing "inputs" array`);
|
|
40
|
+
}
|
|
41
|
+
const contract = {
|
|
42
|
+
abi,
|
|
43
|
+
contractName: abi.contractName,
|
|
44
|
+
connect(privateKey) {
|
|
45
|
+
return createSignedContract(abi, privateKey);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
for (const fn of abi.abi) contract[fn.name] = (params) => {
|
|
49
|
+
return buildContractCall(abi, fn.name, params ?? {});
|
|
50
|
+
};
|
|
51
|
+
return contract;
|
|
90
52
|
}
|
|
91
53
|
/**
|
|
92
|
-
|
|
93
|
-
|
|
54
|
+
* Create a signer-bound contract where each method builds + signs in one step.
|
|
55
|
+
*/
|
|
94
56
|
function createSignedContract(abi, privateKey) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return contract;
|
|
57
|
+
const contract = {
|
|
58
|
+
abi,
|
|
59
|
+
contractName: abi.contractName
|
|
60
|
+
};
|
|
61
|
+
for (const fn of abi.abi) contract[fn.name] = (params) => {
|
|
62
|
+
return signContractCall(privateKey, buildContractCall(abi, fn.name, params ?? {}));
|
|
63
|
+
};
|
|
64
|
+
return contract;
|
|
106
65
|
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { createContract };
|
|
68
|
+
|
|
107
69
|
//# sourceMappingURL=contract.js.map
|