starknet 3.18.2 → 3.19.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 +53 -0
- package/__tests__/account.test.ts +11 -56
- package/__tests__/contract.test.ts +11 -49
- package/__tests__/defaultProvider.test.ts +321 -0
- package/__tests__/fixtures.ts +32 -11
- package/__tests__/rpcProvider.test.ts +17 -0
- package/__tests__/sequencerProvider.test.ts +45 -0
- package/account/default.d.ts +54 -77
- package/account/default.js +271 -596
- package/account/index.js +18 -31
- package/account/interface.d.ts +66 -95
- package/account/interface.js +20 -30
- package/constants.d.ts +17 -19
- package/constants.js +2038 -2059
- package/contract/contractFactory.d.ts +25 -29
- package/contract/contractFactory.js +94 -210
- package/contract/default.d.ts +117 -146
- package/contract/default.js +582 -776
- package/contract/index.js +19 -32
- package/contract/interface.d.ts +72 -92
- package/contract/interface.js +6 -5
- package/dist/account/default.d.ts +5 -9
- package/dist/account/default.js +35 -169
- package/dist/account/interface.d.ts +3 -15
- package/dist/contract/contractFactory.js +4 -4
- package/dist/contract/default.d.ts +3 -3
- package/dist/contract/default.js +3 -2
- package/dist/contract/interface.d.ts +2 -2
- package/dist/provider/default.d.ts +18 -134
- package/dist/provider/default.js +47 -411
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.js +2 -0
- package/dist/provider/interface.d.ts +45 -50
- package/dist/provider/rpc.d.ts +57 -0
- package/dist/provider/rpc.js +364 -0
- package/dist/provider/sequencer.d.ts +66 -0
- package/dist/provider/sequencer.js +443 -0
- package/dist/types/account.d.ts +2 -3
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.js +18 -0
- package/dist/types/api/rpc.d.ts +221 -0
- package/dist/types/{api.js → api/rpc.js} +0 -0
- package/dist/types/api/sequencer.d.ts +289 -0
- package/dist/types/api/sequencer.js +2 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/types/index.js +15 -1
- package/dist/types/lib.d.ts +3 -1
- package/dist/types/provider.d.ts +86 -0
- package/dist/types/provider.js +2 -0
- package/dist/utils/provider.d.ts +4 -0
- package/dist/utils/provider.js +38 -0
- package/dist/utils/responseParser/index.d.ts +11 -0
- package/dist/utils/responseParser/index.js +9 -0
- package/dist/utils/responseParser/rpc.d.ts +13 -0
- package/dist/utils/responseParser/rpc.js +96 -0
- package/dist/utils/responseParser/sequencer.d.ts +13 -0
- package/dist/utils/responseParser/sequencer.js +124 -0
- package/index.js +42 -75
- package/package.json +1 -1
- package/provider/default.d.ts +21 -175
- package/provider/default.js +139 -704
- package/provider/errors.d.ts +4 -4
- package/provider/errors.js +30 -40
- package/provider/index.d.ts +2 -0
- package/provider/index.js +22 -33
- package/provider/interface.d.ts +104 -131
- package/provider/interface.js +6 -5
- package/provider/rpc.d.ts +57 -0
- package/provider/rpc.js +364 -0
- package/provider/sequencer.d.ts +66 -0
- package/provider/sequencer.js +443 -0
- package/provider/utils.d.ts +7 -9
- package/provider/utils.js +39 -44
- package/signer/default.d.ts +5 -9
- package/signer/default.js +72 -177
- package/signer/index.js +18 -31
- package/signer/interface.d.ts +29 -33
- package/signer/interface.js +6 -5
- package/src/account/default.ts +26 -146
- package/src/account/interface.ts +5 -20
- package/src/contract/contractFactory.ts +3 -6
- package/src/contract/default.ts +6 -4
- package/src/contract/interface.ts +2 -2
- package/src/provider/default.ts +63 -395
- package/src/provider/index.ts +2 -0
- package/src/provider/interface.ts +68 -63
- package/src/provider/rpc.ts +300 -0
- package/src/provider/sequencer.ts +384 -0
- package/src/types/account.ts +2 -3
- package/src/types/api/index.ts +17 -0
- package/src/types/api/rpc.ts +247 -0
- package/src/types/api/sequencer.ts +331 -0
- package/src/types/index.ts +3 -1
- package/src/types/lib.ts +3 -1
- package/src/types/provider.ts +108 -0
- package/src/utils/provider.ts +28 -0
- package/src/utils/responseParser/index.ts +28 -0
- package/src/utils/responseParser/rpc.ts +93 -0
- package/src/utils/responseParser/sequencer.ts +127 -0
- package/types/account.d.ts +5 -7
- package/types/account.js +2 -2
- package/types/api/index.d.ts +16 -0
- package/types/api/index.js +18 -0
- package/types/api/rpc.d.ts +221 -0
- package/types/api/rpc.js +2 -0
- package/types/api/sequencer.d.ts +289 -0
- package/types/api/sequencer.js +2 -0
- package/types/contract.d.ts +1 -1
- package/types/contract.js +2 -2
- package/types/index.d.ts +3 -1
- package/types/index.js +35 -34
- package/types/lib.d.ts +36 -41
- package/types/lib.js +2 -2
- package/types/provider.d.ts +86 -0
- package/types/provider.js +2 -0
- package/types/signer.d.ts +2 -2
- package/types/signer.js +2 -2
- package/utils/address.js +26 -37
- package/utils/ellipticCurve.d.ts +1 -6
- package/utils/ellipticCurve.js +73 -137
- package/utils/encode.js +49 -85
- package/utils/hash.d.ts +4 -31
- package/utils/hash.js +76 -141
- package/utils/json.d.ts +13 -45
- package/utils/json.js +15 -22
- package/utils/number.d.ts +2 -9
- package/utils/number.js +47 -81
- package/utils/provider.d.ts +4 -0
- package/utils/provider.js +38 -0
- package/utils/responseParser/index.d.ts +11 -0
- package/utils/responseParser/index.js +9 -0
- package/utils/responseParser/rpc.d.ts +13 -0
- package/utils/responseParser/rpc.js +96 -0
- package/utils/responseParser/sequencer.d.ts +13 -0
- package/utils/responseParser/sequencer.js +124 -0
- package/utils/shortString.js +13 -21
- package/utils/stark.d.ts +0 -1
- package/utils/stark.js +59 -93
- package/utils/transaction.d.ts +3 -6
- package/utils/transaction.js +50 -81
- package/utils/typedData/index.d.ts +3 -15
- package/utils/typedData/index.js +109 -175
- package/utils/typedData/types.d.ts +9 -9
- package/utils/typedData/types.js +2 -2
- package/utils/typedData/utils.js +6 -6
- package/utils/uint256.d.ts +5 -5
- package/utils/uint256.js +16 -26
- package/www/docs/API/account.md +3 -4
- package/www/docs/API/contract.md +2 -2
- package/www/docs/API/contractFactory.md +2 -2
- package/www/docs/API/provider.md +185 -74
- package/www/guides/account.md +1 -8
- package/www/guides/erc20.md +3 -0
- package/__tests__/provider.test.ts +0 -168
- package/dist/types/api.d.ts +0 -261
- package/src/types/api.ts +0 -303
- package/types/api.d.ts +0 -287
- package/types/api.js +0 -2
package/contract/index.js
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
});
|
|
22
|
-
var __exportStar =
|
|
23
|
-
(this && this.__exportStar) ||
|
|
24
|
-
function (m, exports) {
|
|
25
|
-
for (var p in m)
|
|
26
|
-
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
27
|
-
__createBinding(exports, m, p);
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
30
|
-
__exportStar(require('./default'), exports);
|
|
31
|
-
__exportStar(require('./interface'), exports);
|
|
32
|
-
__exportStar(require('./contractFactory'), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./default"), exports);
|
|
18
|
+
__exportStar(require("./interface"), exports);
|
|
19
|
+
__exportStar(require("./contractFactory"), exports);
|
package/contract/interface.d.ts
CHANGED
|
@@ -1,97 +1,77 @@
|
|
|
1
1
|
import { AccountInterface } from '../account';
|
|
2
2
|
import { ProviderInterface } from '../provider';
|
|
3
3
|
import { BlockIdentifier } from '../provider/utils';
|
|
4
|
-
import {
|
|
5
|
-
Abi,
|
|
6
|
-
AddTransactionResponse,
|
|
7
|
-
AsyncContractFunction,
|
|
8
|
-
ContractFunction,
|
|
9
|
-
Invocation,
|
|
10
|
-
Overrides,
|
|
11
|
-
Result,
|
|
12
|
-
} from '../types';
|
|
4
|
+
import { Abi, AsyncContractFunction, ContractFunction, Invocation, InvokeFunctionResponse, Overrides, Result } from '../types';
|
|
13
5
|
export declare abstract class ContractInterface {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
options?:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
args?: Array<any
|
|
85
|
-
options?: {
|
|
86
|
-
blockIdentifier?: BlockIdentifier;
|
|
87
|
-
}
|
|
88
|
-
): Promise<any>;
|
|
89
|
-
/**
|
|
90
|
-
* Calls a method on a contract
|
|
91
|
-
*
|
|
92
|
-
* @param method name of the method
|
|
93
|
-
* @param args Array of the arguments for the call
|
|
94
|
-
* @returns Invocation objet
|
|
95
|
-
*/
|
|
96
|
-
abstract populate(method: string, args?: Array<any>): Invocation;
|
|
6
|
+
abstract abi: Abi;
|
|
7
|
+
abstract address: string;
|
|
8
|
+
abstract providerOrAccount: ProviderInterface | AccountInterface;
|
|
9
|
+
abstract deployTransactionHash?: string;
|
|
10
|
+
readonly functions: {
|
|
11
|
+
[name: string]: AsyncContractFunction;
|
|
12
|
+
};
|
|
13
|
+
readonly callStatic: {
|
|
14
|
+
[name: string]: AsyncContractFunction;
|
|
15
|
+
};
|
|
16
|
+
readonly populateTransaction: {
|
|
17
|
+
[name: string]: ContractFunction;
|
|
18
|
+
};
|
|
19
|
+
readonly estimateFee: {
|
|
20
|
+
[name: string]: ContractFunction;
|
|
21
|
+
};
|
|
22
|
+
readonly [key: string]: AsyncContractFunction | any;
|
|
23
|
+
/**
|
|
24
|
+
* Saves the address of the contract deployed on network that will be used for interaction
|
|
25
|
+
*
|
|
26
|
+
* @param address - address of the contract
|
|
27
|
+
*/
|
|
28
|
+
abstract attach(address: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Attaches to new Provider or Account
|
|
31
|
+
*
|
|
32
|
+
* @param providerOrAccount - new Provider or Account to attach to
|
|
33
|
+
*/
|
|
34
|
+
abstract connect(providerOrAccount: ProviderInterface | AccountInterface): void;
|
|
35
|
+
/**
|
|
36
|
+
* Resolves when contract is deployed on the network or when no deployment transaction is found
|
|
37
|
+
*
|
|
38
|
+
* @returns Promise that resolves when contract is deployed on the network or when no deployment transaction is found
|
|
39
|
+
* @throws When deployment fails
|
|
40
|
+
*/
|
|
41
|
+
abstract deployed(): Promise<ContractInterface>;
|
|
42
|
+
/**
|
|
43
|
+
* Calls a method on a contract
|
|
44
|
+
*
|
|
45
|
+
* @param method name of the method
|
|
46
|
+
* @param args Array of the arguments for the call
|
|
47
|
+
* @returns Result of the call as an array with key value pars
|
|
48
|
+
*/
|
|
49
|
+
abstract call(method: string, args?: Array<any>, options?: {
|
|
50
|
+
blockIdentifier?: BlockIdentifier;
|
|
51
|
+
}): Promise<Result>;
|
|
52
|
+
/**
|
|
53
|
+
* Invokes a method on a contract
|
|
54
|
+
*
|
|
55
|
+
* @param method name of the method
|
|
56
|
+
* @param args Array of the arguments for the invoke
|
|
57
|
+
* @returns Add Transaction Response
|
|
58
|
+
*/
|
|
59
|
+
abstract invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Calls a method on a contract
|
|
62
|
+
*
|
|
63
|
+
* @param method name of the method
|
|
64
|
+
* @param args Array of the arguments for the call
|
|
65
|
+
*/
|
|
66
|
+
abstract estimate(method: string, args?: Array<any>, options?: {
|
|
67
|
+
blockIdentifier?: BlockIdentifier;
|
|
68
|
+
}): Promise<any>;
|
|
69
|
+
/**
|
|
70
|
+
* Calls a method on a contract
|
|
71
|
+
*
|
|
72
|
+
* @param method name of the method
|
|
73
|
+
* @param args Array of the arguments for the call
|
|
74
|
+
* @returns Invocation objet
|
|
75
|
+
*/
|
|
76
|
+
abstract populate(method: string, args?: Array<any>): Invocation;
|
|
97
77
|
}
|
package/contract/interface.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContractInterface = void 0;
|
|
4
4
|
var ContractInterface = /** @class */ (function () {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function ContractInterface() {
|
|
6
|
+
}
|
|
7
|
+
return ContractInterface;
|
|
8
|
+
}());
|
|
8
9
|
exports.ContractInterface = ContractInterface;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProviderInterface, ProviderOptions } from '../provider';
|
|
2
|
+
import { Provider } from '../provider/default';
|
|
2
3
|
import { SignerInterface } from '../signer';
|
|
3
|
-
import { Abi,
|
|
4
|
+
import { Abi, Call, InvocationsDetails, InvokeFunctionResponse, KeyPair, Signature } from '../types';
|
|
4
5
|
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
5
6
|
import { BigNumberish } from '../utils/number';
|
|
6
7
|
import { TypedData } from '../utils/typedData';
|
|
@@ -8,7 +9,7 @@ import { AccountInterface } from './interface';
|
|
|
8
9
|
export declare class Account extends Provider implements AccountInterface {
|
|
9
10
|
address: string;
|
|
10
11
|
signer: SignerInterface;
|
|
11
|
-
constructor(
|
|
12
|
+
constructor(providerOrOptions: ProviderOptions | ProviderInterface, address: string, keyPairOrSigner: KeyPair | SignerInterface);
|
|
12
13
|
getNonce(): Promise<string>;
|
|
13
14
|
estimateFee(calls: Call | Call[], { nonce: providedNonce, blockIdentifier }?: EstimateFeeDetails): Promise<EstimateFee>;
|
|
14
15
|
/**
|
|
@@ -21,12 +22,7 @@ export declare class Account extends Provider implements AccountInterface {
|
|
|
21
22
|
* @param transactionsDetail - optional transaction details
|
|
22
23
|
* @returns a confirmation of invoking a function on the starknet contract
|
|
23
24
|
*/
|
|
24
|
-
execute(calls: Call | Call[], abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<
|
|
25
|
-
/**
|
|
26
|
-
* Temporary method to allow dapps on starknet.js v2 to work with Argent X v3
|
|
27
|
-
* @deprecated to remove ASAP
|
|
28
|
-
*/
|
|
29
|
-
LEGACY_addTransaction(transaction: Transaction): Promise<AddTransactionResponse>;
|
|
25
|
+
execute(calls: Call | Call[], abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
30
26
|
/**
|
|
31
27
|
* Sign an JSON object with the starknet private key and return the signature
|
|
32
28
|
*
|
package/dist/account/default.js
CHANGED
|
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
29
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
30
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -50,54 +61,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
61
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
62
|
}
|
|
52
63
|
};
|
|
53
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
54
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
55
|
-
if (!m) return o;
|
|
56
|
-
var i = m.call(o), r, ar = [], e;
|
|
57
|
-
try {
|
|
58
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
59
|
-
}
|
|
60
|
-
catch (error) { e = { error: error }; }
|
|
61
|
-
finally {
|
|
62
|
-
try {
|
|
63
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
64
|
-
}
|
|
65
|
-
finally { if (e) throw e.error; }
|
|
66
|
-
}
|
|
67
|
-
return ar;
|
|
68
|
-
};
|
|
69
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
70
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
71
|
-
if (ar || !(i in from)) {
|
|
72
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
73
|
-
ar[i] = from[i];
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
77
|
-
};
|
|
78
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
79
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
80
|
-
};
|
|
81
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
82
65
|
exports.Account = void 0;
|
|
83
|
-
var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
|
|
84
66
|
var constants_1 = require("../constants");
|
|
85
|
-
var
|
|
67
|
+
var default_1 = require("../provider/default");
|
|
86
68
|
var signer_1 = require("../signer");
|
|
87
|
-
var ellipticCurve_1 = require("../utils/ellipticCurve");
|
|
88
69
|
var hash_1 = require("../utils/hash");
|
|
89
70
|
var number_1 = require("../utils/number");
|
|
90
|
-
var shortString_1 = require("../utils/shortString");
|
|
91
71
|
var stark_1 = require("../utils/stark");
|
|
92
72
|
var transaction_1 = require("../utils/transaction");
|
|
93
73
|
var typedData_1 = require("../utils/typedData");
|
|
94
74
|
var Account = /** @class */ (function (_super) {
|
|
95
75
|
__extends(Account, _super);
|
|
96
|
-
function Account(
|
|
97
|
-
var _this = _super.call(this,
|
|
76
|
+
function Account(providerOrOptions, address, keyPairOrSigner) {
|
|
77
|
+
var _this = _super.call(this, providerOrOptions) || this;
|
|
78
|
+
_this.address = address;
|
|
98
79
|
_this.signer =
|
|
99
80
|
'getPubKey' in keyPairOrSigner ? keyPairOrSigner : new signer_1.Signer(keyPairOrSigner);
|
|
100
|
-
_this.address = address;
|
|
101
81
|
return _this;
|
|
102
82
|
}
|
|
103
83
|
Account.prototype.getNonce = function () {
|
|
@@ -117,23 +97,22 @@ var Account = /** @class */ (function (_super) {
|
|
|
117
97
|
});
|
|
118
98
|
};
|
|
119
99
|
Account.prototype.estimateFee = function (calls, _a) {
|
|
120
|
-
var _b;
|
|
121
|
-
var _c = _a === void 0 ? {} : _a, providedNonce = _c.nonce, _d = _c.blockIdentifier, blockIdentifier = _d === void 0 ? 'pending' : _d;
|
|
100
|
+
var _b = _a === void 0 ? {} : _a, providedNonce = _b.nonce, blockIdentifier = _b.blockIdentifier;
|
|
122
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
123
|
-
var transactions, nonce,
|
|
124
|
-
return __generator(this, function (
|
|
125
|
-
switch (
|
|
102
|
+
var transactions, nonce, _c, version, signerDetails, signature, calldata, response, suggestedMaxFee;
|
|
103
|
+
return __generator(this, function (_d) {
|
|
104
|
+
switch (_d.label) {
|
|
126
105
|
case 0:
|
|
127
106
|
transactions = Array.isArray(calls) ? calls : [calls];
|
|
128
107
|
if (!(providedNonce !== null && providedNonce !== void 0)) return [3 /*break*/, 1];
|
|
129
|
-
|
|
108
|
+
_c = providedNonce;
|
|
130
109
|
return [3 /*break*/, 3];
|
|
131
110
|
case 1: return [4 /*yield*/, this.getNonce()];
|
|
132
111
|
case 2:
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
_c = (_d.sent());
|
|
113
|
+
_d.label = 3;
|
|
135
114
|
case 3:
|
|
136
|
-
nonce =
|
|
115
|
+
nonce = _c;
|
|
137
116
|
version = (0, number_1.toBN)(hash_1.feeTransactionVersion);
|
|
138
117
|
signerDetails = {
|
|
139
118
|
walletAddress: this.address,
|
|
@@ -144,27 +123,13 @@ var Account = /** @class */ (function (_super) {
|
|
|
144
123
|
};
|
|
145
124
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails)];
|
|
146
125
|
case 4:
|
|
147
|
-
signature =
|
|
126
|
+
signature = _d.sent();
|
|
148
127
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
149
|
-
return [4 /*yield*/, this.
|
|
150
|
-
contract_address: this.address,
|
|
151
|
-
entry_point_selector: (0, hash_1.getSelectorFromName)('__execute__'),
|
|
152
|
-
calldata: calldata,
|
|
153
|
-
version: (0, number_1.toHex)(version),
|
|
154
|
-
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature),
|
|
155
|
-
})];
|
|
128
|
+
return [4 /*yield*/, _super.prototype.getEstimateFee.call(this, { contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, blockIdentifier, { version: version })];
|
|
156
129
|
case 5:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
throw new Error('Expected either amount or overall_fee in estimate_fee response');
|
|
161
|
-
}
|
|
162
|
-
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(fee);
|
|
163
|
-
return [2 /*return*/, {
|
|
164
|
-
amount: fee,
|
|
165
|
-
unit: fetchedEstimate.unit,
|
|
166
|
-
suggestedMaxFee: suggestedMaxFee,
|
|
167
|
-
}];
|
|
130
|
+
response = _d.sent();
|
|
131
|
+
suggestedMaxFee = (0, stark_1.estimatedFeeToMaxFee)(response.overall_fee);
|
|
132
|
+
return [2 /*return*/, __assign(__assign({}, response), { suggestedMaxFee: suggestedMaxFee })];
|
|
168
133
|
}
|
|
169
134
|
});
|
|
170
135
|
});
|
|
@@ -184,7 +149,7 @@ var Account = /** @class */ (function (_super) {
|
|
|
184
149
|
if (abis === void 0) { abis = undefined; }
|
|
185
150
|
if (transactionsDetail === void 0) { transactionsDetail = {}; }
|
|
186
151
|
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
-
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, signerDetails, signature, calldata;
|
|
152
|
+
var transactions, nonce, _b, _c, maxFee, suggestedMaxFee, version, signerDetails, signature, calldata;
|
|
188
153
|
return __generator(this, function (_d) {
|
|
189
154
|
switch (_d.label) {
|
|
190
155
|
case 0:
|
|
@@ -209,120 +174,21 @@ var Account = /** @class */ (function (_super) {
|
|
|
209
174
|
maxFee = suggestedMaxFee.toString();
|
|
210
175
|
_d.label = 6;
|
|
211
176
|
case 6:
|
|
177
|
+
version = (0, number_1.toBN)(hash_1.transactionVersion);
|
|
212
178
|
signerDetails = {
|
|
213
179
|
walletAddress: this.address,
|
|
214
180
|
nonce: nonce,
|
|
215
181
|
maxFee: maxFee,
|
|
216
|
-
version:
|
|
182
|
+
version: version,
|
|
217
183
|
chainId: this.chainId,
|
|
218
184
|
};
|
|
219
185
|
return [4 /*yield*/, this.signer.signTransaction(transactions, signerDetails, abis)];
|
|
220
186
|
case 7:
|
|
221
187
|
signature = _d.sent();
|
|
222
188
|
calldata = (0, transaction_1.fromCallsToExecuteCalldataWithNonce)(transactions, nonce);
|
|
223
|
-
return [2 /*return*/, this.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
entry_point_selector: (0, hash_1.getSelectorFromName)('__execute__'),
|
|
227
|
-
calldata: calldata,
|
|
228
|
-
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature),
|
|
229
|
-
max_fee: (0, number_1.toHex)((0, number_1.toBN)(maxFee)),
|
|
230
|
-
})];
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
};
|
|
235
|
-
/**
|
|
236
|
-
* Temporary method to allow dapps on starknet.js v2 to work with Argent X v3
|
|
237
|
-
* @deprecated to remove ASAP
|
|
238
|
-
*/
|
|
239
|
-
Account.prototype.LEGACY_addTransaction = function (transaction) {
|
|
240
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
-
function hashMulticall(account, transactions, nonce, maxFee) {
|
|
242
|
-
var hashArray = transactions
|
|
243
|
-
.map(function (_a) {
|
|
244
|
-
var contract_address = _a.contract_address, entry_point_selector = _a.entry_point_selector, calldata = _a.calldata;
|
|
245
|
-
return [
|
|
246
|
-
contract_address,
|
|
247
|
-
entry_point_selector,
|
|
248
|
-
(0, hash_1.computeHashOnElements)(calldata || []),
|
|
249
|
-
];
|
|
250
|
-
})
|
|
251
|
-
.map(number_1.bigNumberishArrayToDecimalStringArray)
|
|
252
|
-
.map(hash_1.computeHashOnElements);
|
|
253
|
-
return (0, hash_1.computeHashOnElements)([
|
|
254
|
-
(0, shortString_1.encodeShortString)('StarkNet Transaction'),
|
|
255
|
-
account,
|
|
256
|
-
(0, hash_1.computeHashOnElements)(hashArray),
|
|
257
|
-
nonce,
|
|
258
|
-
maxFee,
|
|
259
|
-
hash_1.transactionVersion,
|
|
260
|
-
]);
|
|
261
|
-
}
|
|
262
|
-
var nonceBn, result, msgHash, signature, transformCallsToMulticallArrays, fromCallsToExecuteCalldata2, calldata;
|
|
263
|
-
return __generator(this, function (_a) {
|
|
264
|
-
switch (_a.label) {
|
|
265
|
-
case 0:
|
|
266
|
-
if (transaction.type === 'DEPLOY')
|
|
267
|
-
throw new Error('No DEPLOYS');
|
|
268
|
-
if (transaction.type === 'DECLARE')
|
|
269
|
-
throw new Error('No DECLARES');
|
|
270
|
-
(0, minimalistic_assert_1.default)(!transaction.signature, "Adding signatures to a signer transaction currently isn't supported");
|
|
271
|
-
if (!transaction.nonce) return [3 /*break*/, 1];
|
|
272
|
-
nonceBn = (0, number_1.toBN)(transaction.nonce);
|
|
273
|
-
return [3 /*break*/, 3];
|
|
274
|
-
case 1: return [4 /*yield*/, this.callContract({
|
|
275
|
-
contractAddress: this.address,
|
|
276
|
-
entrypoint: 'get_nonce',
|
|
277
|
-
})];
|
|
278
|
-
case 2:
|
|
279
|
-
result = (_a.sent()).result;
|
|
280
|
-
nonceBn = (0, number_1.toBN)(result[0]);
|
|
281
|
-
_a.label = 3;
|
|
282
|
-
case 3:
|
|
283
|
-
msgHash = hashMulticall(this.address, [transaction], nonceBn.toString(), '0');
|
|
284
|
-
if (!('keyPair' in this.signer)) {
|
|
285
|
-
throw new Error('No keyPair');
|
|
286
|
-
}
|
|
287
|
-
signature = (0, ellipticCurve_1.sign)(this.signer.keyPair, msgHash);
|
|
288
|
-
transformCallsToMulticallArrays = function (calls) {
|
|
289
|
-
var callArray = [];
|
|
290
|
-
var calldata = [];
|
|
291
|
-
calls.forEach(function (call) {
|
|
292
|
-
var data = call.calldata || [];
|
|
293
|
-
callArray.push({
|
|
294
|
-
to: (0, number_1.toBN)(call.contract_address).toString(10),
|
|
295
|
-
selector: (0, number_1.toBN)(call.entry_point_selector).toString(10),
|
|
296
|
-
data_offset: calldata.length.toString(),
|
|
297
|
-
data_len: data.length.toString(),
|
|
298
|
-
});
|
|
299
|
-
calldata.push.apply(calldata, __spreadArray([], __read(data), false));
|
|
300
|
-
});
|
|
301
|
-
return {
|
|
302
|
-
callArray: callArray,
|
|
303
|
-
calldata: (0, number_1.bigNumberishArrayToDecimalStringArray)(calldata),
|
|
304
|
-
};
|
|
305
|
-
};
|
|
306
|
-
fromCallsToExecuteCalldata2 = function (calls) {
|
|
307
|
-
var _a = transformCallsToMulticallArrays(calls), callArray = _a.callArray, calldata = _a.calldata;
|
|
308
|
-
return __spreadArray(__spreadArray(__spreadArray([
|
|
309
|
-
callArray.length.toString()
|
|
310
|
-
], __read(callArray
|
|
311
|
-
.map(function (_a) {
|
|
312
|
-
var to = _a.to, selector = _a.selector, data_offset = _a.data_offset, data_len = _a.data_len;
|
|
313
|
-
return [to, selector, data_offset, data_len];
|
|
314
|
-
})
|
|
315
|
-
.flat()), false), [
|
|
316
|
-
calldata.length.toString()
|
|
317
|
-
], false), __read(calldata), false);
|
|
318
|
-
};
|
|
319
|
-
calldata = __spreadArray(__spreadArray([], __read(fromCallsToExecuteCalldata2([transaction])), false), [nonceBn.toString()], false);
|
|
320
|
-
return [2 /*return*/, this.fetchEndpoint('add_transaction', undefined, {
|
|
321
|
-
type: 'INVOKE_FUNCTION',
|
|
322
|
-
contract_address: this.address,
|
|
323
|
-
entry_point_selector: (0, hash_1.getSelectorFromName)('__execute__'),
|
|
324
|
-
calldata: calldata,
|
|
325
|
-
signature: (0, number_1.bigNumberishArrayToDecimalStringArray)(signature),
|
|
189
|
+
return [2 /*return*/, this.invokeFunction({ contractAddress: this.address, entrypoint: '__execute__', calldata: calldata, signature: signature }, {
|
|
190
|
+
maxFee: maxFee,
|
|
191
|
+
version: version,
|
|
326
192
|
})];
|
|
327
193
|
}
|
|
328
194
|
});
|
|
@@ -413,5 +279,5 @@ var Account = /** @class */ (function (_super) {
|
|
|
413
279
|
});
|
|
414
280
|
};
|
|
415
281
|
return Account;
|
|
416
|
-
}(
|
|
282
|
+
}(default_1.Provider));
|
|
417
283
|
exports.Account = Account;
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import { ProviderInterface } from '../provider';
|
|
2
2
|
import { SignerInterface } from '../signer';
|
|
3
|
-
import { Abi,
|
|
4
|
-
import { EstimateFee, EstimateFeeDetails } from '../types/account';
|
|
3
|
+
import { Abi, Call, EstimateFeeDetails, EstimateFeeResponse, InvocationsDetails, InvokeFunctionResponse, Signature } from '../types';
|
|
5
4
|
import { BigNumberish } from '../utils/number';
|
|
6
5
|
import { TypedData } from '../utils/typedData/types';
|
|
7
6
|
export declare abstract class AccountInterface extends ProviderInterface {
|
|
8
7
|
abstract address: string;
|
|
9
8
|
abstract signer: SignerInterface;
|
|
10
|
-
/**
|
|
11
|
-
* Deploys a given compiled contract (json) to starknet
|
|
12
|
-
*
|
|
13
|
-
* @param payload payload to be deployed containing:
|
|
14
|
-
* - compiled contract code
|
|
15
|
-
* - constructor calldata
|
|
16
|
-
* - address salt
|
|
17
|
-
* @param abi the abi of the contract
|
|
18
|
-
* @returns a confirmation of sending a transaction on the starknet contract
|
|
19
|
-
*/
|
|
20
|
-
abstract deployContract(payload: DeployContractPayload, abi?: Abi): Promise<AddTransactionResponse>;
|
|
21
9
|
/**
|
|
22
10
|
* Estimate Fee for a method on starknet
|
|
23
11
|
*
|
|
@@ -29,7 +17,7 @@ export declare abstract class AccountInterface extends ProviderInterface {
|
|
|
29
17
|
*
|
|
30
18
|
* @returns response from addTransaction
|
|
31
19
|
*/
|
|
32
|
-
abstract estimateFee(calls: Call | Call[], estimateFeeDetails?: EstimateFeeDetails): Promise<
|
|
20
|
+
abstract estimateFee(calls: Call | Call[], estimateFeeDetails?: EstimateFeeDetails): Promise<EstimateFeeResponse>;
|
|
33
21
|
/**
|
|
34
22
|
* Invoke execute function in account contract
|
|
35
23
|
*
|
|
@@ -42,7 +30,7 @@ export declare abstract class AccountInterface extends ProviderInterface {
|
|
|
42
30
|
*
|
|
43
31
|
* @returns response from addTransaction
|
|
44
32
|
*/
|
|
45
|
-
abstract execute(transactions: Call | Call[], abis?: Abi[], transactionsDetail?: InvocationsDetails): Promise<
|
|
33
|
+
abstract execute(transactions: Call | Call[], abis?: Abi[], transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
|
|
46
34
|
/**
|
|
47
35
|
* Sign an JSON object for off-chain usage with the starknet private key and return the signature
|
|
48
36
|
* This adds a message prefix so it cant be interchanged with transactions
|
|
@@ -61,7 +61,7 @@ var ContractFactory = /** @class */ (function () {
|
|
|
61
61
|
*/
|
|
62
62
|
ContractFactory.prototype.deploy = function (constructorCalldata, addressSalt) {
|
|
63
63
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var _a,
|
|
64
|
+
var _a, contract_address, transaction_hash, contractInstance;
|
|
65
65
|
return __generator(this, function (_b) {
|
|
66
66
|
switch (_b.label) {
|
|
67
67
|
case 0: return [4 /*yield*/, this.providerOrAccount.deployContract({
|
|
@@ -70,9 +70,9 @@ var ContractFactory = /** @class */ (function () {
|
|
|
70
70
|
addressSalt: addressSalt,
|
|
71
71
|
})];
|
|
72
72
|
case 1:
|
|
73
|
-
_a = _b.sent(),
|
|
74
|
-
(0, minimalistic_assert_1.default)(
|
|
75
|
-
contractInstance = new default_1.Contract(this.compiledContract.abi,
|
|
73
|
+
_a = _b.sent(), contract_address = _a.contract_address, transaction_hash = _a.transaction_hash;
|
|
74
|
+
(0, minimalistic_assert_1.default)(Boolean(contract_address), 'Deployment of the contract failed');
|
|
75
|
+
contractInstance = new default_1.Contract(this.compiledContract.abi, contract_address, this.providerOrAccount);
|
|
76
76
|
contractInstance.deployTransactionHash = transaction_hash;
|
|
77
77
|
return [2 /*return*/, contractInstance];
|
|
78
78
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountInterface } from '../account';
|
|
2
2
|
import { ProviderInterface } from '../provider';
|
|
3
3
|
import { BlockIdentifier } from '../provider/utils';
|
|
4
|
-
import { Abi, AbiEntry,
|
|
4
|
+
import { Abi, AbiEntry, Args, AsyncContractFunction, Calldata, ContractFunction, Invocation, InvokeFunctionResponse, Overrides, ParsedStruct, Result, StructAbi } from '../types';
|
|
5
5
|
import { BigNumberish } from '../utils/number';
|
|
6
6
|
import { ContractInterface } from './interface';
|
|
7
7
|
export declare class Contract implements ContractInterface {
|
|
@@ -115,10 +115,10 @@ export declare class Contract implements ContractInterface {
|
|
|
115
115
|
* @return - parsed response corresponding to the abi
|
|
116
116
|
*/
|
|
117
117
|
protected parseResponse(method: string, response: string[]): Result;
|
|
118
|
-
invoke(method: string, args?: Array<any>, options?: Overrides): Promise<
|
|
118
|
+
invoke(method: string, args?: Array<any>, options?: Overrides): Promise<InvokeFunctionResponse>;
|
|
119
119
|
call(method: string, args?: Array<any>, { blockIdentifier, }?: {
|
|
120
120
|
blockIdentifier?: BlockIdentifier;
|
|
121
121
|
}): Promise<Result>;
|
|
122
|
-
estimate(method: string, args?: Array<any>): Promise<import("../types").
|
|
122
|
+
estimate(method: string, args?: Array<any>): Promise<import("../types").EstimateFeeResponse>;
|
|
123
123
|
populate(method: string, args?: Array<any>): Invocation;
|
|
124
124
|
}
|