@tonappchain/sdk 0.7.0-rc24-test-8 → 0.7.0-rc24-test-10
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/artifacts/dev/tac/artifacts.js +2 -2
- package/dist/artifacts/dev/tac/wrappers.d.ts +4 -4
- package/dist/artifacts/mainnet/tac/artifacts.js +2 -2
- package/dist/artifacts/mainnet/tac/wrappers.d.ts +4 -4
- package/dist/artifacts/tacTypes.d.ts +1 -1
- package/dist/artifacts/testnet/tac/artifacts.js +2 -2
- package/dist/artifacts/testnet/tac/wrappers.d.ts +4 -4
- package/dist/artifacts/tonTypes.d.ts +1 -1
- package/dist/src/adapters/contractOpener.js +3 -1
- package/dist/src/agnosticSdk/AbiHandler.d.ts +23 -0
- package/dist/src/agnosticSdk/AbiHandler.js +105 -0
- package/dist/src/agnosticSdk/AgnosticSdk.d.ts +47 -217
- package/dist/src/agnosticSdk/AgnosticSdk.js +60 -595
- package/dist/src/agnosticSdk/AgnosticStructs.d.ts +108 -0
- package/dist/src/agnosticSdk/AgnosticStructs.js +23 -0
- package/dist/src/agnosticSdk/DebugHelpers.d.ts +88 -0
- package/dist/src/agnosticSdk/DebugHelpers.js +274 -0
- package/dist/src/agnosticSdk/HooksHandler.d.ts +43 -0
- package/dist/src/agnosticSdk/HooksHandler.js +102 -0
- package/dist/src/agnosticSdk/ReplacementHelper.d.ts +95 -0
- package/dist/src/agnosticSdk/ReplacementHelper.js +233 -0
- package/dist/src/assets/NFT.js +3 -3
- package/dist/src/errors/index.d.ts +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +26 -2
- package/dist/src/sdk/Configuration.js +5 -5
- package/dist/src/sdk/OperationTracker.js +37 -14
- package/dist/src/sdk/TONTransactionManager.js +3 -2
- package/dist/src/sdk/TacSdk.js +4 -37
- package/dist/src/structs/InternalStruct.d.ts +1 -1
- package/dist/src/wrappers/ContentUtils.js +0 -1
- package/package.json +1 -1
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.compilationArtifacts = void 0;
|
|
7
|
+
const IERC721_json_1 = __importDefault(require("./internal/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json"));
|
|
7
8
|
const ICrossChainLayer_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ICrossChainLayer.sol/ICrossChainLayer.json"));
|
|
8
9
|
const ISettings_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ISettings.sol/ISettings.json"));
|
|
9
10
|
const ITokenUtils_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ITokenUtils.sol/ITokenUtils.json"));
|
|
10
11
|
const ICrossChainLayerERC20_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/ICrossChainLayerERC20.sol/ICrossChainLayerERC20.json"));
|
|
11
12
|
const ICrossChainLayerERC721_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/ICrossChainLayerERC721.sol/ICrossChainLayerERC721.json"));
|
|
13
|
+
const IERC20WithDecimals_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/IERC20WithDecimals.sol/IERC20WithDecimals.json"));
|
|
12
14
|
const ISAFactory_json_1 = __importDefault(require("./internal/artifacts/contracts/smart-account/interfaces/ISAFactory.sol/ISAFactory.json"));
|
|
13
15
|
const ITacSmartAccount_json_1 = __importDefault(require("./internal/artifacts/contracts/smart-account/interfaces/ITacSmartAccount.sol/ITacSmartAccount.json"));
|
|
14
|
-
const IERC20WithDecimals_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/IERC20WithDecimals.sol/IERC20WithDecimals.json"));
|
|
15
|
-
const IERC721_json_1 = __importDefault(require("./internal/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json"));
|
|
16
16
|
exports.compilationArtifacts = {
|
|
17
17
|
ICrossChainLayer: ICrossChainLayer_json_1.default,
|
|
18
18
|
ISettings: ISettings_json_1.default,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export { IERC721 } from './internal/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721';
|
|
1
2
|
export { ICrossChainLayer } from './internal/typechain-types/contracts/interfaces/ICrossChainLayer';
|
|
2
3
|
export { ISettings } from './internal/typechain-types/contracts/interfaces/ISettings';
|
|
3
4
|
export { ITokenUtils } from './internal/typechain-types/contracts/interfaces/ITokenUtils';
|
|
4
|
-
export { ISAFactory } from './internal/typechain-types/contracts/smart-account/interfaces/ISAFactory';
|
|
5
|
-
export { ITacSmartAccount } from './internal/typechain-types/contracts/smart-account/interfaces/ITacSmartAccount';
|
|
6
|
-
export { IERC20WithDecimals } from './internal/typechain-types/contracts/interfaces/tokens/IERC20WithDecimals';
|
|
7
|
-
export { IERC721 } from './internal/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721';
|
|
8
5
|
export { ICrossChainLayerERC20 } from './internal/typechain-types/contracts/interfaces/tokens/ICrossChainLayerERC20';
|
|
9
6
|
export { ICrossChainLayerERC721 } from './internal/typechain-types/contracts/interfaces/tokens/ICrossChainLayerERC721';
|
|
7
|
+
export { IERC20WithDecimals } from './internal/typechain-types/contracts/interfaces/tokens/IERC20WithDecimals';
|
|
8
|
+
export { ISAFactory } from './internal/typechain-types/contracts/smart-account/interfaces/ISAFactory';
|
|
9
|
+
export { ITacSmartAccount } from './internal/typechain-types/contracts/smart-account/interfaces/ITacSmartAccount';
|
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.compilationArtifacts = void 0;
|
|
7
|
+
const IERC721_json_1 = __importDefault(require("./internal/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json"));
|
|
7
8
|
const ICrossChainLayer_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ICrossChainLayer.sol/ICrossChainLayer.json"));
|
|
8
9
|
const ISettings_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ISettings.sol/ISettings.json"));
|
|
9
10
|
const ITokenUtils_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ITokenUtils.sol/ITokenUtils.json"));
|
|
10
11
|
const ICrossChainLayerERC20_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/ICrossChainLayerERC20.sol/ICrossChainLayerERC20.json"));
|
|
11
12
|
const ICrossChainLayerERC721_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/ICrossChainLayerERC721.sol/ICrossChainLayerERC721.json"));
|
|
13
|
+
const IERC20WithDecimals_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/IERC20WithDecimals.sol/IERC20WithDecimals.json"));
|
|
12
14
|
const ISAFactory_json_1 = __importDefault(require("./internal/artifacts/contracts/smart-account/interfaces/ISAFactory.sol/ISAFactory.json"));
|
|
13
15
|
const ITacSmartAccount_json_1 = __importDefault(require("./internal/artifacts/contracts/smart-account/interfaces/ITacSmartAccount.sol/ITacSmartAccount.json"));
|
|
14
|
-
const IERC20WithDecimals_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/IERC20WithDecimals.sol/IERC20WithDecimals.json"));
|
|
15
|
-
const IERC721_json_1 = __importDefault(require("./internal/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json"));
|
|
16
16
|
exports.compilationArtifacts = {
|
|
17
17
|
ICrossChainLayer: ICrossChainLayer_json_1.default,
|
|
18
18
|
ISettings: ISettings_json_1.default,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export { IERC721 } from './internal/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721';
|
|
1
2
|
export { ICrossChainLayer } from './internal/typechain-types/contracts/interfaces/ICrossChainLayer';
|
|
2
3
|
export { ISettings } from './internal/typechain-types/contracts/interfaces/ISettings';
|
|
3
4
|
export { ITokenUtils } from './internal/typechain-types/contracts/interfaces/ITokenUtils';
|
|
4
|
-
export { ISAFactory } from './internal/typechain-types/contracts/smart-account/interfaces/ISAFactory';
|
|
5
|
-
export { ITacSmartAccount } from './internal/typechain-types/contracts/smart-account/interfaces/ITacSmartAccount';
|
|
6
|
-
export { IERC20WithDecimals } from './internal/typechain-types/contracts/interfaces/tokens/IERC20WithDecimals';
|
|
7
|
-
export { IERC721 } from './internal/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721';
|
|
8
5
|
export { ICrossChainLayerERC20 } from './internal/typechain-types/contracts/interfaces/tokens/ICrossChainLayerERC20';
|
|
9
6
|
export { ICrossChainLayerERC721 } from './internal/typechain-types/contracts/interfaces/tokens/ICrossChainLayerERC721';
|
|
7
|
+
export { IERC20WithDecimals } from './internal/typechain-types/contracts/interfaces/tokens/IERC20WithDecimals';
|
|
8
|
+
export { ISAFactory } from './internal/typechain-types/contracts/smart-account/interfaces/ISAFactory';
|
|
9
|
+
export { ITacSmartAccount } from './internal/typechain-types/contracts/smart-account/interfaces/ITacSmartAccount';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Dev from './dev';
|
|
2
|
-
import type * as Testnet from './testnet';
|
|
3
2
|
import type * as Mainnet from './mainnet';
|
|
3
|
+
import type * as Testnet from './testnet';
|
|
4
4
|
export type ICrossChainLayer = Dev.tac.wrappers.ICrossChainLayer | Testnet.tac.wrappers.ICrossChainLayer | Mainnet.tac.wrappers.ICrossChainLayer;
|
|
5
5
|
export type ISAFactory = Dev.tac.wrappers.ISAFactory | Testnet.tac.wrappers.ISAFactory | Mainnet.tac.wrappers.ISAFactory;
|
|
6
6
|
export type ITacSmartAccount = Dev.tac.wrappers.ITacSmartAccount | Testnet.tac.wrappers.ITacSmartAccount | Mainnet.tac.wrappers.ITacSmartAccount;
|
|
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.compilationArtifacts = void 0;
|
|
7
|
+
const IERC721_json_1 = __importDefault(require("./internal/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json"));
|
|
7
8
|
const ICrossChainLayer_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ICrossChainLayer.sol/ICrossChainLayer.json"));
|
|
8
9
|
const ISettings_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ISettings.sol/ISettings.json"));
|
|
9
10
|
const ITokenUtils_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/ITokenUtils.sol/ITokenUtils.json"));
|
|
10
11
|
const ICrossChainLayerERC20_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/ICrossChainLayerERC20.sol/ICrossChainLayerERC20.json"));
|
|
11
12
|
const ICrossChainLayerERC721_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/ICrossChainLayerERC721.sol/ICrossChainLayerERC721.json"));
|
|
13
|
+
const IERC20WithDecimals_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/IERC20WithDecimals.sol/IERC20WithDecimals.json"));
|
|
12
14
|
const ISAFactory_json_1 = __importDefault(require("./internal/artifacts/contracts/smart-account/interfaces/ISAFactory.sol/ISAFactory.json"));
|
|
13
15
|
const ITacSmartAccount_json_1 = __importDefault(require("./internal/artifacts/contracts/smart-account/interfaces/ITacSmartAccount.sol/ITacSmartAccount.json"));
|
|
14
|
-
const IERC20WithDecimals_json_1 = __importDefault(require("./internal/artifacts/contracts/interfaces/tokens/IERC20WithDecimals.sol/IERC20WithDecimals.json"));
|
|
15
|
-
const IERC721_json_1 = __importDefault(require("./internal/artifacts/@openzeppelin/contracts/token/ERC721/IERC721.sol/IERC721.json"));
|
|
16
16
|
exports.compilationArtifacts = {
|
|
17
17
|
ICrossChainLayer: ICrossChainLayer_json_1.default,
|
|
18
18
|
ISettings: ISettings_json_1.default,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
export { IERC721 } from './internal/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721';
|
|
1
2
|
export { ICrossChainLayer } from './internal/typechain-types/contracts/interfaces/ICrossChainLayer';
|
|
2
3
|
export { ISettings } from './internal/typechain-types/contracts/interfaces/ISettings';
|
|
3
4
|
export { ITokenUtils } from './internal/typechain-types/contracts/interfaces/ITokenUtils';
|
|
4
|
-
export { ISAFactory } from './internal/typechain-types/contracts/smart-account/interfaces/ISAFactory';
|
|
5
|
-
export { ITacSmartAccount } from './internal/typechain-types/contracts/smart-account/interfaces/ITacSmartAccount';
|
|
6
|
-
export { IERC20WithDecimals } from './internal/typechain-types/contracts/interfaces/tokens/IERC20WithDecimals';
|
|
7
|
-
export { IERC721 } from './internal/typechain-types/@openzeppelin/contracts/token/ERC721/IERC721';
|
|
8
5
|
export { ICrossChainLayerERC20 } from './internal/typechain-types/contracts/interfaces/tokens/ICrossChainLayerERC20';
|
|
9
6
|
export { ICrossChainLayerERC721 } from './internal/typechain-types/contracts/interfaces/tokens/ICrossChainLayerERC721';
|
|
7
|
+
export { IERC20WithDecimals } from './internal/typechain-types/contracts/interfaces/tokens/IERC20WithDecimals';
|
|
8
|
+
export { ISAFactory } from './internal/typechain-types/contracts/smart-account/interfaces/ISAFactory';
|
|
9
|
+
export { ITacSmartAccount } from './internal/typechain-types/contracts/smart-account/interfaces/ITacSmartAccount';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Dev from './dev';
|
|
2
|
-
import type * as Testnet from './testnet';
|
|
3
2
|
import type * as Mainnet from './mainnet';
|
|
3
|
+
import type * as Testnet from './testnet';
|
|
4
4
|
export type MsgType = Dev.ton.wrappers.MsgType | Testnet.ton.wrappers.MsgType | Mainnet.ton.wrappers.MsgType;
|
|
5
5
|
export type CrossChainLayer = Dev.ton.wrappers.CrossChainLayer | Testnet.ton.wrappers.CrossChainLayer | Mainnet.ton.wrappers.CrossChainLayer;
|
|
6
6
|
export type CrossChainLayerData = Dev.ton.wrappers.CrossChainLayerConfig | Testnet.ton.wrappers.CrossChainLayerConfig | Mainnet.ton.wrappers.CrossChainLayerConfig;
|
|
@@ -50,7 +50,9 @@ function intToIP(int) {
|
|
|
50
50
|
return part4 + '.' + part3 + '.' + part2 + '.' + part1;
|
|
51
51
|
}
|
|
52
52
|
async function getDefaultLiteServers(network) {
|
|
53
|
-
const url = network === Struct_1.Network.TESTNET || network === Struct_1.Network.DEV
|
|
53
|
+
const url = network === Struct_1.Network.TESTNET || network === Struct_1.Network.DEV
|
|
54
|
+
? artifacts_1.testnet.DEFAULT_LITESERVERS
|
|
55
|
+
: artifacts_1.mainnet.DEFAULT_LITESERVERS;
|
|
54
56
|
const resp = await fetch(url);
|
|
55
57
|
const liteClients = await resp.json();
|
|
56
58
|
return liteClients.liteservers;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Interface } from 'ethers';
|
|
2
|
+
export declare class AbiHandler {
|
|
3
|
+
contractInterfaces: Map<string, Interface>;
|
|
4
|
+
/**
|
|
5
|
+
* Add a contract interface for encoding function calls
|
|
6
|
+
* Supports both human-readable ABI strings and generated ABI JSON objects
|
|
7
|
+
* @param address - The address of the contract to add interface for
|
|
8
|
+
* @param abi - The abi of the contract to add interface for
|
|
9
|
+
* @returns The sdk instance
|
|
10
|
+
*/
|
|
11
|
+
addContractInterface(address: string, abi: string | any[]): this;
|
|
12
|
+
/**
|
|
13
|
+
* Parse ABI - handles both human-readable strings and generated ABI JSON objects
|
|
14
|
+
* Extracts only function definitions from JSON ABI
|
|
15
|
+
*/
|
|
16
|
+
private _parseAbi;
|
|
17
|
+
/**
|
|
18
|
+
* Build human-readable function signature from JSON ABI function object
|
|
19
|
+
* @param func - The function to build signature for
|
|
20
|
+
* @returns The signature of the function
|
|
21
|
+
*/
|
|
22
|
+
private _buildFunctionSignature;
|
|
23
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbiHandler = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
class AbiHandler {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.contractInterfaces = new Map();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Add a contract interface for encoding function calls
|
|
11
|
+
* Supports both human-readable ABI strings and generated ABI JSON objects
|
|
12
|
+
* @param address - The address of the contract to add interface for
|
|
13
|
+
* @param abi - The abi of the contract to add interface for
|
|
14
|
+
* @returns The sdk instance
|
|
15
|
+
*/
|
|
16
|
+
addContractInterface(address, abi) {
|
|
17
|
+
const parsedAbi = this._parseAbi(abi);
|
|
18
|
+
this.contractInterfaces.set(address.toLowerCase(), new ethers_1.Interface(parsedAbi));
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse ABI - handles both human-readable strings and generated ABI JSON objects
|
|
23
|
+
* Extracts only function definitions from JSON ABI
|
|
24
|
+
*/
|
|
25
|
+
_parseAbi(abi) {
|
|
26
|
+
const humanReadableAbi = [];
|
|
27
|
+
for (const item of abi) {
|
|
28
|
+
// If it's already a string (human-readable format), keep it
|
|
29
|
+
if (typeof item === 'string') {
|
|
30
|
+
humanReadableAbi.push(item);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
// If it's a JSON ABI object, parse it
|
|
34
|
+
if (typeof item === 'object' && item.type) {
|
|
35
|
+
// Only process functions
|
|
36
|
+
if (item.type === 'function') {
|
|
37
|
+
const signature = this._buildFunctionSignature(item);
|
|
38
|
+
if (signature) {
|
|
39
|
+
humanReadableAbi.push(signature);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Skip events, errors, constructor, etc.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return humanReadableAbi;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build human-readable function signature from JSON ABI function object
|
|
49
|
+
* @param func - The function to build signature for
|
|
50
|
+
* @returns The signature of the function
|
|
51
|
+
*/
|
|
52
|
+
_buildFunctionSignature(func) {
|
|
53
|
+
if (!func.name || !Array.isArray(func.inputs)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
// Build parameter list
|
|
57
|
+
const params = func.inputs
|
|
58
|
+
.map((input) => {
|
|
59
|
+
let paramType = input.type;
|
|
60
|
+
// Handle array types
|
|
61
|
+
if (input.type.includes('[]')) {
|
|
62
|
+
paramType = input.type;
|
|
63
|
+
}
|
|
64
|
+
// Add parameter name if available
|
|
65
|
+
if (input.name) {
|
|
66
|
+
return `${paramType} ${input.name}`;
|
|
67
|
+
}
|
|
68
|
+
return paramType;
|
|
69
|
+
})
|
|
70
|
+
.join(', ');
|
|
71
|
+
// Build return types if available
|
|
72
|
+
let returnTypes = '';
|
|
73
|
+
if (func.outputs && func.outputs.length > 0) {
|
|
74
|
+
const outputs = func.outputs
|
|
75
|
+
.map((output) => {
|
|
76
|
+
const outputType = output.type;
|
|
77
|
+
if (output.name) {
|
|
78
|
+
return `${outputType} ${output.name}`;
|
|
79
|
+
}
|
|
80
|
+
return outputType;
|
|
81
|
+
})
|
|
82
|
+
.join(', ');
|
|
83
|
+
if (func.outputs.length === 1) {
|
|
84
|
+
returnTypes = ` returns (${outputs})`;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
returnTypes = ` returns (${outputs})`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Build full signature
|
|
91
|
+
const stateMutability = func.stateMutability || 'nonpayable';
|
|
92
|
+
let mutabilityKeyword = '';
|
|
93
|
+
if (stateMutability === 'view') {
|
|
94
|
+
mutabilityKeyword = ' view';
|
|
95
|
+
}
|
|
96
|
+
else if (stateMutability === 'pure') {
|
|
97
|
+
mutabilityKeyword = ' pure';
|
|
98
|
+
}
|
|
99
|
+
else if (stateMutability === 'payable') {
|
|
100
|
+
mutabilityKeyword = ' payable';
|
|
101
|
+
}
|
|
102
|
+
return `function ${func.name}(${params})${mutabilityKeyword} external${returnTypes}`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.AbiHandler = AbiHandler;
|
|
@@ -1,139 +1,18 @@
|
|
|
1
|
-
import { Network } from
|
|
2
|
-
|
|
3
|
-
* NFTData is a struct that contains the nft, id, and amount of the nft
|
|
4
|
-
* @param nft - The address of the nft
|
|
5
|
-
* @param id - The id of the nft
|
|
6
|
-
* @param amount - The amount of the nft to transfer(for ERC1155, but currently supported only ERC721)
|
|
7
|
-
*/
|
|
8
|
-
export interface NFTData {
|
|
9
|
-
nft: string;
|
|
10
|
-
id: bigint;
|
|
11
|
-
amount: bigint;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* BridgeData is a struct that contains the tokens, nfts, and isRequired of the bridge data
|
|
15
|
-
* @param tokens - The addresses of the tokens to bridge
|
|
16
|
-
* @param nfts - The nfts to bridge
|
|
17
|
-
* @param isRequired - Whether the bridge is required
|
|
18
|
-
*/
|
|
19
|
-
export interface BridgeData {
|
|
20
|
-
tokens: string[];
|
|
21
|
-
nfts: NFTData[];
|
|
22
|
-
isRequired: boolean;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* HookType is an enum that contains the type of the hook
|
|
26
|
-
* @param Custom - The custom hook
|
|
27
|
-
* @param FullBalanceApprove - The full balance approve hook
|
|
28
|
-
* @param FullBalanceTransfer - The full balance transfer hook
|
|
29
|
-
*/
|
|
30
|
-
export declare enum HookType {
|
|
31
|
-
Custom = 0,
|
|
32
|
-
FullBalanceApprove = 1,
|
|
33
|
-
FullBalanceTransfer = 2
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* ReplacementType is an enum that contains the type of the replacement
|
|
37
|
-
* @param Amount - The amount replacement
|
|
38
|
-
*/
|
|
39
|
-
export declare enum ReplacementType {
|
|
40
|
-
Amount = 0
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* AmountChange is a struct that contains the position, length, token, and balance address of the amount change
|
|
44
|
-
* @param position - The position of the amount change(position of the parameter in the function call)
|
|
45
|
-
* @param len - The length of the amount change(length of the parameter in the function call)
|
|
46
|
-
* @param token - The token of the amount change
|
|
47
|
-
* @param balanceAddress - The balance address of the amount change(address to check balance for)
|
|
48
|
-
*/
|
|
49
|
-
export interface AmountChange {
|
|
50
|
-
position: number;
|
|
51
|
-
len: number;
|
|
52
|
-
token: string;
|
|
53
|
-
balanceAddress: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* CustomHookData is a struct that contains the isFromSAPerspective, contractAddress, value, data, and improvedMissionInfo of the custom hook
|
|
57
|
-
* @param isFromSAPerspective - Whether the hook is from the smart account perspective or from proxy perspective
|
|
58
|
-
* @param contractAddress - The address of the contract to call
|
|
59
|
-
* @param value - The value of the hook
|
|
60
|
-
* @param data - The data of the hook
|
|
61
|
-
* @param improvedMissionInfo - The improved mission info of the hook
|
|
62
|
-
*/
|
|
63
|
-
export interface CustomHookData {
|
|
64
|
-
isFromSAPerspective: boolean;
|
|
65
|
-
contractAddress: string;
|
|
66
|
-
value: bigint;
|
|
67
|
-
data: string;
|
|
68
|
-
improvedMissionInfo: string;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* ApproveHookData is a struct that contains the token, to, and isFromSAPerspective of the approve hook
|
|
72
|
-
* @param token - The token to approve
|
|
73
|
-
* @param to - The address to approve to
|
|
74
|
-
* @param isFromSAPerspective - Whether the hook is from the smart account perspective or from proxy perspective
|
|
75
|
-
*/
|
|
76
|
-
export interface ApproveHookData {
|
|
77
|
-
token: string;
|
|
78
|
-
to: string;
|
|
79
|
-
isFromSAPerspective: boolean;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* TransferHookData is a struct that contains the token, to, and isFromSAPerspective of the transfer hook
|
|
83
|
-
* @param token - The token to transfer
|
|
84
|
-
* @param to - The address to transfer to
|
|
85
|
-
* @param isFromSAPerspective - Whether the hook is from the smart account perspective or from proxy perspective
|
|
86
|
-
*/
|
|
87
|
-
export interface TransferHookData {
|
|
88
|
-
token: string;
|
|
89
|
-
to: string;
|
|
90
|
-
isFromSAPerspective: boolean;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Hook is a struct that contains the hookType and hookData of the hook
|
|
94
|
-
* @param hookType - The type of the hook
|
|
95
|
-
* @param hookData - The data of the hook
|
|
96
|
-
*/
|
|
97
|
-
export interface Hook {
|
|
98
|
-
hookType: HookType;
|
|
99
|
-
hookData: string;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* ZapCall is a struct that contains the hooks and bridgeData of the zap call
|
|
103
|
-
* @param hooks - The hooks of the zap call
|
|
104
|
-
* @param bridgeData - The bridge data of the zap call
|
|
105
|
-
*/
|
|
106
|
-
export interface ZapCall {
|
|
107
|
-
hooks: Hook[];
|
|
108
|
-
bridgeData: BridgeData;
|
|
109
|
-
}
|
|
1
|
+
import { Network } from '../structs/Struct';
|
|
2
|
+
import { AmountChange, Hook, NFTData, ZapCall } from './AgnosticStructs';
|
|
110
3
|
/**
|
|
111
4
|
* SDK for building AgnosticProxy Zap calls with efficient hook encoding
|
|
5
|
+
* @param network - The network to use (MAINNET || TESTNET || DEV)
|
|
112
6
|
* @param agnosticProxyAddress - The address of the agnostic proxy(optional)
|
|
113
7
|
*/
|
|
114
8
|
export declare class AgnosticProxySDK {
|
|
115
|
-
private contractInterfaces;
|
|
116
9
|
private agnosticProxyAddress;
|
|
10
|
+
private abiHandler;
|
|
11
|
+
private replacementHelper;
|
|
12
|
+
private hooksHandler;
|
|
13
|
+
private debugHelpers;
|
|
117
14
|
constructor(network: Network, agnosticProxyAddress?: string);
|
|
118
|
-
|
|
119
|
-
* Add a contract interface for encoding function calls
|
|
120
|
-
* Supports both human-readable ABI strings and generated ABI JSON objects
|
|
121
|
-
* @param address - The address of the contract to add interface for
|
|
122
|
-
* @param abi - The abi of the contract to add interface for
|
|
123
|
-
* @returns The sdk instance
|
|
124
|
-
*/
|
|
125
|
-
addContractInterface(address: string, abi: any[]): this;
|
|
126
|
-
/**
|
|
127
|
-
* Parse ABI - handles both human-readable strings and generated ABI JSON objects
|
|
128
|
-
* Extracts only function definitions from JSON ABI
|
|
129
|
-
*/
|
|
130
|
-
private _parseAbi;
|
|
131
|
-
/**
|
|
132
|
-
* Build human-readable function signature from JSON ABI function object
|
|
133
|
-
* @param func - The function to build signature for
|
|
134
|
-
* @returns The signature of the function
|
|
135
|
-
*/
|
|
136
|
-
private _buildFunctionSignature;
|
|
15
|
+
addContractInterface(address: string, abi: string | any[]): this;
|
|
137
16
|
/**
|
|
138
17
|
* Create a custom hook with optional dynamic value replacement
|
|
139
18
|
* @param contractAddress - The address of the contract to call
|
|
@@ -163,6 +42,31 @@ export declare class AgnosticProxySDK {
|
|
|
163
42
|
* @returns The full balance transfer hook
|
|
164
43
|
*/
|
|
165
44
|
createFullBalanceTransferHook(token: string, to: string, isFromSAPerspective?: boolean): Hook;
|
|
45
|
+
/**
|
|
46
|
+
* Utility: Create multiple approve hooks at once
|
|
47
|
+
* @param approvals - The approvals to create
|
|
48
|
+
* @returns The multiple approve hooks
|
|
49
|
+
*/
|
|
50
|
+
createMultipleApproves(approvals: {
|
|
51
|
+
token: string;
|
|
52
|
+
spender: string;
|
|
53
|
+
isFromSA?: boolean;
|
|
54
|
+
}[]): Hook[];
|
|
55
|
+
/**
|
|
56
|
+
* Utility: Create a sequence of custom hooks
|
|
57
|
+
* @param calls - The calls to create
|
|
58
|
+
* @returns The hook sequence
|
|
59
|
+
*/
|
|
60
|
+
createHookSequence(calls: {
|
|
61
|
+
contract: string;
|
|
62
|
+
functionName: string;
|
|
63
|
+
params: any[];
|
|
64
|
+
options?: {
|
|
65
|
+
isFromSAPerspective?: boolean;
|
|
66
|
+
value?: bigint;
|
|
67
|
+
dynamicReplacements?: AmountChange[];
|
|
68
|
+
};
|
|
69
|
+
}[]): Hook[];
|
|
166
70
|
/**
|
|
167
71
|
* Helper to create dynamic amount replacement for a specific parameter
|
|
168
72
|
* @param paramIndex - The index of the parameter to replace
|
|
@@ -236,64 +140,6 @@ export declare class AgnosticProxySDK {
|
|
|
236
140
|
suggestions: string[];
|
|
237
141
|
};
|
|
238
142
|
};
|
|
239
|
-
/**
|
|
240
|
-
* Private helper to calculate position and length for complex parameter types
|
|
241
|
-
* @param inputs - The inputs of the function
|
|
242
|
-
* @param targetIndex - The index of the parameter to calculate the position and length for
|
|
243
|
-
* @returns The position and length of the parameter
|
|
244
|
-
*/
|
|
245
|
-
private _calculateParamPositionAndLength;
|
|
246
|
-
/**
|
|
247
|
-
* Get the size in bytes for a parameter type
|
|
248
|
-
* @param type - The type of the parameter
|
|
249
|
-
* @returns The size in bytes of the parameter
|
|
250
|
-
*/
|
|
251
|
-
private _getTypeSize;
|
|
252
|
-
/**
|
|
253
|
-
* Check if a parameter type can be replaced with a balance
|
|
254
|
-
* @param type - The type of the parameter
|
|
255
|
-
* @returns The can replace and reason of the parameter
|
|
256
|
-
*/
|
|
257
|
-
private _canParameterBeReplaced;
|
|
258
|
-
/**
|
|
259
|
-
* Build a complete ZapCall
|
|
260
|
-
* @param hooks - The hooks of the zap call
|
|
261
|
-
* @param bridgeTokens - The tokens to bridge
|
|
262
|
-
* @param bridgeNFTs - The nfts to bridge
|
|
263
|
-
* @returns The zap call
|
|
264
|
-
*/
|
|
265
|
-
buildZapCall(hooks: Hook[], bridgeTokens?: string[], bridgeNFTs?: NFTData[]): ZapCall;
|
|
266
|
-
/**
|
|
267
|
-
* Encode ZapCall for transaction - Much more efficient now!
|
|
268
|
-
* @param zapCall - The zap call to encode
|
|
269
|
-
* @returns The encoded zap call that can be used as calldata in tac sdk
|
|
270
|
-
*/
|
|
271
|
-
encodeZapCall(zapCall: ZapCall): string;
|
|
272
|
-
/**
|
|
273
|
-
* Utility: Create multiple approve hooks at once
|
|
274
|
-
* @param approvals - The approvals to create
|
|
275
|
-
* @returns The multiple approve hooks
|
|
276
|
-
*/
|
|
277
|
-
createMultipleApproves(approvals: {
|
|
278
|
-
token: string;
|
|
279
|
-
spender: string;
|
|
280
|
-
isFromSA?: boolean;
|
|
281
|
-
}[]): Hook[];
|
|
282
|
-
/**
|
|
283
|
-
* Utility: Create a sequence of custom hooks
|
|
284
|
-
* @param calls - The calls to create
|
|
285
|
-
* @returns The hook sequence
|
|
286
|
-
*/
|
|
287
|
-
createHookSequence(calls: {
|
|
288
|
-
contract: string;
|
|
289
|
-
functionName: string;
|
|
290
|
-
params: any[];
|
|
291
|
-
options?: {
|
|
292
|
-
isFromSAPerspective?: boolean;
|
|
293
|
-
value?: bigint;
|
|
294
|
-
dynamicReplacements?: AmountChange[];
|
|
295
|
-
};
|
|
296
|
-
}[]): Hook[];
|
|
297
143
|
/**
|
|
298
144
|
* Debug helper: Decode hook data back to readable format
|
|
299
145
|
* @param hook - The hook to decode
|
|
@@ -311,36 +157,6 @@ export declare class AgnosticProxySDK {
|
|
|
311
157
|
* @param zapCall - The zap call to visualize
|
|
312
158
|
*/
|
|
313
159
|
visualizeZapCall(zapCall: ZapCall): void;
|
|
314
|
-
/**
|
|
315
|
-
* Private helper to describe individual hooks
|
|
316
|
-
* @param hook - The hook to describe
|
|
317
|
-
* @returns The description of the hook
|
|
318
|
-
*/
|
|
319
|
-
private _describeHook;
|
|
320
|
-
/**
|
|
321
|
-
* Describe custom hook with function details
|
|
322
|
-
* @param hook - The hook to describe
|
|
323
|
-
* @returns The description of the hook
|
|
324
|
-
*/
|
|
325
|
-
private _describeCustomHook;
|
|
326
|
-
/**
|
|
327
|
-
* Describe approve hook
|
|
328
|
-
* @param hook - The hook to describe
|
|
329
|
-
* @returns The description of the hook
|
|
330
|
-
*/
|
|
331
|
-
private _describeApproveHook;
|
|
332
|
-
/**
|
|
333
|
-
* Describe transfer hook
|
|
334
|
-
* @param hook - The hook to describe
|
|
335
|
-
* @returns The description of the hook
|
|
336
|
-
*/
|
|
337
|
-
private _describeTransferHook;
|
|
338
|
-
/**
|
|
339
|
-
* Format address for display (show first 6 and last 4 characters)
|
|
340
|
-
* @param address - The address to format
|
|
341
|
-
* @returns The formatted address
|
|
342
|
-
*/
|
|
343
|
-
private _formatAddress;
|
|
344
160
|
/**
|
|
345
161
|
* Get a detailed breakdown of a ZapCall for logging
|
|
346
162
|
* @param zapCall - The zap call to get the breakdown for
|
|
@@ -368,4 +184,18 @@ export declare class AgnosticProxySDK {
|
|
|
368
184
|
evmTargetAddress: string;
|
|
369
185
|
methodName: string;
|
|
370
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* Build a complete ZapCall
|
|
189
|
+
* @param hooks - The hooks of the zap call
|
|
190
|
+
* @param bridgeTokens - The tokens to bridge
|
|
191
|
+
* @param bridgeNFTs - The nfts to bridge
|
|
192
|
+
* @returns The zap call
|
|
193
|
+
*/
|
|
194
|
+
buildZapCall(hooks: Hook[], bridgeTokens?: string[], bridgeNFTs?: NFTData[]): ZapCall;
|
|
195
|
+
/**
|
|
196
|
+
* Encode ZapCall for transaction
|
|
197
|
+
* @param zapCall - The zap call to encode
|
|
198
|
+
* @returns The encoded zap call that can be used as calldata in tac sdk
|
|
199
|
+
*/
|
|
200
|
+
encodeZapCall(zapCall: ZapCall): string;
|
|
371
201
|
}
|