starknet 4.12.0 → 4.13.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/.eslintrc +1 -0
- package/CHANGELOG.md +14 -0
- package/__tests__/account.test.ts +0 -2
- package/dist/index.d.ts +2683 -24
- package/dist/index.global.js +22994 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +4713 -53
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4655 -0
- package/dist/index.mjs.map +1 -0
- package/index.d.ts +2683 -24
- package/index.global.js +22994 -0
- package/index.global.js.map +1 -0
- package/index.js +4713 -53
- package/index.js.map +1 -0
- package/index.mjs +4655 -0
- package/index.mjs.map +1 -0
- package/package.json +8 -2
- package/src/account/default.ts +43 -8
- package/src/account/interface.ts +25 -2
- package/src/constants.ts +0 -1
- package/src/provider/default.ts +3 -0
- package/src/provider/interface.ts +2 -0
- package/src/provider/rpc.ts +4 -4
- package/src/provider/sequencer.ts +4 -1
- package/src/types/lib.ts +1 -1
- package/src/types/provider.ts +5 -0
- package/src/utils/ellipticCurve.ts +3 -1
- package/src/utils/fetchPonyfill.ts +3 -2
- package/src/utils/hash.ts +3 -2
- package/src/utils/number.ts +2 -2
- package/tsup.config.ts +10 -0
- package/account/default.d.ts +0 -30
- package/account/default.js +0 -526
- package/account/index.d.ts +0 -2
- package/account/index.js +0 -18
- package/account/interface.d.ts +0 -161
- package/account/interface.js +0 -27
- package/constants.d.ts +0 -36
- package/constants.js +0 -2067
- package/contract/contractFactory.d.ts +0 -31
- package/contract/contractFactory.js +0 -102
- package/contract/default.d.ts +0 -108
- package/contract/default.js +0 -640
- package/contract/index.d.ts +0 -3
- package/contract/index.js +0 -19
- package/contract/interface.d.ts +0 -80
- package/contract/interface.js +0 -9
- package/dist/account/default.d.ts +0 -30
- package/dist/account/default.js +0 -526
- package/dist/account/index.d.ts +0 -2
- package/dist/account/index.js +0 -18
- package/dist/account/interface.d.ts +0 -161
- package/dist/account/interface.js +0 -27
- package/dist/constants.d.ts +0 -36
- package/dist/constants.js +0 -2067
- package/dist/contract/contractFactory.d.ts +0 -31
- package/dist/contract/contractFactory.js +0 -102
- package/dist/contract/default.d.ts +0 -108
- package/dist/contract/default.js +0 -640
- package/dist/contract/index.d.ts +0 -3
- package/dist/contract/index.js +0 -19
- package/dist/contract/interface.d.ts +0 -80
- package/dist/contract/interface.js +0 -9
- package/dist/provider/default.d.ts +0 -37
- package/dist/provider/default.js +0 -207
- package/dist/provider/errors.d.ts +0 -9
- package/dist/provider/errors.js +0 -40
- package/dist/provider/index.d.ts +0 -7
- package/dist/provider/index.js +0 -24
- package/dist/provider/interface.d.ts +0 -203
- package/dist/provider/interface.js +0 -9
- package/dist/provider/rpc.d.ts +0 -86
- package/dist/provider/rpc.js +0 -605
- package/dist/provider/sequencer.d.ts +0 -79
- package/dist/provider/sequencer.js +0 -575
- package/dist/provider/utils.d.ts +0 -30
- package/dist/provider/utils.js +0 -84
- package/dist/signer/default.d.ts +0 -13
- package/dist/signer/default.js +0 -102
- package/dist/signer/index.d.ts +0 -2
- package/dist/signer/index.js +0 -18
- package/dist/signer/interface.d.ts +0 -60
- package/dist/signer/interface.js +0 -9
- package/dist/types/account.d.ts +0 -11
- package/dist/types/account.js +0 -2
- package/dist/types/api/index.d.ts +0 -10
- package/dist/types/api/index.js +0 -18
- package/dist/types/api/openrpc.d.ts +0 -572
- package/dist/types/api/openrpc.js +0 -45
- package/dist/types/api/rpc.d.ts +0 -43
- package/dist/types/api/rpc.js +0 -2
- package/dist/types/api/sequencer.d.ts +0 -320
- package/dist/types/api/sequencer.js +0 -2
- package/dist/types/contract.d.ts +0 -5
- package/dist/types/contract.js +0 -2
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -35
- package/dist/types/lib.d.ts +0 -120
- package/dist/types/lib.js +0 -8
- package/dist/types/provider.d.ts +0 -99
- package/dist/types/provider.js +0 -2
- package/dist/types/signer.d.ts +0 -19
- package/dist/types/signer.js +0 -2
- package/dist/utils/address.d.ts +0 -5
- package/dist/utils/address.js +0 -41
- package/dist/utils/ellipticCurve.d.ts +0 -29
- package/dist/utils/ellipticCurve.js +0 -132
- package/dist/utils/encode.d.ts +0 -15
- package/dist/utils/encode.js +0 -96
- package/dist/utils/fetchPonyfill.d.ts +0 -2
- package/dist/utils/fetchPonyfill.js +0 -6
- package/dist/utils/hash.d.ts +0 -37
- package/dist/utils/hash.js +0 -162
- package/dist/utils/json.d.ts +0 -16
- package/dist/utils/json.js +0 -19
- package/dist/utils/merkle.d.ts +0 -10
- package/dist/utils/merkle.js +0 -89
- package/dist/utils/number.d.ts +0 -16
- package/dist/utils/number.js +0 -112
- package/dist/utils/provider.d.ts +0 -4
- package/dist/utils/provider.js +0 -38
- package/dist/utils/responseParser/index.d.ts +0 -11
- package/dist/utils/responseParser/index.js +0 -9
- package/dist/utils/responseParser/rpc.d.ts +0 -20
- package/dist/utils/responseParser/rpc.js +0 -44
- package/dist/utils/responseParser/sequencer.d.ts +0 -17
- package/dist/utils/responseParser/sequencer.js +0 -99
- package/dist/utils/shortString.d.ts +0 -4
- package/dist/utils/shortString.js +0 -26
- package/dist/utils/stark.d.ts +0 -16
- package/dist/utils/stark.js +0 -91
- package/dist/utils/transaction.d.ts +0 -20
- package/dist/utils/transaction.js +0 -79
- package/dist/utils/typedData/index.d.ts +0 -72
- package/dist/utils/typedData/index.js +0 -239
- package/dist/utils/typedData/types.d.ts +0 -32
- package/dist/utils/typedData/types.js +0 -2
- package/dist/utils/typedData/utils.d.ts +0 -8
- package/dist/utils/typedData/utils.js +0 -16
- package/dist/utils/uint256.d.ts +0 -11
- package/dist/utils/uint256.js +0 -28
- package/dist/utils/url.d.ts +0 -7
- package/dist/utils/url.js +0 -49
- package/provider/default.d.ts +0 -37
- package/provider/default.js +0 -207
- package/provider/errors.d.ts +0 -9
- package/provider/errors.js +0 -40
- package/provider/index.d.ts +0 -7
- package/provider/index.js +0 -24
- package/provider/interface.d.ts +0 -203
- package/provider/interface.js +0 -9
- package/provider/rpc.d.ts +0 -86
- package/provider/rpc.js +0 -605
- package/provider/sequencer.d.ts +0 -79
- package/provider/sequencer.js +0 -575
- package/provider/utils.d.ts +0 -30
- package/provider/utils.js +0 -84
- package/signer/default.d.ts +0 -13
- package/signer/default.js +0 -102
- package/signer/index.d.ts +0 -2
- package/signer/index.js +0 -18
- package/signer/interface.d.ts +0 -60
- package/signer/interface.js +0 -9
- package/types/account.d.ts +0 -11
- package/types/account.js +0 -2
- package/types/api/index.d.ts +0 -10
- package/types/api/index.js +0 -18
- package/types/api/openrpc.d.ts +0 -572
- package/types/api/openrpc.js +0 -45
- package/types/api/rpc.d.ts +0 -43
- package/types/api/rpc.js +0 -2
- package/types/api/sequencer.d.ts +0 -320
- package/types/api/sequencer.js +0 -2
- package/types/contract.d.ts +0 -5
- package/types/contract.js +0 -2
- package/types/index.d.ts +0 -7
- package/types/index.js +0 -35
- package/types/lib.d.ts +0 -120
- package/types/lib.js +0 -8
- package/types/provider.d.ts +0 -99
- package/types/provider.js +0 -2
- package/types/signer.d.ts +0 -19
- package/types/signer.js +0 -2
- package/utils/address.d.ts +0 -5
- package/utils/address.js +0 -41
- package/utils/ellipticCurve.d.ts +0 -29
- package/utils/ellipticCurve.js +0 -132
- package/utils/encode.d.ts +0 -15
- package/utils/encode.js +0 -96
- package/utils/fetchPonyfill.d.ts +0 -2
- package/utils/fetchPonyfill.js +0 -6
- package/utils/hash.d.ts +0 -37
- package/utils/hash.js +0 -162
- package/utils/json.d.ts +0 -16
- package/utils/json.js +0 -19
- package/utils/merkle.d.ts +0 -10
- package/utils/merkle.js +0 -89
- package/utils/number.d.ts +0 -16
- package/utils/number.js +0 -112
- package/utils/provider.d.ts +0 -4
- package/utils/provider.js +0 -38
- package/utils/responseParser/index.d.ts +0 -11
- package/utils/responseParser/index.js +0 -9
- package/utils/responseParser/rpc.d.ts +0 -20
- package/utils/responseParser/rpc.js +0 -44
- package/utils/responseParser/sequencer.d.ts +0 -17
- package/utils/responseParser/sequencer.js +0 -99
- package/utils/shortString.d.ts +0 -4
- package/utils/shortString.js +0 -26
- package/utils/stark.d.ts +0 -16
- package/utils/stark.js +0 -91
- package/utils/transaction.d.ts +0 -20
- package/utils/transaction.js +0 -79
- package/utils/typedData/index.d.ts +0 -72
- package/utils/typedData/index.js +0 -239
- package/utils/typedData/types.d.ts +0 -32
- package/utils/typedData/types.js +0 -2
- package/utils/typedData/utils.d.ts +0 -8
- package/utils/typedData/utils.js +0 -16
- package/utils/uint256.d.ts +0 -11
- package/utils/uint256.js +0 -28
- package/utils/url.d.ts +0 -7
- package/utils/url.js +0 -49
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starknet",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"description": "JavaScript library for StarkNet",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"browser": "dist/index.global.js",
|
|
6
8
|
"types": "dist/index.d.ts",
|
|
7
9
|
"scripts": {
|
|
8
10
|
"prepare": "npm run build && husky install",
|
|
9
|
-
"build": "
|
|
11
|
+
"build": "tsup && npm run build:esm && npm run build:iife",
|
|
12
|
+
"build:esm": "tsup --clean false --format esm --platform node",
|
|
13
|
+
"build:iife": "tsup --clean false --format iife --platform browser",
|
|
10
14
|
"pretest": "npm run lint",
|
|
11
15
|
"test": "jest",
|
|
12
16
|
"posttest": "npm run format",
|
|
@@ -38,6 +42,7 @@
|
|
|
38
42
|
"@semantic-release/npm": "^9.0.1",
|
|
39
43
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
40
44
|
"@types/elliptic": "^6.4.14",
|
|
45
|
+
"@types/isomorphic-fetch": "^0.0.36",
|
|
41
46
|
"@types/jest": "^28.1.1",
|
|
42
47
|
"@types/json-bigint": "^1.0.1",
|
|
43
48
|
"@types/minimalistic-assert": "^1.0.1",
|
|
@@ -59,6 +64,7 @@
|
|
|
59
64
|
"lint-staged": "^13.0.1",
|
|
60
65
|
"prettier": "^2.7.0",
|
|
61
66
|
"prettier-plugin-import-sort": "^0.0.7",
|
|
67
|
+
"tsup": "^6.3.0",
|
|
62
68
|
"typedoc": "^0.22.17",
|
|
63
69
|
"typescript": "^4.7.3"
|
|
64
70
|
},
|
package/src/account/default.ts
CHANGED
|
@@ -166,6 +166,38 @@ export class Account extends Provider implements AccountInterface {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
public async estimateDeployFee(
|
|
170
|
+
{
|
|
171
|
+
classHash,
|
|
172
|
+
salt,
|
|
173
|
+
unique = true,
|
|
174
|
+
constructorCalldata = [],
|
|
175
|
+
additionalCalls = [],
|
|
176
|
+
}: UniversalDeployerContractPayload,
|
|
177
|
+
transactionsDetail?: InvocationsDetails | undefined
|
|
178
|
+
): Promise<EstimateFee> {
|
|
179
|
+
const compiledConstructorCallData = compileCalldata(constructorCalldata);
|
|
180
|
+
|
|
181
|
+
const callsArray = Array.isArray(additionalCalls) ? additionalCalls : [additionalCalls];
|
|
182
|
+
return this.estimateInvokeFee(
|
|
183
|
+
[
|
|
184
|
+
{
|
|
185
|
+
contractAddress: UDC.ADDRESS,
|
|
186
|
+
entrypoint: UDC.ENTRYPOINT,
|
|
187
|
+
calldata: [
|
|
188
|
+
classHash,
|
|
189
|
+
salt,
|
|
190
|
+
toCairoBool(unique),
|
|
191
|
+
compiledConstructorCallData.length,
|
|
192
|
+
...compiledConstructorCallData,
|
|
193
|
+
],
|
|
194
|
+
},
|
|
195
|
+
...callsArray,
|
|
196
|
+
],
|
|
197
|
+
transactionsDetail
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
169
201
|
public async execute(
|
|
170
202
|
calls: AllowArray<Call>,
|
|
171
203
|
abis: Abi[] | undefined = undefined,
|
|
@@ -243,9 +275,8 @@ export class Account extends Provider implements AccountInterface {
|
|
|
243
275
|
salt,
|
|
244
276
|
unique = true,
|
|
245
277
|
constructorCalldata = [],
|
|
246
|
-
|
|
278
|
+
additionalCalls = [],
|
|
247
279
|
}: UniversalDeployerContractPayload,
|
|
248
|
-
additionalCalls: AllowArray<Call> = [], // support multicall
|
|
249
280
|
transactionsDetail: InvocationsDetails = {}
|
|
250
281
|
): Promise<InvokeFunctionResponse> {
|
|
251
282
|
const compiledConstructorCallData = compileCalldata(constructorCalldata);
|
|
@@ -255,7 +286,7 @@ export class Account extends Provider implements AccountInterface {
|
|
|
255
286
|
return this.execute(
|
|
256
287
|
[
|
|
257
288
|
{
|
|
258
|
-
contractAddress:
|
|
289
|
+
contractAddress: UDC.ADDRESS,
|
|
259
290
|
entrypoint: UDC.ENTRYPOINT,
|
|
260
291
|
calldata: [
|
|
261
292
|
classHash,
|
|
@@ -350,22 +381,26 @@ export class Account extends Provider implements AccountInterface {
|
|
|
350
381
|
}
|
|
351
382
|
|
|
352
383
|
public async getSuggestedMaxFee(
|
|
353
|
-
|
|
384
|
+
{ type, payload }: EstimateFeeAction,
|
|
354
385
|
details: EstimateFeeDetails
|
|
355
386
|
) {
|
|
356
387
|
let feeEstimate: EstimateFee;
|
|
357
388
|
|
|
358
|
-
switch (
|
|
389
|
+
switch (type) {
|
|
359
390
|
case 'INVOKE':
|
|
360
|
-
feeEstimate = await this.estimateInvokeFee(
|
|
391
|
+
feeEstimate = await this.estimateInvokeFee(payload, details);
|
|
361
392
|
break;
|
|
362
393
|
|
|
363
394
|
case 'DECLARE':
|
|
364
|
-
feeEstimate = await this.estimateDeclareFee(
|
|
395
|
+
feeEstimate = await this.estimateDeclareFee(payload, details);
|
|
365
396
|
break;
|
|
366
397
|
|
|
367
398
|
case 'DEPLOY_ACCOUNT':
|
|
368
|
-
feeEstimate = await this.estimateAccountDeployFee(
|
|
399
|
+
feeEstimate = await this.estimateAccountDeployFee(payload, details);
|
|
400
|
+
break;
|
|
401
|
+
|
|
402
|
+
case 'DEPLOY':
|
|
403
|
+
feeEstimate = await this.estimateDeployFee(payload, details);
|
|
369
404
|
break;
|
|
370
405
|
|
|
371
406
|
default:
|
package/src/account/interface.ts
CHANGED
|
@@ -86,6 +86,27 @@ export abstract class AccountInterface extends ProviderInterface {
|
|
|
86
86
|
estimateFeeDetails?: EstimateFeeDetails
|
|
87
87
|
): Promise<EstimateFeeResponse>;
|
|
88
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Estimate Fee for executing a UDC DEPLOY transaction on starknet
|
|
91
|
+
* This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC)
|
|
92
|
+
|
|
93
|
+
* @param deployContractPayload containing
|
|
94
|
+
* - classHash: computed class hash of compiled contract
|
|
95
|
+
* - salt: address salt
|
|
96
|
+
* - unique: bool if true ensure unique salt
|
|
97
|
+
* - calldata: constructor calldata
|
|
98
|
+
* - additionalCalls - optional additional calls array to support multicall
|
|
99
|
+
*
|
|
100
|
+
* @param transactionsDetail Invocation Details containing:
|
|
101
|
+
* - optional nonce
|
|
102
|
+
* - optional version
|
|
103
|
+
* - optional maxFee
|
|
104
|
+
*/
|
|
105
|
+
public abstract estimateDeployFee(
|
|
106
|
+
deployContractPayload: UniversalDeployerContractPayload,
|
|
107
|
+
transactionsDetail?: InvocationsDetails
|
|
108
|
+
): Promise<EstimateFeeResponse>;
|
|
109
|
+
|
|
89
110
|
/**
|
|
90
111
|
* Invoke execute function in account contract
|
|
91
112
|
*
|
|
@@ -123,12 +144,15 @@ export abstract class AccountInterface extends ProviderInterface {
|
|
|
123
144
|
): Promise<DeclareContractResponse>;
|
|
124
145
|
|
|
125
146
|
/**
|
|
147
|
+
* Deploys a given compiled contract (json) to starknet using Universal Deployer Contract (UDC)
|
|
148
|
+
* This is different from the normal DEPLOY transaction as it goes through the Universal Deployer Contract (UDC)
|
|
149
|
+
*
|
|
126
150
|
* @param deployContractPayload containing
|
|
127
151
|
* - classHash: computed class hash of compiled contract
|
|
128
152
|
* - salt: address salt
|
|
129
153
|
* - unique: bool if true ensure unique salt
|
|
130
154
|
* - calldata: constructor calldata
|
|
131
|
-
*
|
|
155
|
+
* - additionalCalls - optional additional calls array to support multicall
|
|
132
156
|
* @param transactionsDetail Invocation Details containing:
|
|
133
157
|
* - optional nonce
|
|
134
158
|
* - optional version
|
|
@@ -136,7 +160,6 @@ export abstract class AccountInterface extends ProviderInterface {
|
|
|
136
160
|
*/
|
|
137
161
|
public abstract deploy(
|
|
138
162
|
deployContractPayload: UniversalDeployerContractPayload,
|
|
139
|
-
additionalCalls?: AllowArray<Call>,
|
|
140
163
|
transactionsDetail?: InvocationsDetails
|
|
141
164
|
): Promise<InvokeFunctionResponse>;
|
|
142
165
|
|
package/src/constants.ts
CHANGED
|
@@ -24,7 +24,6 @@ export enum TransactionHashPrefix {
|
|
|
24
24
|
export const UDC = {
|
|
25
25
|
ADDRESS: '0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf',
|
|
26
26
|
ENTRYPOINT: 'deployContract',
|
|
27
|
-
ADDRESS_DEVNET: '0x25fcb74260022bd8ed7e8d542408941826b53345e478b8303d6f31744838a36',
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
/**
|
package/src/provider/default.ts
CHANGED
|
@@ -133,6 +133,9 @@ export class Provider implements ProviderInterface {
|
|
|
133
133
|
return this.provider.invokeFunction(functionInvocation, details);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* @deprecated This method won't be supported, use Account.deploy instead
|
|
138
|
+
*/
|
|
136
139
|
public async deployContract(
|
|
137
140
|
payload: DeployContractPayload,
|
|
138
141
|
details: InvocationsDetails
|
|
@@ -140,6 +140,8 @@ export abstract class ProviderInterface {
|
|
|
140
140
|
/**
|
|
141
141
|
* Deploys a given compiled contract (json) to starknet
|
|
142
142
|
*
|
|
143
|
+
* @deprecated This method won't be supported, use Account.deploy instead
|
|
144
|
+
*
|
|
143
145
|
* @param payload payload to be deployed containing:
|
|
144
146
|
* - compiled contract code
|
|
145
147
|
* - constructor calldata
|
package/src/provider/rpc.ts
CHANGED
|
@@ -64,10 +64,10 @@ export class RpcProvider implements ProviderInterface {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
public fetch(method: any, params: any): Promise<any> {
|
|
67
|
-
return fetch(
|
|
67
|
+
return fetch(this.nodeUrl, {
|
|
68
68
|
method: 'POST',
|
|
69
69
|
body: stringify({ method, jsonrpc: '2.0', params, id: 0 }),
|
|
70
|
-
headers: this.headers,
|
|
70
|
+
headers: this.headers as Record<string, string>,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -242,7 +242,7 @@ export class RpcProvider implements ProviderInterface {
|
|
|
242
242
|
return this.fetchEndpoint('starknet_estimateFee', {
|
|
243
243
|
request: {
|
|
244
244
|
type: 'INVOKE',
|
|
245
|
-
|
|
245
|
+
sender_address: invocation.contractAddress,
|
|
246
246
|
calldata: parseCalldata(invocation.calldata),
|
|
247
247
|
signature: bigNumberishArrayToHexadecimalStringArray(invocation.signature || []),
|
|
248
248
|
version: toHex(toBN(invocationDetails?.version || 0)),
|
|
@@ -323,7 +323,7 @@ export class RpcProvider implements ProviderInterface {
|
|
|
323
323
|
}
|
|
324
324
|
|
|
325
325
|
/**
|
|
326
|
-
* @deprecated This method
|
|
326
|
+
* @deprecated This method won't be supported, use Account.deploy instead
|
|
327
327
|
*/
|
|
328
328
|
public async deployContract(
|
|
329
329
|
{ contract, constructorCalldata, addressSalt }: DeployContractPayload,
|
|
@@ -193,7 +193,7 @@ export class SequencerProvider implements ProviderInterface {
|
|
|
193
193
|
const res = await fetch(url, {
|
|
194
194
|
method,
|
|
195
195
|
body: stringify(request),
|
|
196
|
-
headers,
|
|
196
|
+
headers: headers as Record<string, string>,
|
|
197
197
|
});
|
|
198
198
|
const textResponse = await res.text();
|
|
199
199
|
if (!res.ok) {
|
|
@@ -326,6 +326,9 @@ export class SequencerProvider implements ProviderInterface {
|
|
|
326
326
|
}).then(this.responseParser.parseInvokeFunctionResponse);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
/**
|
|
330
|
+
* @deprecated This method won't be supported, use Account.deploy instead
|
|
331
|
+
*/
|
|
329
332
|
public async deployContract({
|
|
330
333
|
contract,
|
|
331
334
|
constructorCalldata,
|
package/src/types/lib.ts
CHANGED
package/src/types/provider.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
RawCalldata,
|
|
13
13
|
Signature,
|
|
14
14
|
Status,
|
|
15
|
+
UniversalDeployerContractPayload,
|
|
15
16
|
} from './lib';
|
|
16
17
|
|
|
17
18
|
export interface GetBlockResponse {
|
|
@@ -131,4 +132,8 @@ export type EstimateFeeAction =
|
|
|
131
132
|
| {
|
|
132
133
|
type: 'DEPLOY_ACCOUNT';
|
|
133
134
|
payload: DeployAccountContractPayload;
|
|
135
|
+
}
|
|
136
|
+
| {
|
|
137
|
+
type: 'DEPLOY';
|
|
138
|
+
payload: UniversalDeployerContractPayload;
|
|
134
139
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import elliptic from 'elliptic';
|
|
2
2
|
import hashJS from 'hash.js';
|
|
3
3
|
import assert from 'minimalistic-assert';
|
|
4
4
|
|
|
@@ -7,6 +7,8 @@ import { KeyPair, Signature } from '../types';
|
|
|
7
7
|
import { addHexPrefix, removeHexPrefix, sanitizeBytes } from './encode';
|
|
8
8
|
import { BigNumberish, assertInRange, toBN, toHex } from './number';
|
|
9
9
|
|
|
10
|
+
const { ec: EC, curves } = elliptic;
|
|
11
|
+
|
|
10
12
|
export const ec = new EC(
|
|
11
13
|
new curves.PresetCurve({
|
|
12
14
|
type: 'short',
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import isomorphicFetch from 'isomorphic-fetch';
|
|
2
|
+
|
|
1
3
|
export default (typeof window !== 'undefined' && window.fetch) || // use buildin fetch in browser if available
|
|
2
4
|
(typeof global !== 'undefined' && global.fetch) || // use buildin fetch in node, react-native and service worker if available
|
|
3
|
-
//
|
|
4
|
-
require('isomorphic-fetch'); // ponyfill fetch in node and browsers that don't have it
|
|
5
|
+
isomorphicFetch; // ponyfill fetch in node and browsers that don't have it
|
package/src/utils/hash.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable import/extensions */
|
|
1
2
|
import BN from 'bn.js';
|
|
2
|
-
import { keccak256 } from 'ethereum-cryptography/keccak';
|
|
3
|
-
import { hexToBytes } from 'ethereum-cryptography/utils';
|
|
3
|
+
import { keccak256 } from 'ethereum-cryptography/keccak.js';
|
|
4
|
+
import { hexToBytes } from 'ethereum-cryptography/utils.js';
|
|
4
5
|
import assert from 'minimalistic-assert';
|
|
5
6
|
|
|
6
7
|
import {
|
package/src/utils/number.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BN
|
|
1
|
+
import BN from 'bn.js';
|
|
2
2
|
import assert from 'minimalistic-assert';
|
|
3
3
|
|
|
4
4
|
import { addHexPrefix, removeHexPrefix } from './encode';
|
|
@@ -28,7 +28,7 @@ export function hexToDecimalString(hex: string): string {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export function toFelt(num: BigNumberish): string {
|
|
31
|
-
if (isBN(num)) {
|
|
31
|
+
if (BN.isBN(num)) {
|
|
32
32
|
return num.toString();
|
|
33
33
|
}
|
|
34
34
|
return toBN(num).toString();
|
package/tsup.config.ts
ADDED
package/account/default.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ProviderInterface, ProviderOptions } from '../provider';
|
|
2
|
-
import { Provider } from '../provider/default';
|
|
3
|
-
import { BlockIdentifier } from '../provider/utils';
|
|
4
|
-
import { SignerInterface } from '../signer';
|
|
5
|
-
import { Abi, Call, DeclareContractResponse, DeployContractResponse, EstimateFeeAction, InvocationsDetails, InvokeFunctionResponse, KeyPair, Signature } from '../types';
|
|
6
|
-
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
7
|
-
import { AllowArray, DeclareContractPayload, DeployAccountContractPayload, UniversalDeployerContractPayload } from '../types/lib';
|
|
8
|
-
import { BigNumberish } from '../utils/number';
|
|
9
|
-
import { TypedData } from '../utils/typedData';
|
|
10
|
-
import { AccountInterface } from './interface';
|
|
11
|
-
export declare class Account extends Provider implements AccountInterface {
|
|
12
|
-
signer: SignerInterface;
|
|
13
|
-
address: string;
|
|
14
|
-
constructor(providerOrOptions: ProviderOptions | ProviderInterface, address: string, keyPairOrSigner: KeyPair | SignerInterface);
|
|
15
|
-
getNonce(blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
|
|
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>;
|
|
25
|
-
signMessage(typedData: TypedData): Promise<Signature>;
|
|
26
|
-
hashMessage(typedData: TypedData): Promise<string>;
|
|
27
|
-
verifyMessageHash(hash: BigNumberish, signature: Signature): Promise<boolean>;
|
|
28
|
-
verifyMessage(typedData: TypedData, signature: Signature): Promise<boolean>;
|
|
29
|
-
getSuggestedMaxFee(estimateFeeAction: EstimateFeeAction, details: EstimateFeeDetails): Promise<string>;
|
|
30
|
-
}
|