@iota/isc-sdk 0.0.0-dev-20251015065834
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/.prettierignore +2 -0
- package/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +81 -0
- package/LICENSE +201 -0
- package/README.md +88 -0
- package/dist/cjs/api/EvmRpcClient.d.ts +7 -0
- package/dist/cjs/api/EvmRpcClient.js +57 -0
- package/dist/cjs/api/EvmRpcClient.js.map +7 -0
- package/dist/cjs/api/index.d.ts +1 -0
- package/dist/cjs/api/index.js +19 -0
- package/dist/cjs/api/index.js.map +7 -0
- package/dist/cjs/bcs.d.ts +944 -0
- package/dist/cjs/bcs.js +260 -0
- package/dist/cjs/bcs.js.map +7 -0
- package/dist/cjs/constants.d.ts +2 -0
- package/dist/cjs/constants.js +27 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/enums/contracts.enums.d.ts +76 -0
- package/dist/cjs/enums/contracts.enums.js +113 -0
- package/dist/cjs/enums/contracts.enums.js.map +7 -0
- package/dist/cjs/enums/index.d.ts +1 -0
- package/dist/cjs/enums/index.js +19 -0
- package/dist/cjs/enums/index.js.map +7 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.js +27 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/isc.d.ts +26 -0
- package/dist/cjs/isc.js +220 -0
- package/dist/cjs/isc.js.map +7 -0
- package/dist/cjs/move_bcs.d.ts +124 -0
- package/dist/cjs/move_bcs.js +70 -0
- package/dist/cjs/move_bcs.js.map +7 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/transaction.d.ts +168 -0
- package/dist/cjs/transaction.js +328 -0
- package/dist/cjs/transaction.js.map +7 -0
- package/dist/cjs/types/assetsResponse.d.ts +37 -0
- package/dist/cjs/types/assetsResponse.js +34 -0
- package/dist/cjs/types/assetsResponse.js.map +7 -0
- package/dist/cjs/types/chainData.d.ts +12 -0
- package/dist/cjs/types/chainData.js +29 -0
- package/dist/cjs/types/chainData.js.map +7 -0
- package/dist/cjs/types/index.d.ts +2 -0
- package/dist/cjs/types/index.js +20 -0
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/utils/getHname.d.ts +1 -0
- package/dist/cjs/utils/getHname.js +30 -0
- package/dist/cjs/utils/getHname.js.map +7 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +19 -0
- package/dist/cjs/utils/index.js.map +7 -0
- package/dist/cjs/vite-env.d.js +2 -0
- package/dist/cjs/vite-env.d.js.map +7 -0
- package/dist/esm/api/EvmRpcClient.d.ts +7 -0
- package/dist/esm/api/EvmRpcClient.js +37 -0
- package/dist/esm/api/EvmRpcClient.js.map +7 -0
- package/dist/esm/api/index.d.ts +1 -0
- package/dist/esm/api/index.js +2 -0
- package/dist/esm/api/index.js.map +7 -0
- package/dist/esm/bcs.d.ts +944 -0
- package/dist/esm/bcs.js +240 -0
- package/dist/esm/bcs.js.map +7 -0
- package/dist/esm/constants.d.ts +2 -0
- package/dist/esm/constants.js +7 -0
- package/dist/esm/constants.js.map +7 -0
- package/dist/esm/enums/contracts.enums.d.ts +76 -0
- package/dist/esm/enums/contracts.enums.js +93 -0
- package/dist/esm/enums/contracts.enums.js.map +7 -0
- package/dist/esm/enums/index.d.ts +1 -0
- package/dist/esm/enums/index.js +2 -0
- package/dist/esm/enums/index.js.map +7 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/isc.d.ts +26 -0
- package/dist/esm/isc.js +200 -0
- package/dist/esm/isc.js.map +7 -0
- package/dist/esm/move_bcs.d.ts +124 -0
- package/dist/esm/move_bcs.js +50 -0
- package/dist/esm/move_bcs.js.map +7 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/transaction.d.ts +168 -0
- package/dist/esm/transaction.js +298 -0
- package/dist/esm/transaction.js.map +7 -0
- package/dist/esm/types/assetsResponse.d.ts +37 -0
- package/dist/esm/types/assetsResponse.js +14 -0
- package/dist/esm/types/assetsResponse.js.map +7 -0
- package/dist/esm/types/chainData.d.ts +12 -0
- package/dist/esm/types/chainData.js +9 -0
- package/dist/esm/types/chainData.js.map +7 -0
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/types/index.js +3 -0
- package/dist/esm/types/index.js.map +7 -0
- package/dist/esm/utils/getHname.d.ts +1 -0
- package/dist/esm/utils/getHname.js +10 -0
- package/dist/esm/utils/getHname.js.map +7 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +2 -0
- package/dist/esm/utils/index.js.map +7 -0
- package/dist/esm/vite-env.d.js +10 -0
- package/dist/esm/vite-env.d.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/examples/L1AddressL2funds.ts +72 -0
- package/examples/anchor.ts +72 -0
- package/examples/assetsBag.ts +61 -0
- package/examples/config.ts +81 -0
- package/examples/tokens.ts +96 -0
- package/package.json +57 -0
- package/src/api/EvmRpcClient.ts +48 -0
- package/src/api/index.ts +1 -0
- package/src/bcs.ts +237 -0
- package/src/constants.ts +4 -0
- package/src/enums/contracts.enums.ts +82 -0
- package/src/enums/index.ts +1 -0
- package/src/index.ts +9 -0
- package/src/isc.ts +331 -0
- package/src/move_bcs.ts +47 -0
- package/src/transaction.ts +380 -0
- package/src/types/assetsResponse.ts +13 -0
- package/src/types/chainData.ts +8 -0
- package/src/types/index.ts +2 -0
- package/src/utils/getHname.ts +11 -0
- package/src/utils/index.ts +1 -0
- package/src/vite-env.d.ts +1 -0
- package/tests/L1ToL2Tokens.spec.ts +141 -0
- package/tests/config.ts +81 -0
- package/tests/getHname.spec.ts +78 -0
- package/tests/utils.ts +69 -0
- package/tsconfig.esm.json +7 -0
- package/tsconfig.json +11 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountsContractMethod,
|
|
3
|
+
CoreContract,
|
|
4
|
+
EvmRpcClient,
|
|
5
|
+
getHname,
|
|
6
|
+
IscTransaction,
|
|
7
|
+
L2_FROM_L1_GAS_BUDGET,
|
|
8
|
+
} from '../src/index.js';
|
|
9
|
+
import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils';
|
|
10
|
+
import { Ed25519Keypair } from '@iota/iota-sdk/keypairs/ed25519';
|
|
11
|
+
import { IotaClient } from '@iota/iota-sdk/client';
|
|
12
|
+
import { CONFIG } from './config.js';
|
|
13
|
+
import { bcs } from '@iota/iota-sdk/bcs';
|
|
14
|
+
|
|
15
|
+
const { L1, L2 } = CONFIG;
|
|
16
|
+
|
|
17
|
+
const client = new IotaClient({
|
|
18
|
+
url: L1.rpcUrl,
|
|
19
|
+
});
|
|
20
|
+
const evmRpcClient = new EvmRpcClient(L2.evmRpcUrl);
|
|
21
|
+
|
|
22
|
+
const MNEMONIC =
|
|
23
|
+
'mom program scrap easily doctor seed slender secret mad flat foam hospital cherry seek river you obscure column blood reflect arch pencil cat burst';
|
|
24
|
+
const TOKEN_COIN_TYPE =
|
|
25
|
+
'0xe1e88f4962b3ea96cfad19aee42f666b04bbce4dc4327c3cd63f1b8ff16e13b2::tool_coin::TOOL_COIN';
|
|
26
|
+
|
|
27
|
+
const keypair = Ed25519Keypair.deriveKeypair(MNEMONIC);
|
|
28
|
+
const address = keypair.toIotaAddress();
|
|
29
|
+
|
|
30
|
+
// EVM Address
|
|
31
|
+
const recipientAddress = process.argv[2];
|
|
32
|
+
|
|
33
|
+
if (!recipientAddress) {
|
|
34
|
+
console.error('Please provide a recipient address as an argument');
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Amount to send (0.01 IOTAs)
|
|
39
|
+
const amountToSend = BigInt(1 * 1_000_000);
|
|
40
|
+
// Amount to send (1 Boxfish)
|
|
41
|
+
const tokenAmountToSend = BigInt(1);
|
|
42
|
+
// We also need to place a little more in the bag to cover the L2 gas
|
|
43
|
+
const amountToPlace = amountToSend + L2_FROM_L1_GAS_BUDGET;
|
|
44
|
+
|
|
45
|
+
console.log('Sending...');
|
|
46
|
+
|
|
47
|
+
const iscTx = new IscTransaction(L1);
|
|
48
|
+
const tx = iscTx.transaction();
|
|
49
|
+
|
|
50
|
+
const bag = iscTx.newBag();
|
|
51
|
+
|
|
52
|
+
// Place IOTA
|
|
53
|
+
const iotaCoin = iscTx.coinFromAmount({ amount: amountToPlace });
|
|
54
|
+
iscTx.placeCoinInBag({ coin: iotaCoin, bag, coinType: IOTA_TYPE_ARG });
|
|
55
|
+
|
|
56
|
+
// Place Token
|
|
57
|
+
const tokenCoin = tx.splitCoins(
|
|
58
|
+
tx.object('0xf7662ffd9cb079d8e75ab4805ba78fdb0e0fb78cf49aa0fa01ecb7ebdf15d04e'),
|
|
59
|
+
[tx.pure(bcs.U64.serialize(tokenAmountToSend))],
|
|
60
|
+
);
|
|
61
|
+
iscTx.placeCoinInBag({
|
|
62
|
+
bag,
|
|
63
|
+
coin: tokenCoin,
|
|
64
|
+
coinType: TOKEN_COIN_TYPE,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
iscTx.createAndSendToEvm({
|
|
68
|
+
bag,
|
|
69
|
+
transfers: [
|
|
70
|
+
[IOTA_TYPE_ARG, amountToSend],
|
|
71
|
+
[TOKEN_COIN_TYPE, tokenAmountToSend],
|
|
72
|
+
],
|
|
73
|
+
address: recipientAddress,
|
|
74
|
+
accountsContract: getHname(CoreContract.Accounts),
|
|
75
|
+
accountsFunction: getHname(AccountsContractMethod.TransferAllowanceTo),
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const transaction = iscTx.build();
|
|
79
|
+
transaction.setSender(address);
|
|
80
|
+
|
|
81
|
+
await transaction.build({ client });
|
|
82
|
+
|
|
83
|
+
const { digest } = await client.signAndExecuteTransaction({
|
|
84
|
+
signer: keypair,
|
|
85
|
+
transaction,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
await client.waitForTransaction({
|
|
89
|
+
digest,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
console.log('Sent!');
|
|
93
|
+
|
|
94
|
+
const l1BalanceInL2 = await evmRpcClient.getBalanceBaseToken(address);
|
|
95
|
+
|
|
96
|
+
console.log(`L2 balance of the L1 address ${address}: ${JSON.stringify(l1BalanceInL2)}`);
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iota/isc-sdk",
|
|
3
|
+
"author": "IOTA Foundation <info@iota.org>",
|
|
4
|
+
"version": "0.0.0-dev-20251015065834",
|
|
5
|
+
"description": "ISC SDK for interacting with IOTA Smart Contracts.",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"license": "Apache-2.0",
|
|
8
|
+
"main": "./dist/cjs/index.js",
|
|
9
|
+
"module": "./dist/esm/index.js",
|
|
10
|
+
"types": "./dist/cjs/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/esm/index.js",
|
|
14
|
+
"require": "./dist/cjs/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@noble/hashes": "^1.4.0",
|
|
19
|
+
"@iota/bcs": "1.2.0",
|
|
20
|
+
"@iota/dapp-kit": "0.0.0-dev-20251015065834",
|
|
21
|
+
"@iota/iota-sdk": "0.0.0-dev-20251015065834"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^20.14.10",
|
|
25
|
+
"dotenv": "^16.4.5",
|
|
26
|
+
"ethers": "^6.13.5",
|
|
27
|
+
"tsx": "^3.12.7",
|
|
28
|
+
"typescript": "^5.5.3",
|
|
29
|
+
"vite": "^5.4.12",
|
|
30
|
+
"vite-plugin-dts": "^4.3.0",
|
|
31
|
+
"vitest": "^2.1.9",
|
|
32
|
+
"zod": "^3.21.4",
|
|
33
|
+
"@iota/build-scripts": "0.0.0"
|
|
34
|
+
},
|
|
35
|
+
"lint-staged": {
|
|
36
|
+
"src/**/*.{ts,js,mjs}": [
|
|
37
|
+
"eslint --fix",
|
|
38
|
+
"prettier --write"
|
|
39
|
+
],
|
|
40
|
+
"examples/**/*.{ts,js,mjs}": [
|
|
41
|
+
"eslint --fix",
|
|
42
|
+
"prettier --write"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
47
|
+
"build": "build-package",
|
|
48
|
+
"eslint:check": "eslint --max-warnings=0 \"./src/**/*.{js,ts}\"",
|
|
49
|
+
"eslint:fix": "pnpm eslint:check --fix",
|
|
50
|
+
"prettier:check": "prettier -c --ignore-unknown --ignore-path=.prettierignore .",
|
|
51
|
+
"prettier:fix": "prettier -w --ignore-unknown --ignore-path=.prettierignore .",
|
|
52
|
+
"lint": "pnpm eslint:check && pnpm prettier:check",
|
|
53
|
+
"lint:fix": "pnpm eslint:fix && pnpm prettier:fix",
|
|
54
|
+
"run:example": "tsx",
|
|
55
|
+
"test": "vitest"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { AssetsResponse } from '../types/index.js';
|
|
2
|
+
|
|
3
|
+
export class EvmRpcClient {
|
|
4
|
+
public baseUrl: string;
|
|
5
|
+
|
|
6
|
+
constructor(baseUrl?: string) {
|
|
7
|
+
if (!baseUrl) {
|
|
8
|
+
throw new Error('Base URL for EVM rpc is required.');
|
|
9
|
+
}
|
|
10
|
+
// Normalize baseUrl by removing any trailing slash in the end
|
|
11
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private async request<T>(
|
|
15
|
+
endpoint: string,
|
|
16
|
+
options?: RequestInit,
|
|
17
|
+
params?: Record<string, string | number | undefined>,
|
|
18
|
+
): Promise<T> {
|
|
19
|
+
const url = new URL(`${this.baseUrl}${endpoint}`);
|
|
20
|
+
|
|
21
|
+
if (params) {
|
|
22
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
23
|
+
if (value !== undefined) {
|
|
24
|
+
url.searchParams.append(key, value.toString());
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const response = await fetch(url, {
|
|
30
|
+
...(options ?? {}),
|
|
31
|
+
headers: {
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
...(options?.headers || {}),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
const errorText = await response.text();
|
|
39
|
+
throw new Error(`API Error: ${response.status} ${response.statusText} - ${errorText}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return response.json() as T;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public getBalanceBaseToken = async (address: string): Promise<AssetsResponse> => {
|
|
46
|
+
return this.request(`/v1/chain/core/accounts/account/${address}/balance`);
|
|
47
|
+
};
|
|
48
|
+
}
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EvmRpcClient.js';
|
package/src/bcs.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { bcs } from '@iota/iota-sdk/bcs';
|
|
2
|
+
|
|
3
|
+
export const IotagoObjectRef = bcs.struct('IotagoObjectRef', {
|
|
4
|
+
objectID: bcs.fixedArray(32, bcs.u8()),
|
|
5
|
+
version: bcs.u64(),
|
|
6
|
+
digest: bcs.vector(bcs.u8()),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const IscmoveAssetsBag = bcs.struct('IscmoveAssetsBag', {
|
|
10
|
+
iD: bcs.fixedArray(32, bcs.u8()),
|
|
11
|
+
size: bcs.u64(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export const IscAssets = bcs.struct('IscAssets', {
|
|
15
|
+
coins: bcs.map(bcs.string(), bcs.u64()),
|
|
16
|
+
objects: bcs.map(bcs.fixedArray(32, bcs.u8()), bcs.string()),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export const IscmoveReferent_AssetsBag = bcs.struct('IscmoveReferent_AssetsBag', {
|
|
20
|
+
iD: bcs.fixedArray(32, bcs.u8()),
|
|
21
|
+
value: IscmoveAssetsBag,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const IscmoveAnchor = bcs.struct('IscmoveAnchor', {
|
|
25
|
+
iD: bcs.fixedArray(32, bcs.u8()),
|
|
26
|
+
assets: IscmoveReferent_AssetsBag,
|
|
27
|
+
stateMetadata: bcs.vector(bcs.u8()),
|
|
28
|
+
stateIndex: bcs.u32(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const IscmoveRefWithObject_Anchor = bcs.struct('IscmoveRefWithObject_Anchor', {
|
|
32
|
+
objectRef: IotagoObjectRef,
|
|
33
|
+
object: IscmoveAnchor,
|
|
34
|
+
owner: bcs.fixedArray(32, bcs.u8()),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const IscStateAnchor = bcs.struct('IscStateAnchor', {
|
|
38
|
+
anchor: IscmoveRefWithObject_Anchor,
|
|
39
|
+
iscPackage: bcs.fixedArray(32, bcs.u8()),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const CoinType = bcs.struct('CoinType', {
|
|
43
|
+
s: bcs.string(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const ParametersBaseToken = bcs.struct('ParametersBaseToken', {
|
|
47
|
+
name: bcs.string(),
|
|
48
|
+
tickerSymbol: bcs.string(),
|
|
49
|
+
unit: bcs.string(),
|
|
50
|
+
subunit: bcs.string(),
|
|
51
|
+
decimals: bcs.u8(),
|
|
52
|
+
useMetricPrefix: bcs.bool(),
|
|
53
|
+
coinType: CoinType,
|
|
54
|
+
totalSupply: bcs.u64(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
export const IotajsonrpcBigInt = bcs.struct('IotajsonrpcBigInt', {
|
|
58
|
+
int: bcs.u256(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const ParametersProtocol = bcs.struct('ParametersProtocol', {
|
|
62
|
+
epoch: IotajsonrpcBigInt,
|
|
63
|
+
protocolVersion: IotajsonrpcBigInt,
|
|
64
|
+
systemStateVersion: IotajsonrpcBigInt,
|
|
65
|
+
iotaTotalSupply: IotajsonrpcBigInt,
|
|
66
|
+
referenceGasPrice: IotajsonrpcBigInt,
|
|
67
|
+
epochStartTimestampMs: IotajsonrpcBigInt,
|
|
68
|
+
epochDurationMs: IotajsonrpcBigInt,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export const ParametersL1Params = bcs.struct('ParametersL1Params', {
|
|
72
|
+
protocol: ParametersProtocol,
|
|
73
|
+
baseToken: ParametersBaseToken,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export const BlocklogBlockInfo = bcs.struct('BlocklogBlockInfo', {
|
|
77
|
+
schemaVersion: bcs.u8(),
|
|
78
|
+
blockIndex: bcs.u32(),
|
|
79
|
+
timestamp: bcs.u64(),
|
|
80
|
+
previousAnchor: IscStateAnchor,
|
|
81
|
+
l1Params: ParametersL1Params,
|
|
82
|
+
totalRequests: bcs.u16(),
|
|
83
|
+
numSuccessfulRequests: bcs.u16(),
|
|
84
|
+
numOffLedgerRequests: bcs.u16(),
|
|
85
|
+
gasBurned: bcs.u64(),
|
|
86
|
+
gasFeeCharged: bcs.u64(),
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export const IscCallTarget = bcs.struct('IscCallTarget', {
|
|
90
|
+
contract: bcs.u32(),
|
|
91
|
+
entryPoint: bcs.u32(),
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export const IscMessage = bcs.struct('IscMessage', {
|
|
95
|
+
target: IscCallTarget,
|
|
96
|
+
params: bcs.vector(bcs.vector(bcs.u8())),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export const CryptolibPublicKey = bcs.struct('CryptolibPublicKey', {
|
|
100
|
+
key: bcs.vector(bcs.u8()),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export const CryptolibSignature = bcs.struct('CryptolibSignature', {
|
|
104
|
+
signatureScheme: bcs.u8(),
|
|
105
|
+
publicKey: CryptolibPublicKey,
|
|
106
|
+
signature: bcs.fixedArray(64, bcs.u8()),
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
export const RootContractRecord = bcs.struct('RootContractRecord', {
|
|
110
|
+
name: bcs.string(),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export const LoTuple2_Hname_ContractRecord = bcs.struct('LoTuple2_Hname_ContractRecord', {
|
|
114
|
+
a: bcs.u32(),
|
|
115
|
+
b: RootContractRecord,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export const IscContractAgentID = bcs.struct('IscContractAgentID', {
|
|
119
|
+
hname: bcs.u32(),
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
export const IscEthereumAddressAgentID = bcs.struct('IscEthereumAddressAgentID', {
|
|
123
|
+
eth: bcs.fixedArray(20, bcs.u8()),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export const IscNilAgentID = bcs.struct('IscNilAgentID', {});
|
|
127
|
+
|
|
128
|
+
export const IscAddressAgentID = bcs.struct('IscAddressAgentID', {
|
|
129
|
+
a: bcs.fixedArray(32, bcs.u8()),
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export const IscAgentID = bcs.enum('IscAgentID', {
|
|
133
|
+
NoType: null,
|
|
134
|
+
AddressAgentID: IscAddressAgentID,
|
|
135
|
+
ContractAgentID: IscContractAgentID,
|
|
136
|
+
EthereumAddressAgentID: IscEthereumAddressAgentID,
|
|
137
|
+
NilAgentID: IscNilAgentID,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
export const balanceInputs = bcs.struct('balanceInputs', {
|
|
141
|
+
agentID: bcs.option(IscAgentID),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
export const balanceOutputs = bcs.struct('balanceOutputs', {
|
|
145
|
+
coinBalances: bcs.map(CoinType, bcs.u64()),
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export const balanceBaseTokenEVMInputs = bcs.struct('balanceBaseTokenEVMInputs', {
|
|
149
|
+
agentID: bcs.option(IscAgentID),
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
export const balanceBaseTokenEVMOutputs = bcs.struct('balanceBaseTokenEVMOutputs', {
|
|
153
|
+
evmBaseTokenBalance: bcs.u256(),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export const AtomicnoCopy = bcs.struct('AtomicnoCopy', {});
|
|
157
|
+
|
|
158
|
+
export const Atomicalign64 = bcs.struct('Atomicalign64', {});
|
|
159
|
+
|
|
160
|
+
export const IscEvent = bcs.struct('IscEvent', {
|
|
161
|
+
contractID: bcs.u32(),
|
|
162
|
+
topic: bcs.string(),
|
|
163
|
+
timestamp: bcs.u64(),
|
|
164
|
+
payload: bcs.vector(bcs.u8()),
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
export const UtilRatio32 = bcs.struct('UtilRatio32', {
|
|
168
|
+
a: bcs.u32(),
|
|
169
|
+
b: bcs.u32(),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
export const GasFeePolicy = bcs.struct('GasFeePolicy', {
|
|
173
|
+
eVMGasRatio: UtilRatio32,
|
|
174
|
+
gasPerToken: UtilRatio32,
|
|
175
|
+
validatorFeeShare: bcs.u8(),
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export const GasLimits = bcs.struct('GasLimits', {
|
|
179
|
+
maxGasPerBlock: bcs.u64(),
|
|
180
|
+
minGasPerRequest: bcs.u64(),
|
|
181
|
+
maxGasPerRequest: bcs.u64(),
|
|
182
|
+
maxGasExternalViewCall: bcs.u64(),
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
export const IscPublicChainMetadata = bcs.struct('IscPublicChainMetadata', {
|
|
186
|
+
eVMJsonRPCURL: bcs.string(),
|
|
187
|
+
eVMWebSocketURL: bcs.string(),
|
|
188
|
+
name: bcs.string(),
|
|
189
|
+
description: bcs.string(),
|
|
190
|
+
website: bcs.string(),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
export const IscChainInfo = bcs.struct('IscChainInfo', {
|
|
194
|
+
chainID: bcs.fixedArray(32, bcs.u8()),
|
|
195
|
+
chainOwnerID: IscAgentID,
|
|
196
|
+
gasFeePolicy: GasFeePolicy,
|
|
197
|
+
gasLimits: GasLimits,
|
|
198
|
+
blockKeepAmount: bcs.bytes(4),
|
|
199
|
+
publicURL: bcs.string(),
|
|
200
|
+
metadata: IscPublicChainMetadata,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
export const IscVMErrorCode = bcs.struct('IscVMErrorCode', {
|
|
204
|
+
contractID: bcs.u32(),
|
|
205
|
+
iD: bcs.u16(),
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
export const GasBurnRecord = bcs.struct('GasBurnRecord', {
|
|
209
|
+
code: bcs.u16(),
|
|
210
|
+
gasBurned: bcs.u64(),
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
export const IscVMErrorParam = bcs.enum('IscVMErrorParam', {
|
|
214
|
+
NoType: null,
|
|
215
|
+
uint16: bcs.u16(),
|
|
216
|
+
int64: bcs.bytes(8),
|
|
217
|
+
string: bcs.string(),
|
|
218
|
+
uint8: bcs.u8(),
|
|
219
|
+
int32: bcs.bytes(4),
|
|
220
|
+
uint64: bcs.u64(),
|
|
221
|
+
int16: bcs.bytes(2),
|
|
222
|
+
uint32: bcs.u32(),
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
export const IscUnresolvedVMError = bcs.struct('IscUnresolvedVMError', {
|
|
226
|
+
errorCode: IscVMErrorCode,
|
|
227
|
+
params: bcs.vector(IscVMErrorParam),
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
export const GasBurnLog = bcs.struct('GasBurnLog', {
|
|
231
|
+
records: bcs.vector(GasBurnRecord),
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
export const TypesAccessTuple = bcs.struct('TypesAccessTuple', {
|
|
235
|
+
address: bcs.fixedArray(20, bcs.u8()),
|
|
236
|
+
storageKeys: bcs.vector(bcs.fixedArray(32, bcs.u8())),
|
|
237
|
+
});
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export enum CoreContract {
|
|
2
|
+
Root = 'root',
|
|
3
|
+
Accounts = 'accounts',
|
|
4
|
+
Blocklog = 'blocklog',
|
|
5
|
+
Governance = 'governance',
|
|
6
|
+
Errors = 'errors',
|
|
7
|
+
evm = 'evm',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export enum RootContractMethod {
|
|
11
|
+
FindContract = 'findContract',
|
|
12
|
+
GetContractRecords = 'getContractRecords',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export enum AccountsContractMethod {
|
|
16
|
+
Deposit = 'deposit',
|
|
17
|
+
Withdraw = 'withdraw',
|
|
18
|
+
TransferAllowanceTo = 'transferAllowanceTo',
|
|
19
|
+
TransferAccountToChain = 'transferAccountToChain',
|
|
20
|
+
SetCoinMetadata = 'setCoinMetadata',
|
|
21
|
+
DeleteCoinMetadata = 'deleteCoinMetadata',
|
|
22
|
+
Balance = 'balance',
|
|
23
|
+
BalanceBaseToken = 'balanceBaseToken',
|
|
24
|
+
BalanceBaseTokenEVM = 'balanceBaseTokenEVM',
|
|
25
|
+
BalanceCoin = 'balanceCoin',
|
|
26
|
+
TotalAssets = 'totalAssets',
|
|
27
|
+
AccountObjects = 'accountObjects',
|
|
28
|
+
AccountObjectsInCollection = 'accountObjectsInCollection',
|
|
29
|
+
GetAccountNonce = 'getAccountNonce',
|
|
30
|
+
ObjectBCS = 'objectBCS',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export enum BlocklogContractMethod {
|
|
34
|
+
GetBlockInfo = 'getBlockInfo',
|
|
35
|
+
GetRequestIDsForBlock = 'getRequestIDsForBlock',
|
|
36
|
+
GetRequestReceipt = 'getRequestReceipt',
|
|
37
|
+
GetRequestReceiptsForBlock = 'getRequestReceiptsForBlock',
|
|
38
|
+
IsRequestProcessed = 'isRequestProcessed',
|
|
39
|
+
GetEventsForRequest = 'getEventsForRequest',
|
|
40
|
+
GetEventsForBlock = 'getEventsForBlock',
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export enum GovernanceContractMethod {
|
|
44
|
+
RotateStateController = 'rotateStateController',
|
|
45
|
+
AddAllowedStateControllerAddress = 'addAllowedStateControllerAddress',
|
|
46
|
+
RemoveAllowedStateControllerAddress = 'removeAllowedStateControllerAddress',
|
|
47
|
+
DelegateChainOwnership = 'delegateChainOwnership',
|
|
48
|
+
ClaimChainOwnership = 'claimChainOwnership',
|
|
49
|
+
SetFeePolicy = 'setFeePolicy',
|
|
50
|
+
SetGasLimits = 'setGasLimits',
|
|
51
|
+
SetEVMGasRatio = 'setEVMGasRatio',
|
|
52
|
+
AddCandidateNode = 'addCandidateNode',
|
|
53
|
+
RevokeAccessNode = 'revokeAccessNode',
|
|
54
|
+
ChangeAccessNodes = 'changeAccessNodes',
|
|
55
|
+
StartMaintenance = 'startMaintenance',
|
|
56
|
+
StopMaintenance = 'stopMaintenance',
|
|
57
|
+
SetPayoutAgentID = 'setPayoutAgentID',
|
|
58
|
+
GetAllowedStateControllerAddresses = 'getAllowedStateControllerAddresses',
|
|
59
|
+
GetChainOwner = 'getChainOwner',
|
|
60
|
+
GetChainInfo = 'getChainInfo',
|
|
61
|
+
GetFeePolicy = 'getFeePolicy',
|
|
62
|
+
GetGasLimits = 'getGasLimits',
|
|
63
|
+
GetEVMGasRatio = 'getEVMGasRatio',
|
|
64
|
+
GetChainNodes = 'getChainNodes',
|
|
65
|
+
GetMaintenanceStatus = 'getMaintenanceStatus',
|
|
66
|
+
GetPayoutAgentID = 'getPayoutAgentID',
|
|
67
|
+
GetMetadata = 'getMetadata',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export enum ErrorsContractMethod {
|
|
71
|
+
RegisterError = 'registerError',
|
|
72
|
+
GetErrorMessageFormat = 'getErrorMessageFormat',
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export enum EVMContractMethod {
|
|
76
|
+
RegisterERC20Coin = 'registerERC20Coin',
|
|
77
|
+
SendTransaction = 'sendTransaction',
|
|
78
|
+
CallContract = 'callContract',
|
|
79
|
+
RegisterERC721NFTCollection = 'registerERC721NFTCollection',
|
|
80
|
+
NewL1Deposit = 'newL1Deposit',
|
|
81
|
+
GetChainID = 'getChainID',
|
|
82
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './contracts.enums.js';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './enums/index.js';
|
|
2
|
+
export * from './utils/index.js';
|
|
3
|
+
export * from './bcs.js';
|
|
4
|
+
export * from './constants.js';
|
|
5
|
+
export * from './transaction.js';
|
|
6
|
+
export * from './types/index.js';
|
|
7
|
+
export * from './move_bcs.js';
|
|
8
|
+
export * from './api/index.js';
|
|
9
|
+
export * from './types/index.js';
|