starknet 4.8.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +1 -3
- package/__mocks__/ERC20.json +32561 -29055
- package/__tests__/account.test.ts +32 -24
- package/__tests__/contract.test.ts +25 -14
- package/__tests__/defaultProvider.test.ts +91 -240
- package/__tests__/fixtures.ts +10 -2
- package/__tests__/rpcProvider.test.ts +8 -16
- package/__tests__/sequencerProvider.test.ts +17 -10
- package/__tests__/udc.test.ts +41 -0
- package/__tests__/utils/merkle.test.ts +98 -3
- package/__tests__/utils/typedData.test.ts +3 -3
- package/account/default.d.ts +12 -44
- package/account/default.js +305 -61
- package/account/interface.d.ts +96 -8
- package/constants.d.ts +8 -1
- package/constants.js +8 -1
- package/contract/default.d.ts +11 -27
- package/contract/default.js +105 -121
- package/contract/interface.d.ts +5 -2
- package/dist/account/default.d.ts +12 -44
- package/dist/account/default.js +305 -61
- package/dist/account/interface.d.ts +96 -8
- package/dist/constants.d.ts +8 -1
- package/dist/constants.js +8 -1
- package/dist/contract/default.d.ts +11 -27
- package/dist/contract/default.js +105 -121
- package/dist/contract/interface.d.ts +5 -2
- package/dist/provider/default.d.ts +8 -3
- package/dist/provider/default.js +31 -4
- package/dist/provider/interface.d.ts +67 -5
- package/dist/provider/rpc.d.ts +10 -3
- package/dist/provider/rpc.js +98 -10
- package/dist/provider/sequencer.d.ts +11 -4
- package/dist/provider/sequencer.js +89 -18
- package/dist/signer/default.d.ts +5 -2
- package/dist/signer/default.js +25 -3
- package/dist/signer/interface.d.ts +29 -2
- package/dist/types/api/index.d.ts +0 -6
- package/dist/types/api/openrpc.d.ts +24 -2
- package/dist/types/api/sequencer.d.ts +22 -7
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib.d.ts +36 -2
- package/dist/types/provider.d.ts +15 -10
- package/dist/types/signer.d.ts +14 -1
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +13 -2
- package/dist/utils/merkle.js +2 -4
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/number.js +3 -1
- package/dist/utils/responseParser/rpc.d.ts +2 -6
- package/dist/utils/responseParser/rpc.js +0 -11
- package/dist/utils/responseParser/sequencer.js +4 -14
- package/package.json +1 -1
- package/provider/default.d.ts +8 -3
- package/provider/default.js +31 -4
- package/provider/interface.d.ts +67 -5
- package/provider/rpc.d.ts +10 -3
- package/provider/rpc.js +98 -10
- package/provider/sequencer.d.ts +11 -4
- package/provider/sequencer.js +89 -18
- package/signer/default.d.ts +5 -2
- package/signer/default.js +25 -3
- package/signer/interface.d.ts +29 -2
- package/src/account/default.ts +243 -55
- package/src/account/interface.ts +132 -7
- package/src/constants.ts +8 -0
- package/src/contract/default.ts +124 -141
- package/src/contract/interface.ts +5 -2
- package/src/provider/default.ts +43 -5
- package/src/provider/interface.ts +92 -7
- package/src/provider/rpc.ts +93 -15
- package/src/provider/sequencer.ts +87 -14
- package/src/signer/default.ts +56 -4
- package/src/signer/interface.ts +33 -2
- package/src/types/api/index.ts +0 -4
- package/src/types/api/openrpc.ts +28 -2
- package/src/types/api/sequencer.ts +32 -9
- package/src/types/index.ts +1 -1
- package/src/types/lib.ts +43 -2
- package/src/types/provider.ts +27 -11
- package/src/types/signer.ts +18 -1
- package/src/utils/hash.ts +46 -1
- package/src/utils/merkle.ts +2 -4
- package/src/utils/number.ts +2 -0
- package/src/utils/responseParser/rpc.ts +4 -20
- package/src/utils/responseParser/sequencer.ts +2 -0
- package/types/api/index.d.ts +0 -6
- package/types/api/openrpc.d.ts +24 -2
- package/types/api/sequencer.d.ts +22 -7
- package/types/index.d.ts +1 -1
- package/types/lib.d.ts +36 -2
- package/types/provider.d.ts +15 -10
- package/types/signer.d.ts +14 -1
- package/utils/hash.d.ts +2 -0
- package/utils/hash.js +13 -2
- package/utils/merkle.js +2 -4
- package/utils/number.d.ts +1 -0
- package/utils/number.js +3 -1
- package/utils/responseParser/rpc.d.ts +2 -6
- package/utils/responseParser/rpc.js +0 -11
- package/utils/responseParser/sequencer.js +4 -14
- package/www/docs/API/account.md +170 -11
- package/www/docs/API/contract.md +39 -3
- package/www/docs/API/provider.md +310 -17
- package/www/docs/API/signer.md +56 -2
- package/www/guides/erc20.md +13 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Account, GetBlockResponse, RpcProvider, ec } from '../src';
|
|
2
|
+
import { StarknetChainId } from '../src/constants';
|
|
2
3
|
import {
|
|
3
|
-
compiledErc20,
|
|
4
4
|
compiledOpenZeppelinAccount,
|
|
5
5
|
describeIfRpc,
|
|
6
6
|
getTestAccount,
|
|
@@ -23,7 +23,7 @@ describeIfRpc('RPCProvider', () => {
|
|
|
23
23
|
|
|
24
24
|
test('getChainId', async () => {
|
|
25
25
|
const chainId = await rpcProvider.getChainId();
|
|
26
|
-
expect(chainId).toBe(
|
|
26
|
+
expect(chainId).toBe(StarknetChainId.TESTNET2);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
test('getPendingTransactions', async () => {
|
|
@@ -116,20 +116,12 @@ describeIfRpc('RPCProvider', () => {
|
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}));
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test('getClass', async () => {
|
|
129
|
-
const contractClass = await rpcProvider.getClass(class_hash);
|
|
130
|
-
expect(contractClass).toHaveProperty('program');
|
|
131
|
-
expect(contractClass).toHaveProperty('entry_points_by_type');
|
|
132
|
-
});
|
|
119
|
+
test('getClass classHash 0x00808396477a4296946bf6574afb2e14723f8d9a37bba25a1e104315ca89b1f7', async () => {
|
|
120
|
+
const contractClass = await rpcProvider.getClass(
|
|
121
|
+
'0x00808396477a4296946bf6574afb2e14723f8d9a37bba25a1e104315ca89b1f7'
|
|
122
|
+
);
|
|
123
|
+
expect(contractClass).toHaveProperty('program');
|
|
124
|
+
expect(contractClass).toHaveProperty('entry_points_by_type');
|
|
133
125
|
});
|
|
134
126
|
|
|
135
127
|
test.todo('getEstimateFee');
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
compiledL1L2,
|
|
7
7
|
describeIfNotDevnet,
|
|
8
8
|
describeIfSequencer,
|
|
9
|
+
getERC20DeployPayload,
|
|
9
10
|
getTestProvider,
|
|
10
11
|
} from './fixtures';
|
|
11
12
|
|
|
@@ -19,7 +20,7 @@ describeIfSequencer('SequencerProvider', () => {
|
|
|
19
20
|
sequencerProvider = getTestProvider() as SequencerProvider;
|
|
20
21
|
customSequencerProvider = new Provider({
|
|
21
22
|
sequencer: {
|
|
22
|
-
baseUrl: '
|
|
23
|
+
baseUrl: 'http://127.0.0.1:5050/',
|
|
23
24
|
feederGatewayUrl: 'feeder_gateway',
|
|
24
25
|
gatewayUrl: 'gateway',
|
|
25
26
|
}, // Similar to arguements used in docs
|
|
@@ -28,11 +29,15 @@ describeIfSequencer('SequencerProvider', () => {
|
|
|
28
29
|
|
|
29
30
|
describe('Gateway specific methods', () => {
|
|
30
31
|
let exampleTransactionHash: string;
|
|
32
|
+
const wallet = stark.randomAddress();
|
|
31
33
|
|
|
32
34
|
beforeAll(async () => {
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
}
|
|
35
|
+
const erc20DeployPayload = getERC20DeployPayload(wallet);
|
|
36
|
+
|
|
37
|
+
const { contract_address, transaction_hash } = await sequencerProvider.deployContract(
|
|
38
|
+
erc20DeployPayload
|
|
39
|
+
);
|
|
40
|
+
|
|
36
41
|
await sequencerProvider.waitForTransaction(transaction_hash);
|
|
37
42
|
exampleTransactionHash = transaction_hash;
|
|
38
43
|
exampleContractAddress = contract_address;
|
|
@@ -69,19 +74,21 @@ describeIfSequencer('SequencerProvider', () => {
|
|
|
69
74
|
const wallet = stark.randomAddress();
|
|
70
75
|
|
|
71
76
|
beforeAll(async () => {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
}
|
|
77
|
+
const erc20DeployPayload = getERC20DeployPayload(wallet);
|
|
78
|
+
|
|
79
|
+
const { contract_address, transaction_hash } = await customSequencerProvider.deployContract(
|
|
80
|
+
erc20DeployPayload
|
|
81
|
+
);
|
|
75
82
|
|
|
76
83
|
await customSequencerProvider.waitForTransaction(transaction_hash);
|
|
77
84
|
erc20 = new Contract(compiledErc20.abi, contract_address, customSequencerProvider);
|
|
78
85
|
});
|
|
79
86
|
|
|
80
87
|
test('Check ERC20 balance using Custom Sequencer Provider', async () => {
|
|
81
|
-
const result = await erc20.
|
|
88
|
+
const result = await erc20.balanceOf(wallet);
|
|
82
89
|
const [res] = result;
|
|
83
|
-
expect(res).toStrictEqual(toBN(
|
|
84
|
-
expect(res).toStrictEqual(result.
|
|
90
|
+
expect(res.low).toStrictEqual(toBN(1000));
|
|
91
|
+
expect(res).toStrictEqual(result.balance);
|
|
85
92
|
});
|
|
86
93
|
});
|
|
87
94
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { encodeShortString } from '../src/utils/shortString';
|
|
2
|
+
import { randomAddress } from '../src/utils/stark';
|
|
3
|
+
import { IS_DEVNET, compiledErc20, getTestAccount, getTestProvider } from './fixtures';
|
|
4
|
+
|
|
5
|
+
describe('Declare and UDC Deploy Flow', () => {
|
|
6
|
+
const provider = getTestProvider();
|
|
7
|
+
const account = getTestAccount(provider);
|
|
8
|
+
const erc20ClassHash = '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a';
|
|
9
|
+
|
|
10
|
+
test('ERC20 Declare', async () => {
|
|
11
|
+
const declareTx = await account.declare({
|
|
12
|
+
classHash: erc20ClassHash,
|
|
13
|
+
contract: compiledErc20,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
await provider.waitForTransaction(declareTx.transaction_hash);
|
|
17
|
+
|
|
18
|
+
expect(declareTx).toHaveProperty('class_hash');
|
|
19
|
+
expect(declareTx.class_hash).toEqual(erc20ClassHash);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('UDC Deploy', async () => {
|
|
23
|
+
const salt = randomAddress(); // use random salt
|
|
24
|
+
|
|
25
|
+
const deployment = await account.deploy({
|
|
26
|
+
classHash: erc20ClassHash,
|
|
27
|
+
constructorCalldata: [
|
|
28
|
+
encodeShortString('Token'),
|
|
29
|
+
encodeShortString('ERC20'),
|
|
30
|
+
account.address,
|
|
31
|
+
],
|
|
32
|
+
salt,
|
|
33
|
+
unique: true, // Using true here so as not to clash with normal erc20 deploy in account and provider test
|
|
34
|
+
isDevnet: IS_DEVNET,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
await provider.waitForTransaction(deployment.transaction_hash);
|
|
38
|
+
|
|
39
|
+
expect(deployment).toHaveProperty('transaction_hash');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -53,7 +53,7 @@ describe('MerkleTree class', () => {
|
|
|
53
53
|
MerkleTree.hash(leaves[0], leaves[1]),
|
|
54
54
|
MerkleTree.hash(leaves[2], leaves[3])
|
|
55
55
|
),
|
|
56
|
-
MerkleTree.hash(leaves[4], leaves[5])
|
|
56
|
+
MerkleTree.hash(MerkleTree.hash(leaves[4], leaves[5]), '0x0')
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
expect(tree.root).toBe(manualMerkle);
|
|
@@ -67,7 +67,7 @@ describe('MerkleTree class', () => {
|
|
|
67
67
|
MerkleTree.hash(leaves[0], leaves[1]),
|
|
68
68
|
MerkleTree.hash(leaves[2], leaves[3])
|
|
69
69
|
),
|
|
70
|
-
MerkleTree.hash(MerkleTree.hash(leaves[4], leaves[5]), leaves[6])
|
|
70
|
+
MerkleTree.hash(MerkleTree.hash(leaves[4], leaves[5]), MerkleTree.hash(leaves[6], '0x0'))
|
|
71
71
|
);
|
|
72
72
|
|
|
73
73
|
expect(tree.root).toBe(manualMerkle);
|
|
@@ -85,7 +85,7 @@ describe('MerkleTree class', () => {
|
|
|
85
85
|
const manualProof = [
|
|
86
86
|
'0x4',
|
|
87
87
|
MerkleTree.hash('0x1', '0x2'),
|
|
88
|
-
MerkleTree.hash(MerkleTree.hash('0x5', '0x6'), '0x7'),
|
|
88
|
+
MerkleTree.hash(MerkleTree.hash('0x5', '0x6'), MerkleTree.hash('0x7', '0x0')),
|
|
89
89
|
];
|
|
90
90
|
|
|
91
91
|
expect(proof).toEqual(manualProof);
|
|
@@ -101,6 +101,17 @@ describe('MerkleTree class', () => {
|
|
|
101
101
|
|
|
102
102
|
expect(proof).toEqual(manualProof);
|
|
103
103
|
});
|
|
104
|
+
test('should return proof path for valid child', async () => {
|
|
105
|
+
const proof = tree.getProof('0x5');
|
|
106
|
+
|
|
107
|
+
const manualProof = [
|
|
108
|
+
'0x6',
|
|
109
|
+
MerkleTree.hash('0x7', '0x0'), // tree should be padded with 0x0 so that all proofs are equals in size
|
|
110
|
+
MerkleTree.hash(MerkleTree.hash('0x1', '0x2'), MerkleTree.hash('0x3', '0x4')),
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
expect(proof).toEqual(manualProof);
|
|
114
|
+
});
|
|
104
115
|
test('should throw for invalid child', () => {
|
|
105
116
|
expect(() => tree.getProof('0x8')).toThrow('leaf not found');
|
|
106
117
|
});
|
|
@@ -114,6 +125,7 @@ describe('MerkleTree class', () => {
|
|
|
114
125
|
|
|
115
126
|
test('should return true for valid manual proof', async () => {
|
|
116
127
|
const manualProof = [
|
|
128
|
+
'0x0', // tree should be padded with 0x0 so that all proofs are equals in size
|
|
117
129
|
MerkleTree.hash('0x5', '0x6'),
|
|
118
130
|
MerkleTree.hash(MerkleTree.hash('0x1', '0x2'), MerkleTree.hash('0x3', '0x4')),
|
|
119
131
|
];
|
|
@@ -122,6 +134,17 @@ describe('MerkleTree class', () => {
|
|
|
122
134
|
|
|
123
135
|
expect(proofMerklePath(root, leaf, manualProof)).toBe(true);
|
|
124
136
|
});
|
|
137
|
+
test('should return true for valid manual proof', async () => {
|
|
138
|
+
const manualProof = [
|
|
139
|
+
'0x6',
|
|
140
|
+
MerkleTree.hash('0x7', '0x0'), // tree should be padded with 0x0 so that all proofs are equals in size
|
|
141
|
+
MerkleTree.hash(MerkleTree.hash('0x1', '0x2'), MerkleTree.hash('0x3', '0x4')),
|
|
142
|
+
];
|
|
143
|
+
const leaf = '0x5';
|
|
144
|
+
const { root } = tree;
|
|
145
|
+
|
|
146
|
+
expect(proofMerklePath(root, leaf, manualProof)).toBe(true);
|
|
147
|
+
});
|
|
125
148
|
test('should return true for valid proof', async () => {
|
|
126
149
|
const proof = tree.getProof('0x3');
|
|
127
150
|
const leaf = '0x3';
|
|
@@ -158,4 +181,76 @@ describe('MerkleTree class', () => {
|
|
|
158
181
|
expect(proofMerklePath(root, leaf, proof)).toBe(false);
|
|
159
182
|
});
|
|
160
183
|
});
|
|
184
|
+
describe('verify 2-deep tree with empty data on the right', () => {
|
|
185
|
+
let tree: MerkleTree;
|
|
186
|
+
beforeAll(() => {
|
|
187
|
+
const leaves = ['0x1', '0x2', '0x3'];
|
|
188
|
+
tree = new MerkleTree(leaves);
|
|
189
|
+
});
|
|
190
|
+
test('should return 1-length proof in a 2-length tree', async () => {
|
|
191
|
+
const proof = tree.getProof('0x3');
|
|
192
|
+
const manualProof = ['0x0', MerkleTree.hash('0x1', '0x2')];
|
|
193
|
+
expect(proof).toEqual(manualProof);
|
|
194
|
+
});
|
|
195
|
+
test('should check the previous proof works fine', async () => {
|
|
196
|
+
const manualMerkle = MerkleTree.hash(
|
|
197
|
+
MerkleTree.hash('0x3', '0x0'),
|
|
198
|
+
MerkleTree.hash('0x1', '0x2')
|
|
199
|
+
);
|
|
200
|
+
expect(tree.root).toBe(manualMerkle);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
describe('verify 3-deep tree with empty data on the right', () => {
|
|
204
|
+
let tree: MerkleTree;
|
|
205
|
+
beforeAll(() => {
|
|
206
|
+
const leaves = ['0x1', '0x2', '0x3', '0x4', '0x5', '0x6'];
|
|
207
|
+
tree = new MerkleTree(leaves);
|
|
208
|
+
});
|
|
209
|
+
test('should return 2-length proof with the 2nd place skipped', async () => {
|
|
210
|
+
const proof = tree.getProof('0x5');
|
|
211
|
+
const manualProof = [
|
|
212
|
+
'0x6',
|
|
213
|
+
'0x0',
|
|
214
|
+
MerkleTree.hash(MerkleTree.hash('0x1', '0x2'), MerkleTree.hash('0x3', '0x4')),
|
|
215
|
+
];
|
|
216
|
+
expect(proof).toEqual(manualProof);
|
|
217
|
+
});
|
|
218
|
+
test('should check the previous proof works fine', async () => {
|
|
219
|
+
const manualMerkle = MerkleTree.hash(
|
|
220
|
+
MerkleTree.hash(MerkleTree.hash('0x5', '0x6'), '0x0'),
|
|
221
|
+
MerkleTree.hash(MerkleTree.hash('0x1', '0x2'), MerkleTree.hash('0x3', '0x4'))
|
|
222
|
+
);
|
|
223
|
+
expect(tree.root).toBe(manualMerkle);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
describe('verify 4-deep tree with empty data on the right', () => {
|
|
227
|
+
let tree: MerkleTree;
|
|
228
|
+
beforeAll(() => {
|
|
229
|
+
const leaves = ['0x1', '0x2', '0x3', '0x4', '0x5', '0x6', '0x7', '0x8', '0x9'];
|
|
230
|
+
tree = new MerkleTree(leaves);
|
|
231
|
+
});
|
|
232
|
+
test('should return 2-length proof with the 2nd place skipped', async () => {
|
|
233
|
+
const proof = tree.getProof('0x9');
|
|
234
|
+
const manualProof = [
|
|
235
|
+
'0x0',
|
|
236
|
+
'0x0',
|
|
237
|
+
'0x0',
|
|
238
|
+
MerkleTree.hash(
|
|
239
|
+
MerkleTree.hash(MerkleTree.hash('0x1', '0x2'), MerkleTree.hash('0x3', '0x4')),
|
|
240
|
+
MerkleTree.hash(MerkleTree.hash('0x5', '0x6'), MerkleTree.hash('0x7', '0x8'))
|
|
241
|
+
),
|
|
242
|
+
];
|
|
243
|
+
expect(proof).toEqual(manualProof);
|
|
244
|
+
});
|
|
245
|
+
test('should check the previous proof works fine', async () => {
|
|
246
|
+
const manualMerkle = MerkleTree.hash(
|
|
247
|
+
MerkleTree.hash(MerkleTree.hash(MerkleTree.hash('0x9', '0x0'), '0x0'), '0x0'),
|
|
248
|
+
MerkleTree.hash(
|
|
249
|
+
MerkleTree.hash(MerkleTree.hash('0x1', '0x2'), MerkleTree.hash('0x3', '0x4')),
|
|
250
|
+
MerkleTree.hash(MerkleTree.hash('0x5', '0x6'), MerkleTree.hash('0x7', '0x8'))
|
|
251
|
+
)
|
|
252
|
+
);
|
|
253
|
+
expect(tree.root).toBe(manualMerkle);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
161
256
|
});
|
|
@@ -72,7 +72,7 @@ describe('typedData', () => {
|
|
|
72
72
|
const [, merkleTreeHash] = encodeValue({}, 'merkletree', tree.leaves);
|
|
73
73
|
expect(merkleTreeHash).toBe(tree.root);
|
|
74
74
|
expect(merkleTreeHash).toMatchInlineSnapshot(
|
|
75
|
-
`"
|
|
75
|
+
`"0x15ac9e457789ef0c56e5d559809e7336a909c14ee2511503fa7af69be1ba639"`
|
|
76
76
|
);
|
|
77
77
|
});
|
|
78
78
|
|
|
@@ -119,7 +119,7 @@ describe('typedData', () => {
|
|
|
119
119
|
);
|
|
120
120
|
expect(merkleTreeHash).toBe(tree.root);
|
|
121
121
|
expect(merkleTreeHash).toMatchInlineSnapshot(
|
|
122
|
-
`"
|
|
122
|
+
`"0x12354b159e3799dc0ebe86d62dde4ce7b300538d471e5a7fef23dcbac076011"`
|
|
123
123
|
);
|
|
124
124
|
});
|
|
125
125
|
|
|
@@ -217,7 +217,7 @@ describe('typedData', () => {
|
|
|
217
217
|
'0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826'
|
|
218
218
|
);
|
|
219
219
|
expect(hash).toMatchInlineSnapshot(
|
|
220
|
-
`"
|
|
220
|
+
`"0x751fb7d98545f7649d0d0eadc80d770fcd88d8cfaa55590b284f4e1b701ef0a"`
|
|
221
221
|
);
|
|
222
222
|
});
|
|
223
223
|
});
|
package/account/default.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import { ProviderInterface, ProviderOptions } from '../provider';
|
|
|
2
2
|
import { Provider } from '../provider/default';
|
|
3
3
|
import { BlockIdentifier } from '../provider/utils';
|
|
4
4
|
import { SignerInterface } from '../signer';
|
|
5
|
-
import { Abi, Call, InvocationsDetails, InvokeFunctionResponse, KeyPair, Signature } from '../types';
|
|
5
|
+
import { Abi, Call, DeclareContractResponse, DeployContractResponse, EstimateFeeAction, InvocationsDetails, InvokeFunctionResponse, KeyPair, Signature } from '../types';
|
|
6
6
|
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
7
|
+
import { AllowArray, DeclareContractPayload, DeployAccountContractPayload, UniversalDeployerContractPayload } from '../types/lib';
|
|
7
8
|
import { BigNumberish } from '../utils/number';
|
|
8
9
|
import { TypedData } from '../utils/typedData';
|
|
9
10
|
import { AccountInterface } from './interface';
|
|
@@ -12,51 +13,18 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
12
13
|
address: string;
|
|
13
14
|
constructor(providerOrOptions: ProviderOptions | ProviderInterface, address: string, keyPairOrSigner: KeyPair | SignerInterface);
|
|
14
15
|
getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
15
|
-
estimateFee(calls: Call
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* @returns a confirmation of invoking a function on the starknet contract
|
|
25
|
-
*/
|
|
26
|
-
execute(calls: Call | Call[], abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
27
|
-
/**
|
|
28
|
-
* Sign an JSON object with the starknet private key and return the signature
|
|
29
|
-
*
|
|
30
|
-
* @param json - JSON object to be signed
|
|
31
|
-
* @returns the signature of the JSON object
|
|
32
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
33
|
-
*/
|
|
16
|
+
estimateFee(calls: AllowArray<Call>, estimateFeeDetails?: EstimateFeeDetails | undefined): Promise<EstimateFee>;
|
|
17
|
+
estimateInvokeFee(calls: AllowArray<Call>, { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
18
|
+
estimateDeclareFee({ classHash, contract }: DeclareContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
19
|
+
estimateAccountDeployFee({ classHash, addressSalt, constructorCalldata, contractAddress: providedContractAddress, }: DeployAccountContractPayload, { blockIdentifier, nonce: providedNonce }?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
20
|
+
execute(calls: AllowArray<Call>, abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
21
|
+
declare({ classHash, contract }: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
|
|
22
|
+
deploy({ classHash, salt, unique, constructorCalldata, isDevnet, }: UniversalDeployerContractPayload, additionalCalls?: AllowArray<Call>, // support multicall
|
|
23
|
+
transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
24
|
+
deployAccount({ classHash, constructorCalldata, addressSalt, contractAddress: providedContractAddress, }: DeployAccountContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeployContractResponse>;
|
|
34
25
|
signMessage(typedData: TypedData): Promise<Signature>;
|
|
35
|
-
/**
|
|
36
|
-
* Hash a JSON object with pederson hash and return the hash
|
|
37
|
-
*
|
|
38
|
-
* @param json - JSON object to be hashed
|
|
39
|
-
* @returns the hash of the JSON object
|
|
40
|
-
* @throws {Error} if the JSON object is not a valid JSON
|
|
41
|
-
*/
|
|
42
26
|
hashMessage(typedData: TypedData): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* Verify a signature of a given hash
|
|
45
|
-
* @warning This method is not recommended, use verifyMessage instead
|
|
46
|
-
*
|
|
47
|
-
* @param hash - JSON object to be verified
|
|
48
|
-
* @param signature - signature of the JSON object
|
|
49
|
-
* @returns true if the signature is valid, false otherwise
|
|
50
|
-
* @throws {Error} if the JSON object is not a valid JSON or the signature is not a valid signature
|
|
51
|
-
*/
|
|
52
27
|
verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* Verify a signature of a JSON object
|
|
55
|
-
*
|
|
56
|
-
* @param hash - hash to be verified
|
|
57
|
-
* @param signature - signature of the hash
|
|
58
|
-
* @returns true if the signature is valid, false otherwise
|
|
59
|
-
* @throws {Error} if the signature is not a valid signature
|
|
60
|
-
*/
|
|
61
28
|
verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
|
|
29
|
+
getSuggestedMaxFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<string>;
|
|
62
30
|
}
|