@sravankumar02/sdk-core 1.0.0 → 2.0.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/out/abi/codec/binary.js.map +1 -1
- package/out/abi/codec/managedDecimal.js +17 -5
- package/out/abi/codec/managedDecimal.js.map +1 -1
- package/out/abi/codec/managedDecimalSigned.js +17 -5
- package/out/abi/codec/managedDecimalSigned.js.map +1 -1
- package/out/abi/index.d.ts +0 -3
- package/out/abi/index.js +0 -3
- package/out/abi/index.js.map +1 -1
- package/out/abi/nativeSerializer.js +1 -1
- package/out/abi/nativeSerializer.js.map +1 -1
- package/out/abi/typesystem/typeMapper.js +2 -0
- package/out/abi/typesystem/typeMapper.js.map +1 -1
- package/out/accountManagement/accountController.d.ts +2 -1
- package/out/accountManagement/accountController.js +11 -20
- package/out/accountManagement/accountController.js.map +1 -1
- package/out/accountManagement/accountTransactionsFactory.d.ts +10 -5
- package/out/accountManagement/accountTransactionsFactory.js +45 -34
- package/out/accountManagement/accountTransactionsFactory.js.map +1 -1
- package/out/core/address.d.ts +1 -25
- package/out/core/address.js +3 -41
- package/out/core/address.js.map +1 -1
- package/out/core/baseController.d.ts +9 -3
- package/out/core/baseController.js +24 -10
- package/out/core/baseController.js.map +1 -1
- package/out/core/baseFactory.d.ts +25 -0
- package/out/core/baseFactory.js +40 -0
- package/out/core/baseFactory.js.map +1 -0
- package/out/core/codeMetadata.d.ts +0 -10
- package/out/core/codeMetadata.js +0 -27
- package/out/core/codeMetadata.js.map +1 -1
- package/out/core/constants.d.ts +1 -0
- package/out/core/constants.js +2 -1
- package/out/core/constants.js.map +1 -1
- package/out/core/errors.d.ts +9 -0
- package/out/core/errors.js +17 -2
- package/out/core/errors.js.map +1 -1
- package/out/core/index.d.ts +2 -0
- package/out/core/index.js +2 -0
- package/out/core/index.js.map +1 -1
- package/out/core/interfaces.d.ts +5 -0
- package/out/core/tokens.d.ts +1 -77
- package/out/core/tokens.js +2 -144
- package/out/core/tokens.js.map +1 -1
- package/out/core/transaction.d.ts +1 -144
- package/out/core/transaction.js +0 -209
- package/out/core/transaction.js.map +1 -1
- package/out/core/transactionStatus.d.ts +0 -5
- package/out/core/transactionStatus.js +0 -7
- package/out/core/transactionStatus.js.map +1 -1
- package/out/core/transactionsFactoryConfig.d.ts +16 -0
- package/out/core/transactionsFactoryConfig.js +17 -0
- package/out/core/transactionsFactoryConfig.js.map +1 -1
- package/out/delegation/delegationController.d.ts +2 -1
- package/out/delegation/delegationController.js +39 -134
- package/out/delegation/delegationController.js.map +1 -1
- package/out/delegation/delegationTransactionsFactory.d.ts +23 -20
- package/out/delegation/delegationTransactionsFactory.js +183 -159
- package/out/delegation/delegationTransactionsFactory.js.map +1 -1
- package/out/entrypoints/entrypoints.d.ts +36 -3
- package/out/entrypoints/entrypoints.js +102 -27
- package/out/entrypoints/entrypoints.js.map +1 -1
- package/out/gasEstimator/gasLimitEstimator.d.ts +19 -0
- package/out/gasEstimator/gasLimitEstimator.js +22 -0
- package/out/gasEstimator/gasLimitEstimator.js.map +1 -0
- package/out/gasEstimator/index.d.ts +1 -0
- package/out/gasEstimator/index.js +6 -0
- package/out/gasEstimator/index.js.map +1 -0
- package/out/governance/governanceController.d.ts +2 -1
- package/out/governance/governanceController.js +13 -43
- package/out/governance/governanceController.js.map +1 -1
- package/out/governance/governanceTransactionsFactory.d.ts +10 -8
- package/out/governance/governanceTransactionsFactory.js +60 -52
- package/out/governance/governanceTransactionsFactory.js.map +1 -1
- package/out/index.d.ts +1 -0
- package/out/index.js +1 -0
- package/out/index.js.map +1 -1
- package/out/multisig/index.d.ts +2 -0
- package/out/multisig/index.js +2 -0
- package/out/multisig/index.js.map +1 -1
- package/out/multisig/multisigController.d.ts +2 -1
- package/out/multisig/multisigController.js +61 -117
- package/out/multisig/multisigController.js.map +1 -1
- package/out/multisig/multisigTransactionsFactory.d.ts +26 -24
- package/out/multisig/multisigTransactionsFactory.js +57 -54
- package/out/multisig/multisigTransactionsFactory.js.map +1 -1
- package/out/multisig/proposeTransferExecuteContractInput.d.ts +2 -2
- package/out/multisig/proposeTransferExecuteContractInput.js +4 -4
- package/out/multisig/proposeTransferExecuteContractInput.js.map +1 -1
- package/out/multisig/resources.d.ts +2 -2
- package/out/networkProviders/apiNetworkProvider.js +1 -3
- package/out/networkProviders/apiNetworkProvider.js.map +1 -1
- package/out/networkProviders/proxyNetworkProvider.js +20 -1
- package/out/networkProviders/proxyNetworkProvider.js.map +1 -1
- package/out/networkProviders/tokens.d.ts +1 -1
- package/out/networkProviders/tokens.js +14 -11
- package/out/networkProviders/tokens.js.map +1 -1
- package/out/smartContracts/resources.d.ts +6 -2
- package/out/smartContracts/smartContractController.d.ts +2 -1
- package/out/smartContracts/smartContractController.js +10 -22
- package/out/smartContracts/smartContractController.js.map +1 -1
- package/out/smartContracts/smartContractTransactionsFactory.d.ts +12 -7
- package/out/smartContracts/smartContractTransactionsFactory.js +62 -44
- package/out/smartContracts/smartContractTransactionsFactory.js.map +1 -1
- package/out/tokenManagement/tokenManagementController.d.ts +2 -1
- package/out/tokenManagement/tokenManagementController.js +71 -246
- package/out/tokenManagement/tokenManagementController.js.map +1 -1
- package/out/tokenManagement/tokenManagementTransactionsFactory.d.ts +39 -36
- package/out/tokenManagement/tokenManagementTransactionsFactory.js +310 -275
- package/out/tokenManagement/tokenManagementTransactionsFactory.js.map +1 -1
- package/out/transfers/transferTransactionsFactory.d.ts +10 -8
- package/out/transfers/transferTransactionsFactory.js +28 -26
- package/out/transfers/transferTransactionsFactory.js.map +1 -1
- package/out/transfers/transfersControllers.d.ts +2 -1
- package/out/transfers/transfersControllers.js +10 -23
- package/out/transfers/transfersControllers.js.map +1 -1
- package/out/validators/index.d.ts +2 -0
- package/out/validators/index.js +15 -0
- package/out/validators/index.js.map +1 -0
- package/out/validators/resources.d.ts +40 -0
- package/out/validators/resources.js +3 -0
- package/out/validators/resources.js.map +1 -0
- package/out/validators/validatorsController.d.ts +27 -0
- package/out/validators/validatorsController.js +95 -0
- package/out/validators/validatorsController.js.map +1 -0
- package/out/validators/validatorsSigner.d.ts +9 -0
- package/out/validators/validatorsSigner.js +25 -0
- package/out/validators/validatorsSigner.js.map +1 -0
- package/out/validators/validatorsTransactionsFactory.d.ts +33 -0
- package/out/validators/validatorsTransactionsFactory.js +269 -0
- package/out/validators/validatorsTransactionsFactory.js.map +1 -0
- package/out/wallet/index.d.ts +1 -0
- package/out/wallet/index.js +1 -0
- package/out/wallet/index.js.map +1 -1
- package/out/wallet/userWallet.d.ts +1 -1
- package/out/wallet/userWallet.js +1 -1
- package/out/wallet/validatorPem.d.ts +12 -0
- package/out/wallet/validatorPem.js +45 -0
- package/out/wallet/validatorPem.js.map +1 -0
- package/out/wallet/validatorSigner.d.ts +9 -1
- package/out/wallet/validatorSigner.js +24 -1
- package/out/wallet/validatorSigner.js.map +1 -1
- package/package.json +6 -5
- package/out/abi/code.d.ts +0 -23
- package/out/abi/code.js +0 -41
- package/out/abi/code.js.map +0 -1
- package/out/abi/interaction.d.ts +0 -67
- package/out/abi/interaction.js +0 -146
- package/out/abi/interaction.js.map +0 -1
- package/out/abi/smartContract.d.ts +0 -74
- package/out/abi/smartContract.js +0 -208
- package/out/abi/smartContract.js.map +0 -1
- package/out/core/transactionBuilder.d.ts +0 -32
- package/out/core/transactionBuilder.js +0 -45
- package/out/core/transactionBuilder.js.map +0 -1
package/out/abi/interaction.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { Account } from "../accounts";
|
|
2
|
-
import { Address } from "../core/address";
|
|
3
|
-
import { TokenTransfer } from "../core/tokens";
|
|
4
|
-
import { Transaction } from "../core/transaction";
|
|
5
|
-
import { ContractFunction } from "./function";
|
|
6
|
-
import { CallArguments } from "./interface";
|
|
7
|
-
import { Query } from "./query";
|
|
8
|
-
import { EndpointDefinition, TypedValue } from "./typesystem";
|
|
9
|
-
/**
|
|
10
|
-
* Internal interface: the smart contract, as seen from the perspective of an {@link Interaction}.
|
|
11
|
-
*/
|
|
12
|
-
interface ISmartContractWithinInteraction {
|
|
13
|
-
call({ func, args, value, gasLimit, receiver }: CallArguments): Transaction;
|
|
14
|
-
getAddress(): Address;
|
|
15
|
-
getEndpoint(name: ContractFunction): EndpointDefinition;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated component. Use "SmartContractTransactionsFactory" or "SmartContractController", instead.
|
|
19
|
-
*
|
|
20
|
-
* Interactions can be seen as mutable transaction & query builders.
|
|
21
|
-
*
|
|
22
|
-
* Aside from building transactions and queries, the interactors are also responsible for interpreting
|
|
23
|
-
* the execution outcome for the objects they've built.
|
|
24
|
-
*/
|
|
25
|
-
export declare class Interaction {
|
|
26
|
-
private readonly contract;
|
|
27
|
-
private readonly function;
|
|
28
|
-
private readonly args;
|
|
29
|
-
private nonce;
|
|
30
|
-
private value;
|
|
31
|
-
private gasLimit;
|
|
32
|
-
private gasPrice;
|
|
33
|
-
private chainID;
|
|
34
|
-
private querent;
|
|
35
|
-
private explicitReceiver?;
|
|
36
|
-
private sender;
|
|
37
|
-
private version;
|
|
38
|
-
private tokenTransfers;
|
|
39
|
-
constructor(contract: ISmartContractWithinInteraction, func: ContractFunction, args: TypedValue[]);
|
|
40
|
-
getContractAddress(): Address;
|
|
41
|
-
getFunction(): ContractFunction;
|
|
42
|
-
getEndpoint(): EndpointDefinition;
|
|
43
|
-
getArguments(): TypedValue[];
|
|
44
|
-
getValue(): bigint;
|
|
45
|
-
getTokenTransfers(): TokenTransfer[];
|
|
46
|
-
getGasLimit(): bigint;
|
|
47
|
-
getExplicitReceiver(): Address | undefined;
|
|
48
|
-
buildTransaction(): Transaction;
|
|
49
|
-
buildQuery(): Query;
|
|
50
|
-
withValue(value: bigint): Interaction;
|
|
51
|
-
withSingleDCDTTransfer(transfer: TokenTransfer): Interaction;
|
|
52
|
-
withSingleDCDTNFTTransfer(transfer: TokenTransfer): Interaction;
|
|
53
|
-
withMultiDCDTNFTTransfer(transfers: TokenTransfer[]): Interaction;
|
|
54
|
-
withGasLimit(gasLimit: bigint): Interaction;
|
|
55
|
-
withGasPrice(gasPrice: bigint): Interaction;
|
|
56
|
-
withNonce(nonce: bigint): Interaction;
|
|
57
|
-
useThenIncrementNonceOf(account: Account): Interaction;
|
|
58
|
-
withChainID(chainID: string): Interaction;
|
|
59
|
-
withSender(sender: Address): Interaction;
|
|
60
|
-
withVersion(version: number): Interaction;
|
|
61
|
-
/**
|
|
62
|
-
* Sets the "caller" field on contract queries.
|
|
63
|
-
*/
|
|
64
|
-
withQuerent(querent: Address): Interaction;
|
|
65
|
-
withExplicitReceiver(receiver: Address): Interaction;
|
|
66
|
-
}
|
|
67
|
-
export {};
|
package/out/abi/interaction.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Interaction = void 0;
|
|
4
|
-
const address_1 = require("../core/address");
|
|
5
|
-
const compatibility_1 = require("../core/compatibility");
|
|
6
|
-
const constants_1 = require("../core/constants");
|
|
7
|
-
const tokens_1 = require("../core/tokens");
|
|
8
|
-
const transactionsFactoryConfig_1 = require("../core/transactionsFactoryConfig");
|
|
9
|
-
const smartContracts_1 = require("../smartContracts");
|
|
10
|
-
const query_1 = require("./query");
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated component. Use "SmartContractTransactionsFactory" or "SmartContractController", instead.
|
|
13
|
-
*
|
|
14
|
-
* Interactions can be seen as mutable transaction & query builders.
|
|
15
|
-
*
|
|
16
|
-
* Aside from building transactions and queries, the interactors are also responsible for interpreting
|
|
17
|
-
* the execution outcome for the objects they've built.
|
|
18
|
-
*/
|
|
19
|
-
class Interaction {
|
|
20
|
-
constructor(contract, func, args) {
|
|
21
|
-
this.nonce = 0n;
|
|
22
|
-
this.value = 0n;
|
|
23
|
-
this.gasLimit = 0n;
|
|
24
|
-
this.gasPrice = undefined;
|
|
25
|
-
this.chainID = "";
|
|
26
|
-
this.querent = address_1.Address.empty();
|
|
27
|
-
this.sender = address_1.Address.empty();
|
|
28
|
-
this.version = constants_1.TRANSACTION_VERSION_DEFAULT;
|
|
29
|
-
this.contract = contract;
|
|
30
|
-
this.function = func;
|
|
31
|
-
this.args = args;
|
|
32
|
-
this.tokenTransfers = [];
|
|
33
|
-
}
|
|
34
|
-
getContractAddress() {
|
|
35
|
-
return this.contract.getAddress();
|
|
36
|
-
}
|
|
37
|
-
getFunction() {
|
|
38
|
-
return this.function;
|
|
39
|
-
}
|
|
40
|
-
getEndpoint() {
|
|
41
|
-
return this.contract.getEndpoint(this.function);
|
|
42
|
-
}
|
|
43
|
-
getArguments() {
|
|
44
|
-
return this.args;
|
|
45
|
-
}
|
|
46
|
-
getValue() {
|
|
47
|
-
return this.value;
|
|
48
|
-
}
|
|
49
|
-
getTokenTransfers() {
|
|
50
|
-
return this.tokenTransfers;
|
|
51
|
-
}
|
|
52
|
-
getGasLimit() {
|
|
53
|
-
return this.gasLimit;
|
|
54
|
-
}
|
|
55
|
-
getExplicitReceiver() {
|
|
56
|
-
return this.explicitReceiver;
|
|
57
|
-
}
|
|
58
|
-
buildTransaction() {
|
|
59
|
-
compatibility_1.Compatibility.guardAddressIsSetAndNonZero(this.sender, "'sender' of interaction", "use interaction.withSender()");
|
|
60
|
-
const factoryConfig = new transactionsFactoryConfig_1.TransactionsFactoryConfig({ chainID: this.chainID.valueOf() });
|
|
61
|
-
const factory = new smartContracts_1.SmartContractTransactionsFactory({
|
|
62
|
-
config: factoryConfig,
|
|
63
|
-
});
|
|
64
|
-
const transaction = factory.createTransactionForExecute(this.sender, {
|
|
65
|
-
contract: this.contract.getAddress(),
|
|
66
|
-
function: this.function.valueOf(),
|
|
67
|
-
gasLimit: BigInt(this.gasLimit.valueOf()),
|
|
68
|
-
arguments: this.args,
|
|
69
|
-
nativeTransferAmount: BigInt(this.value.toString()),
|
|
70
|
-
tokenTransfers: this.tokenTransfers,
|
|
71
|
-
});
|
|
72
|
-
transaction.chainID = this.chainID.valueOf();
|
|
73
|
-
transaction.nonce = BigInt(this.nonce.valueOf());
|
|
74
|
-
transaction.version = this.version;
|
|
75
|
-
if (this.gasPrice) {
|
|
76
|
-
transaction.gasPrice = BigInt(this.gasPrice.valueOf());
|
|
77
|
-
}
|
|
78
|
-
return transaction;
|
|
79
|
-
}
|
|
80
|
-
buildQuery() {
|
|
81
|
-
return new query_1.Query({
|
|
82
|
-
address: this.contract.getAddress(),
|
|
83
|
-
func: this.function,
|
|
84
|
-
args: this.args,
|
|
85
|
-
// Value will be set using "withValue()".
|
|
86
|
-
value: this.value,
|
|
87
|
-
caller: this.querent,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
withValue(value) {
|
|
91
|
-
this.value = value;
|
|
92
|
-
return this;
|
|
93
|
-
}
|
|
94
|
-
withSingleDCDTTransfer(transfer) {
|
|
95
|
-
this.tokenTransfers = [transfer].map((transfer) => new tokens_1.TokenTransfer(transfer));
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
withSingleDCDTNFTTransfer(transfer) {
|
|
99
|
-
this.tokenTransfers = [transfer].map((transfer) => new tokens_1.TokenTransfer(transfer));
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
withMultiDCDTNFTTransfer(transfers) {
|
|
103
|
-
this.tokenTransfers = transfers.map((transfer) => new tokens_1.TokenTransfer(transfer));
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
withGasLimit(gasLimit) {
|
|
107
|
-
this.gasLimit = gasLimit;
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
withGasPrice(gasPrice) {
|
|
111
|
-
this.gasPrice = gasPrice;
|
|
112
|
-
return this;
|
|
113
|
-
}
|
|
114
|
-
withNonce(nonce) {
|
|
115
|
-
this.nonce = nonce;
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
useThenIncrementNonceOf(account) {
|
|
119
|
-
return this.withNonce(account.getNonceThenIncrement());
|
|
120
|
-
}
|
|
121
|
-
withChainID(chainID) {
|
|
122
|
-
this.chainID = chainID;
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
withSender(sender) {
|
|
126
|
-
this.sender = sender;
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
withVersion(version) {
|
|
130
|
-
this.version = version;
|
|
131
|
-
return this;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Sets the "caller" field on contract queries.
|
|
135
|
-
*/
|
|
136
|
-
withQuerent(querent) {
|
|
137
|
-
this.querent = querent;
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
withExplicitReceiver(receiver) {
|
|
141
|
-
this.explicitReceiver = receiver;
|
|
142
|
-
return this;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.Interaction = Interaction;
|
|
146
|
-
//# sourceMappingURL=interaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../src/abi/interaction.ts"],"names":[],"mappings":";;;AACA,6CAA0C;AAC1C,yDAAsD;AACtD,iDAAgE;AAChE,2CAA+C;AAE/C,iFAA8E;AAC9E,sDAAqE;AAGrE,mCAAgC;AAYhC;;;;;;;GAOG;AACH,MAAa,WAAW;IAiBpB,YAAY,QAAyC,EAAE,IAAsB,EAAE,IAAkB;QAZzF,UAAK,GAAW,EAAE,CAAC;QACnB,UAAK,GAAW,EAAE,CAAC;QACnB,aAAQ,GAAW,EAAE,CAAC;QACtB,aAAQ,GAAuB,SAAS,CAAC;QACzC,YAAO,GAAW,EAAE,CAAC;QACrB,YAAO,GAAY,iBAAO,CAAC,KAAK,EAAE,CAAC;QAEnC,WAAM,GAAY,iBAAO,CAAC,KAAK,EAAE,CAAC;QAClC,YAAO,GAAW,uCAA2B,CAAC;QAKlD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,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ACJ;AArKD,kCAqKC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Address } from "../core/address";
|
|
2
|
-
import { Transaction } from "../core/transaction";
|
|
3
|
-
import { ContractFunction } from "./function";
|
|
4
|
-
import { Interaction } from "./interaction";
|
|
5
|
-
import { CallArguments, DeployArguments, ISmartContract, QueryArguments, UpgradeArguments } from "./interface";
|
|
6
|
-
import { Query } from "./query";
|
|
7
|
-
import { Abi, EndpointDefinition, TypedValue } from "./typesystem";
|
|
8
|
-
/**
|
|
9
|
-
* * @deprecated component. Use "SmartContractTransactionsFactory" or "SmartContractController", instead.
|
|
10
|
-
*
|
|
11
|
-
* An abstraction for deploying and interacting with Smart Contracts.
|
|
12
|
-
*/
|
|
13
|
-
export declare class SmartContract implements ISmartContract {
|
|
14
|
-
private address;
|
|
15
|
-
private abi?;
|
|
16
|
-
/**
|
|
17
|
-
* This object contains a function for each endpoint defined by the contract.
|
|
18
|
-
* (a bit similar to web3js's "contract.methods").
|
|
19
|
-
*/
|
|
20
|
-
readonly methodsExplicit: {
|
|
21
|
-
[key: string]: (args?: TypedValue[]) => Interaction;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* This object contains a function for each endpoint defined by the contract.
|
|
25
|
-
* (a bit similar to web3js's "contract.methods").
|
|
26
|
-
*
|
|
27
|
-
* This is an alternative to {@link methodsExplicit}.
|
|
28
|
-
* Unlike {@link methodsExplicit}, automatic type inference (wrt. ABI) is applied when using {@link methods}.
|
|
29
|
-
*/
|
|
30
|
-
readonly methods: {
|
|
31
|
-
[key: string]: (args?: any[]) => Interaction;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Create a SmartContract object by providing its address on the Network.
|
|
35
|
-
*/
|
|
36
|
-
constructor(options?: {
|
|
37
|
-
address?: Address;
|
|
38
|
-
abi?: Abi;
|
|
39
|
-
});
|
|
40
|
-
private setupMethods;
|
|
41
|
-
/**
|
|
42
|
-
* Sets the address, as on Network.
|
|
43
|
-
*/
|
|
44
|
-
setAddress(address: Address): void;
|
|
45
|
-
/**
|
|
46
|
-
* Gets the address, as on Network.
|
|
47
|
-
*/
|
|
48
|
-
getAddress(): Address;
|
|
49
|
-
private getAbi;
|
|
50
|
-
getEndpoint(name: string | ContractFunction): EndpointDefinition;
|
|
51
|
-
/**
|
|
52
|
-
* Creates a {@link Transaction} for deploying the Smart Contract to the Network.
|
|
53
|
-
*/
|
|
54
|
-
deploy({ deployer, code, codeMetadata, initArguments, value, gasLimit, gasPrice, chainID, }: DeployArguments): Transaction;
|
|
55
|
-
private getMetadataPropertiesAsObject;
|
|
56
|
-
/**
|
|
57
|
-
* Creates a {@link Transaction} for upgrading the Smart Contract on the Network.
|
|
58
|
-
*/
|
|
59
|
-
upgrade({ caller, code, codeMetadata, initArguments, value, gasLimit, gasPrice, chainID, }: UpgradeArguments): Transaction;
|
|
60
|
-
/**
|
|
61
|
-
* Creates a {@link Transaction} for calling (a function of) the Smart Contract.
|
|
62
|
-
*/
|
|
63
|
-
call({ func, args, value, gasLimit, receiver, gasPrice, chainID, caller }: CallArguments): Transaction;
|
|
64
|
-
createQuery({ func, args, value, caller }: QueryArguments): Query;
|
|
65
|
-
private ensureHasAddress;
|
|
66
|
-
/**
|
|
67
|
-
* Computes the address of a Smart Contract.
|
|
68
|
-
* The address is computed deterministically, from the address of the owner and the nonce of the deployment transaction.
|
|
69
|
-
*
|
|
70
|
-
* @param owner The owner of the Smart Contract
|
|
71
|
-
* @param nonce The owner nonce used for the deployment transaction
|
|
72
|
-
*/
|
|
73
|
-
static computeAddress(owner: Address, nonce: bigint): Address;
|
|
74
|
-
}
|
package/out/abi/smartContract.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SmartContract = void 0;
|
|
4
|
-
const address_1 = require("../core/address");
|
|
5
|
-
const codeMetadata_1 = require("../core/codeMetadata");
|
|
6
|
-
const compatibility_1 = require("../core/compatibility");
|
|
7
|
-
const constants_1 = require("../core/constants");
|
|
8
|
-
const errors_1 = require("../core/errors");
|
|
9
|
-
const transactionsFactoryConfig_1 = require("../core/transactionsFactoryConfig");
|
|
10
|
-
const utils_1 = require("../core/utils");
|
|
11
|
-
const smartContractTransactionsFactory_1 = require("./../smartContracts/smartContractTransactionsFactory");
|
|
12
|
-
const function_1 = require("./function");
|
|
13
|
-
const interaction_1 = require("./interaction");
|
|
14
|
-
const nativeSerializer_1 = require("./nativeSerializer");
|
|
15
|
-
const query_1 = require("./query");
|
|
16
|
-
/**
|
|
17
|
-
* * @deprecated component. Use "SmartContractTransactionsFactory" or "SmartContractController", instead.
|
|
18
|
-
*
|
|
19
|
-
* An abstraction for deploying and interacting with Smart Contracts.
|
|
20
|
-
*/
|
|
21
|
-
class SmartContract {
|
|
22
|
-
/**
|
|
23
|
-
* Create a SmartContract object by providing its address on the Network.
|
|
24
|
-
*/
|
|
25
|
-
constructor(options = {}) {
|
|
26
|
-
this.address = address_1.Address.empty();
|
|
27
|
-
/**
|
|
28
|
-
* This object contains a function for each endpoint defined by the contract.
|
|
29
|
-
* (a bit similar to web3js's "contract.methods").
|
|
30
|
-
*/
|
|
31
|
-
this.methodsExplicit = {};
|
|
32
|
-
/**
|
|
33
|
-
* This object contains a function for each endpoint defined by the contract.
|
|
34
|
-
* (a bit similar to web3js's "contract.methods").
|
|
35
|
-
*
|
|
36
|
-
* This is an alternative to {@link methodsExplicit}.
|
|
37
|
-
* Unlike {@link methodsExplicit}, automatic type inference (wrt. ABI) is applied when using {@link methods}.
|
|
38
|
-
*/
|
|
39
|
-
this.methods = {};
|
|
40
|
-
this.address = options.address || address_1.Address.empty();
|
|
41
|
-
this.abi = options.abi;
|
|
42
|
-
if (this.abi) {
|
|
43
|
-
this.setupMethods();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
setupMethods() {
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
48
|
-
let contract = this;
|
|
49
|
-
let abi = this.getAbi();
|
|
50
|
-
for (const definition of abi.getEndpoints()) {
|
|
51
|
-
let functionName = definition.name;
|
|
52
|
-
// For each endpoint defined by the ABI, we attach a function to the "methods" and "methodsAuto" objects,
|
|
53
|
-
// a function that receives typed values as arguments
|
|
54
|
-
// and returns a prepared contract interaction.
|
|
55
|
-
this.methodsExplicit[functionName] = function (args) {
|
|
56
|
-
let func = new function_1.ContractFunction(functionName);
|
|
57
|
-
let interaction = new interaction_1.Interaction(contract, func, args || []);
|
|
58
|
-
return interaction;
|
|
59
|
-
};
|
|
60
|
-
this.methods[functionName] = function (args) {
|
|
61
|
-
let func = new function_1.ContractFunction(functionName);
|
|
62
|
-
// Perform automatic type inference, wrt. the endpoint definition:
|
|
63
|
-
let typedArgs = nativeSerializer_1.NativeSerializer.nativeToTypedValues(args || [], definition);
|
|
64
|
-
let interaction = new interaction_1.Interaction(contract, func, typedArgs || []);
|
|
65
|
-
return interaction;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Sets the address, as on Network.
|
|
71
|
-
*/
|
|
72
|
-
setAddress(address) {
|
|
73
|
-
this.address = address;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Gets the address, as on Network.
|
|
77
|
-
*/
|
|
78
|
-
getAddress() {
|
|
79
|
-
return this.address;
|
|
80
|
-
}
|
|
81
|
-
getAbi() {
|
|
82
|
-
utils_1.guardValueIsSet("abi", this.abi);
|
|
83
|
-
return this.abi;
|
|
84
|
-
}
|
|
85
|
-
getEndpoint(name) {
|
|
86
|
-
if (typeof name === "string") {
|
|
87
|
-
return this.getAbi().getEndpoint(name);
|
|
88
|
-
}
|
|
89
|
-
return this.getAbi().getEndpoint(name.name);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Creates a {@link Transaction} for deploying the Smart Contract to the Network.
|
|
93
|
-
*/
|
|
94
|
-
deploy({ deployer, code, codeMetadata, initArguments, value, gasLimit, gasPrice, chainID, }) {
|
|
95
|
-
compatibility_1.Compatibility.guardAddressIsSetAndNonZero(deployer, "'deployer' of SmartContract.deploy()", "pass the actual address to deploy()");
|
|
96
|
-
const config = new transactionsFactoryConfig_1.TransactionsFactoryConfig({ chainID: chainID.valueOf() });
|
|
97
|
-
const factory = new smartContractTransactionsFactory_1.SmartContractTransactionsFactory({
|
|
98
|
-
config: config,
|
|
99
|
-
abi: this.abi,
|
|
100
|
-
});
|
|
101
|
-
const bytecode = Buffer.from(code.toString(), "hex");
|
|
102
|
-
const metadataAsJson = this.getMetadataPropertiesAsObject(codeMetadata);
|
|
103
|
-
const transaction = factory.createTransactionForDeploy(deployer, {
|
|
104
|
-
bytecode: bytecode,
|
|
105
|
-
gasLimit: BigInt(gasLimit.valueOf()),
|
|
106
|
-
arguments: initArguments ?? [],
|
|
107
|
-
isUpgradeable: metadataAsJson.upgradeable,
|
|
108
|
-
isReadable: metadataAsJson.readable,
|
|
109
|
-
isPayable: metadataAsJson.payable,
|
|
110
|
-
isPayableBySmartContract: metadataAsJson.payableBySc,
|
|
111
|
-
});
|
|
112
|
-
transaction.chainID = chainID;
|
|
113
|
-
transaction.value = value ?? 0n;
|
|
114
|
-
transaction.gasPrice = gasPrice ?? BigInt(constants_1.TRANSACTION_MIN_GAS_PRICE);
|
|
115
|
-
return transaction;
|
|
116
|
-
}
|
|
117
|
-
getMetadataPropertiesAsObject(codeMetadata) {
|
|
118
|
-
let metadata;
|
|
119
|
-
if (codeMetadata) {
|
|
120
|
-
metadata = codeMetadata_1.CodeMetadata.newFromBytes(Buffer.from(codeMetadata.toString(), "hex"));
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
metadata = new codeMetadata_1.CodeMetadata();
|
|
124
|
-
}
|
|
125
|
-
const metadataAsJson = metadata.toJSON();
|
|
126
|
-
return metadataAsJson;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Creates a {@link Transaction} for upgrading the Smart Contract on the Network.
|
|
130
|
-
*/
|
|
131
|
-
upgrade({ caller, code, codeMetadata, initArguments, value, gasLimit, gasPrice, chainID, }) {
|
|
132
|
-
compatibility_1.Compatibility.guardAddressIsSetAndNonZero(caller, "'caller' of SmartContract.upgrade()", "pass the actual address to upgrade()");
|
|
133
|
-
this.ensureHasAddress();
|
|
134
|
-
const config = new transactionsFactoryConfig_1.TransactionsFactoryConfig({ chainID: chainID.valueOf() });
|
|
135
|
-
const factory = new smartContractTransactionsFactory_1.SmartContractTransactionsFactory({
|
|
136
|
-
config: config,
|
|
137
|
-
abi: this.abi,
|
|
138
|
-
});
|
|
139
|
-
const bytecode = Uint8Array.from(Buffer.from(code.toString(), "hex"));
|
|
140
|
-
const metadataAsJson = this.getMetadataPropertiesAsObject(codeMetadata);
|
|
141
|
-
const transaction = factory.createTransactionForUpgrade(caller, {
|
|
142
|
-
contract: this.getAddress(),
|
|
143
|
-
bytecode: bytecode,
|
|
144
|
-
gasLimit: BigInt(gasLimit.valueOf()),
|
|
145
|
-
arguments: initArguments ?? [],
|
|
146
|
-
isUpgradeable: metadataAsJson.upgradeable,
|
|
147
|
-
isReadable: metadataAsJson.readable,
|
|
148
|
-
isPayable: metadataAsJson.payable,
|
|
149
|
-
isPayableBySmartContract: metadataAsJson.payableBySc,
|
|
150
|
-
});
|
|
151
|
-
transaction.chainID = chainID;
|
|
152
|
-
transaction.value = value ?? 0n;
|
|
153
|
-
transaction.gasPrice = gasPrice ?? BigInt(constants_1.TRANSACTION_MIN_GAS_PRICE);
|
|
154
|
-
return transaction;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Creates a {@link Transaction} for calling (a function of) the Smart Contract.
|
|
158
|
-
*/
|
|
159
|
-
call({ func, args, value, gasLimit, receiver, gasPrice, chainID, caller }) {
|
|
160
|
-
compatibility_1.Compatibility.guardAddressIsSetAndNonZero(caller, "'caller' of SmartContract.call()", "pass the actual address to call()");
|
|
161
|
-
this.ensureHasAddress();
|
|
162
|
-
const config = new transactionsFactoryConfig_1.TransactionsFactoryConfig({ chainID: chainID.valueOf() });
|
|
163
|
-
const factory = new smartContractTransactionsFactory_1.SmartContractTransactionsFactory({
|
|
164
|
-
config: config,
|
|
165
|
-
abi: this.abi,
|
|
166
|
-
});
|
|
167
|
-
args = args || [];
|
|
168
|
-
value = value || 0n;
|
|
169
|
-
const transaction = factory.createTransactionForExecute(caller, {
|
|
170
|
-
contract: receiver ? receiver : this.getAddress(),
|
|
171
|
-
function: func.toString(),
|
|
172
|
-
gasLimit: gasLimit,
|
|
173
|
-
arguments: args,
|
|
174
|
-
});
|
|
175
|
-
transaction.chainID = chainID;
|
|
176
|
-
transaction.value = value;
|
|
177
|
-
transaction.gasPrice = gasPrice ?? BigInt(constants_1.TRANSACTION_MIN_GAS_PRICE);
|
|
178
|
-
return transaction;
|
|
179
|
-
}
|
|
180
|
-
createQuery({ func, args, value, caller }) {
|
|
181
|
-
this.ensureHasAddress();
|
|
182
|
-
return new query_1.Query({
|
|
183
|
-
address: this.getAddress(),
|
|
184
|
-
func: func,
|
|
185
|
-
args: args,
|
|
186
|
-
value: value,
|
|
187
|
-
caller: caller,
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
ensureHasAddress() {
|
|
191
|
-
if (!this.getAddress().toBech32()) {
|
|
192
|
-
throw new errors_1.ErrContractHasNoAddress();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Computes the address of a Smart Contract.
|
|
197
|
-
* The address is computed deterministically, from the address of the owner and the nonce of the deployment transaction.
|
|
198
|
-
*
|
|
199
|
-
* @param owner The owner of the Smart Contract
|
|
200
|
-
* @param nonce The owner nonce used for the deployment transaction
|
|
201
|
-
*/
|
|
202
|
-
static computeAddress(owner, nonce) {
|
|
203
|
-
const addressComputer = new address_1.AddressComputer();
|
|
204
|
-
return addressComputer.computeContractAddress(owner, BigInt(nonce.valueOf()));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
exports.SmartContract = SmartContract;
|
|
208
|
-
//# sourceMappingURL=smartContract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smartContract.js","sourceRoot":"","sources":["../../src/abi/smartContract.ts"],"names":[],"mappings":";;;AAAA,6CAA2D;AAC3D,uDAAoD;AACpD,yDAAsD;AACtD,iDAA8D;AAC9D,2CAAyD;AAEzD,iFAA8E;AAC9E,yCAAgD;AAChD,2GAAwG;AACxG,yCAA8C;AAC9C,+CAA4C;AAS5C,yDAAsD;AACtD,mCAAgC;AAGhC;;;;GAIG;AACH,MAAa,aAAa;IAmBtB;;OAEG;IACH,YAAY,UAA4C,EAAE;QArBlD,YAAO,GAAY,iBAAO,CAAC,KAAK,EAAE,CAAC;QAG3C;;;WAGG;QACa,oBAAe,GAA4D,EAAE,CAAC;QAE9F;;;;;;WAMG;QACa,YAAO,GAAqD,EAAE,CAAC;QAM3E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,iBAAO,CAAC,KAAK,EAAE,CAAC;QAClD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QAEvB,IAAI,IAAI,CAAC,GAAG,EAAE;YACV,IAAI,CAAC,YAAY,EAAE,CAAC;SACvB;IACL,CAAC;IAEO,YAAY;QAChB,4DAA4D;QAC5D,IAAI,QAAQ,GAAG,IAAI,CAAC;QACpB,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAExB,KAAK,MAAM,UAAU,IAAI,GAAG,CAAC,YAAY,EAAE,EAAE;YACzC,IAAI,YAAY,GAAG,UAAU,CAAC,IAAI,CAAC;YAEnC,yGAAyG;YACzG,qDAAqD;YACrD,+CAA+C;YAC/C,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,UAAU,IAAmB;gBAC9D,IAAI,IAAI,GAAG,IAAI,2BAAgB,CAAC,YAAY,CAAC,CAAC;gBAC9C,IAAI,WAAW,GAAG,IAAI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AK,EAAE,MAAM,EAAkB;QACrD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAExB,OAAO,IAAI,aAAK,CAAC;YACb,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI;YACV,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM;SACjB,CAAC,CAAC;IACP,CAAC;IAEO,gBAAgB;QACpB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;YAC/B,MAAM,IAAI,gCAAuB,EAAE,CAAC;SACvC;IACL,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CAAC,KAAc,EAAE,KAAa;QAC/C,MAAM,eAAe,GAAG,IAAI,yBAAe,EAAE,CAAC;QAC9C,OAAO,eAAe,CAAC,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAClF,CAAC;CACJ;AAvQD,sCAuQC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Address } from "./address";
|
|
2
|
-
import { Transaction } from "./transaction";
|
|
3
|
-
interface Config {
|
|
4
|
-
chainID: string;
|
|
5
|
-
minGasLimit: bigint;
|
|
6
|
-
gasLimitPerByte: bigint;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export declare class TransactionBuilder {
|
|
12
|
-
private config;
|
|
13
|
-
private sender;
|
|
14
|
-
private receiver;
|
|
15
|
-
private dataParts;
|
|
16
|
-
private providedGasLimit;
|
|
17
|
-
private addDataMovementGas;
|
|
18
|
-
private amount?;
|
|
19
|
-
constructor(options: {
|
|
20
|
-
config: Config;
|
|
21
|
-
sender: Address;
|
|
22
|
-
receiver: Address;
|
|
23
|
-
dataParts: string[];
|
|
24
|
-
gasLimit: bigint;
|
|
25
|
-
addDataMovementGas: boolean;
|
|
26
|
-
amount?: bigint;
|
|
27
|
-
});
|
|
28
|
-
private computeGasLimit;
|
|
29
|
-
private buildTransactionPayload;
|
|
30
|
-
build(): Transaction;
|
|
31
|
-
}
|
|
32
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TransactionBuilder = void 0;
|
|
4
|
-
const constants_1 = require("./constants");
|
|
5
|
-
const transaction_1 = require("./transaction");
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
class TransactionBuilder {
|
|
10
|
-
constructor(options) {
|
|
11
|
-
this.config = options.config;
|
|
12
|
-
this.sender = options.sender;
|
|
13
|
-
this.receiver = options.receiver;
|
|
14
|
-
this.dataParts = options.dataParts;
|
|
15
|
-
this.providedGasLimit = options.gasLimit;
|
|
16
|
-
this.addDataMovementGas = options.addDataMovementGas;
|
|
17
|
-
this.amount = options.amount;
|
|
18
|
-
}
|
|
19
|
-
computeGasLimit(payload) {
|
|
20
|
-
if (!this.addDataMovementGas) {
|
|
21
|
-
return this.providedGasLimit;
|
|
22
|
-
}
|
|
23
|
-
const dataMovementGas = this.config.minGasLimit + this.config.gasLimitPerByte * BigInt(payload.length);
|
|
24
|
-
const gasLimit = dataMovementGas + this.providedGasLimit;
|
|
25
|
-
return gasLimit;
|
|
26
|
-
}
|
|
27
|
-
buildTransactionPayload() {
|
|
28
|
-
const data = this.dataParts.join(constants_1.ARGUMENTS_SEPARATOR);
|
|
29
|
-
return Buffer.from(data);
|
|
30
|
-
}
|
|
31
|
-
build() {
|
|
32
|
-
const data = this.buildTransactionPayload();
|
|
33
|
-
const gasLimit = this.computeGasLimit(data);
|
|
34
|
-
return new transaction_1.Transaction({
|
|
35
|
-
sender: this.sender,
|
|
36
|
-
receiver: this.receiver,
|
|
37
|
-
gasLimit: gasLimit,
|
|
38
|
-
value: this.amount || 0n,
|
|
39
|
-
data: data.valueOf(),
|
|
40
|
-
chainID: this.config.chainID,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.TransactionBuilder = TransactionBuilder;
|
|
45
|
-
//# sourceMappingURL=transactionBuilder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transactionBuilder.js","sourceRoot":"","sources":["../../src/core/transactionBuilder.ts"],"names":[],"mappings":";;;AACA,2CAAkD;AAClD,+CAA4C;AAQ5C;;GAEG;AACH,MAAa,kBAAkB;IAS3B,YAAY,OAQX;QACG,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC;QACzC,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACrD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACjC,CAAC;IAEO,eAAe,CAAC,OAAmB;QACvC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC1B,OAAO,IAAI,CAAC,gBAAgB,CAAC;SAChC;QAED,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACvG,MAAM,QAAQ,GAAG,eAAe,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACzD,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEO,uBAAuB;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,+BAAmB,CAAC,CAAC;QACtD,OAAO,MAAM,CAAC,IAAI,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