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
package/utils/merkle.js
CHANGED
|
@@ -44,7 +44,7 @@ var MerkleTree = /** @class */ (function () {
|
|
|
44
44
|
var newLeaves = [];
|
|
45
45
|
for (var i = 0; i < leaves.length; i += 2) {
|
|
46
46
|
if (i + 1 === leaves.length) {
|
|
47
|
-
newLeaves.push(leaves[i]);
|
|
47
|
+
newLeaves.push(MerkleTree.hash(leaves[i], '0x0'));
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
50
|
newLeaves.push(MerkleTree.hash(leaves[i], leaves[i + 1]));
|
|
@@ -74,9 +74,7 @@ var MerkleTree = /** @class */ (function () {
|
|
|
74
74
|
? -1
|
|
75
75
|
: this.branches.findIndex(function (b) { return b.length === branch.length; });
|
|
76
76
|
var nextBranch = (_b = this.branches[currentBranchLevelIndex + 1]) !== null && _b !== void 0 ? _b : [this.root];
|
|
77
|
-
return this.getProof(neededBranch
|
|
78
|
-
? leaf
|
|
79
|
-
: MerkleTree.hash(isLeft ? leaf : neededBranch, isLeft ? neededBranch : leaf), nextBranch, newHashPath);
|
|
77
|
+
return this.getProof(MerkleTree.hash(isLeft ? leaf : neededBranch, isLeft ? neededBranch : leaf), nextBranch, newHashPath);
|
|
80
78
|
};
|
|
81
79
|
return MerkleTree;
|
|
82
80
|
}());
|
package/utils/number.d.ts
CHANGED
|
@@ -13,3 +13,4 @@ export declare const toHexString: (value: string) => string;
|
|
|
13
13
|
export declare function getDecimalString(value: string): string;
|
|
14
14
|
export declare function getHexString(value: string): string;
|
|
15
15
|
export declare function getHexStringArray(value: Array<string>): string[];
|
|
16
|
+
export declare const toCairoBool: (value: boolean) => string;
|
package/utils/number.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getHexStringArray = exports.getHexString = exports.getDecimalString = exports.toHexString = exports.isStringWholeNumber = exports.bigNumberishArrayToHexadecimalStringArray = exports.bigNumberishArrayToDecimalStringArray = exports.assertInRange = exports.toFelt = exports.hexToDecimalString = exports.toHex = exports.toBN = exports.isHex = void 0;
|
|
29
|
+
exports.toCairoBool = exports.getHexStringArray = exports.getHexString = exports.getDecimalString = exports.toHexString = exports.isStringWholeNumber = exports.bigNumberishArrayToHexadecimalStringArray = exports.bigNumberishArrayToDecimalStringArray = exports.assertInRange = exports.toFelt = exports.hexToDecimalString = exports.toHex = exports.toBN = exports.isHex = void 0;
|
|
30
30
|
var bn_js_1 = __importStar(require("bn.js"));
|
|
31
31
|
var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
|
|
32
32
|
var encode_1 = require("./encode");
|
|
@@ -108,3 +108,5 @@ function getHexStringArray(value) {
|
|
|
108
108
|
return value.map(function (el) { return getHexString(el); });
|
|
109
109
|
}
|
|
110
110
|
exports.getHexStringArray = getHexStringArray;
|
|
111
|
+
var toCairoBool = function (value) { return (+value).toString(); };
|
|
112
|
+
exports.toCairoBool = toCairoBool;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Map RPC Response to common interface response
|
|
3
3
|
* Intersection (sequencer response ∩ (∪ rpc responses))
|
|
4
4
|
*/
|
|
5
|
-
import { CallContractResponse, EstimateFeeResponse, GetBlockResponse,
|
|
5
|
+
import { CallContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionResponse } from '../../types';
|
|
6
6
|
import { RPC } from '../../types/api';
|
|
7
7
|
import { ResponseParser } from '.';
|
|
8
8
|
declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
|
|
@@ -11,13 +11,9 @@ declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
|
|
|
11
11
|
declare type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
14
|
-
declare
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
};
|
|
17
|
-
export declare class RPCResponseParser implements Omit<ResponseParser, 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse'> {
|
|
14
|
+
export declare class RPCResponseParser implements Omit<ResponseParser, 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse' | 'parseGetTransactionReceiptResponse'> {
|
|
18
15
|
parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse;
|
|
19
16
|
parseGetTransactionResponse(res: GetTransactionByHashResponse): GetTransactionResponse;
|
|
20
|
-
parseGetTransactionReceiptResponse(res: TransactionReceipt): GetTransactionReceiptResponse;
|
|
21
17
|
parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse;
|
|
22
18
|
parseCallContractResponse(res: Array<string>): CallContractResponse;
|
|
23
19
|
}
|
|
@@ -27,17 +27,6 @@ var RPCResponseParser = /** @class */ (function () {
|
|
|
27
27
|
version: res.version,
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
RPCResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
|
|
31
|
-
return {
|
|
32
|
-
transaction_hash: res.transaction_hash,
|
|
33
|
-
actual_fee: res.actual_fee,
|
|
34
|
-
status: res.status,
|
|
35
|
-
status_data: res.status_data,
|
|
36
|
-
messages_sent: res.messages_sent,
|
|
37
|
-
l1_origin_message: res.l1_origin_message,
|
|
38
|
-
events: res.events,
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
30
|
RPCResponseParser.prototype.parseFeeEstimateResponse = function (res) {
|
|
42
31
|
return {
|
|
43
32
|
overall_fee: (0, number_1.toBN)(res.overall_fee),
|
|
@@ -40,25 +40,15 @@ var SequencerAPIResponseParser = /** @class */ (function (_super) {
|
|
|
40
40
|
.filter(Boolean) });
|
|
41
41
|
};
|
|
42
42
|
SequencerAPIResponseParser.prototype.parseGetTransactionResponse = function (res) {
|
|
43
|
-
return {
|
|
44
|
-
calldata: 'calldata' in res.transaction ? res.transaction.calldata : [],
|
|
45
|
-
contract_address: 'contract_address' in res.transaction ? res.transaction.contract_address : undefined,
|
|
46
|
-
contract_class: 'contract_class' in res.transaction ? res.transaction.contract_class : undefined,
|
|
47
|
-
entry_point_selector: 'entry_point_selector' in res.transaction
|
|
43
|
+
return __assign(__assign({}, res), { calldata: 'calldata' in res.transaction ? res.transaction.calldata : [], contract_address: 'contract_address' in res.transaction ? res.transaction.contract_address : undefined, contract_class: 'contract_class' in res.transaction ? res.transaction.contract_class : undefined, entry_point_selector: 'entry_point_selector' in res.transaction
|
|
48
44
|
? res.transaction.entry_point_selector
|
|
49
|
-
: undefined,
|
|
50
|
-
max_fee: 'max_fee' in res.transaction ? res.transaction.max_fee : undefined,
|
|
51
|
-
nonce: res.transaction.nonce,
|
|
52
|
-
sender_address: 'sender_address' in res.transaction
|
|
45
|
+
: undefined, max_fee: 'max_fee' in res.transaction ? res.transaction.max_fee : undefined, nonce: res.transaction.nonce, sender_address: 'sender_address' in res.transaction
|
|
53
46
|
? res.transaction.sender_address
|
|
54
|
-
: undefined,
|
|
55
|
-
signature: 'signature' in res.transaction ? res.transaction.signature : undefined,
|
|
56
|
-
transaction_hash: 'transaction_hash' in res.transaction ? res.transaction.transaction_hash : undefined,
|
|
57
|
-
version: 'version' in res.transaction ? res.transaction.version : undefined,
|
|
58
|
-
};
|
|
47
|
+
: undefined, signature: 'signature' in res.transaction ? res.transaction.signature : undefined, transaction_hash: 'transaction_hash' in res.transaction ? res.transaction.transaction_hash : undefined, version: 'version' in res.transaction ? res.transaction.version : undefined });
|
|
59
48
|
};
|
|
60
49
|
SequencerAPIResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
|
|
61
50
|
return __assign(__assign(__assign(__assign(__assign(__assign(__assign({ transaction_hash: res.transaction_hash, status: res.status, messages_sent: res.l2_to_l1_messages, events: res.events }, ('block_hash' in res && { block_hash: res.block_hash })), ('block_number' in res && { block_number: res.block_number })), ('actual_fee' in res && { actual_fee: res.actual_fee })), ('transaction_index' in res && { transaction_index: res.transaction_index })), ('execution_resources' in res && { execution_resources: res.execution_resources })), ('l1_to_l2_consumed_message' in res && {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
62
52
|
l1_to_l2_consumed_message: res['l1_to_l2_consumed_message'],
|
|
63
53
|
})), ('transaction_failure_reason' in res && {
|
|
64
54
|
transaction_failure_reason: res.transaction_failure_reason,
|
package/www/docs/API/account.md
CHANGED
|
@@ -24,20 +24,82 @@ The address of the account contract.
|
|
|
24
24
|
|
|
25
25
|
## Methods
|
|
26
26
|
|
|
27
|
-
account.**getNonce()** => _Promise < BigNumberish >_
|
|
27
|
+
account.**getNonce(blockIdentifier)** => _Promise < BigNumberish >_
|
|
28
28
|
|
|
29
|
-
Gets the
|
|
29
|
+
Gets the nonce of the account with respect to a specific block.
|
|
30
|
+
|
|
31
|
+
_blockIdentifier_ - optional blockIdentifier. Defaults to 'pending'.
|
|
32
|
+
|
|
33
|
+
Returns the nonce of the account.
|
|
34
|
+
|
|
35
|
+
<hr />
|
|
36
|
+
|
|
37
|
+
account.**estimateInvokeFee**(calls [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
|
|
38
|
+
|
|
39
|
+
Estimate Fee for executing an INVOKE transaction on starknet.
|
|
40
|
+
|
|
41
|
+
The _calls_ object structure:
|
|
42
|
+
|
|
43
|
+
- calls.**contractAddress** - Address of the contract
|
|
44
|
+
- calls.**entrypoint** - Entrypoint of the call (method name)
|
|
45
|
+
- calls.**calldata** - Payload for the invoking method
|
|
46
|
+
|
|
47
|
+
The _estimateFeeDetails_ object may include any of:
|
|
48
|
+
|
|
49
|
+
- estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
|
|
50
|
+
- estimateFeeDetails.**nonce** - Nonce for the transaction
|
|
51
|
+
|
|
52
|
+
###### _EstimateFeeResponse_
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
{
|
|
56
|
+
overall_fee: BN;
|
|
57
|
+
gas_consumed?: BN;
|
|
58
|
+
gas_price?: BN;
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
<hr />
|
|
63
|
+
|
|
64
|
+
account.**estimateDeclareFee**(contractPayload [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
|
|
65
|
+
|
|
66
|
+
Estimate Fee for executing a DECLARE transaction on starknet.
|
|
67
|
+
|
|
68
|
+
The _contractPayload_ object structure:
|
|
69
|
+
|
|
70
|
+
- contractPayload.**contract** - The compiled contract
|
|
71
|
+
- contractPayload.**classHash** - This can be obtained by using starknet-cli. Once the classHash is included in CompiledContract, this can be removed
|
|
72
|
+
|
|
73
|
+
The _estimateFeeDetails_ object may include any of:
|
|
74
|
+
|
|
75
|
+
- estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
|
|
76
|
+
- estimateFeeDetails.**nonce** - Nonce for the transaction
|
|
77
|
+
|
|
78
|
+
###### _EstimateFeeResponse_
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
{
|
|
82
|
+
overall_fee: BN;
|
|
83
|
+
gas_consumed?: BN;
|
|
84
|
+
gas_price?: BN;
|
|
85
|
+
}
|
|
86
|
+
```
|
|
30
87
|
|
|
31
88
|
<hr />
|
|
32
89
|
|
|
33
|
-
account.**
|
|
90
|
+
account.**estimateAccountDeployFee**(contractPayload [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
|
|
91
|
+
|
|
92
|
+
Estimate Fee for executing a DEPLOY_ACCOUNT transaction on starknet
|
|
34
93
|
|
|
35
|
-
|
|
94
|
+
The _contractPayload_ object structure:
|
|
36
95
|
|
|
37
|
-
The
|
|
96
|
+
- contractPayload.**contract** - The compiled contract to be declared
|
|
97
|
+
- contractPayload.**classHash** - This can be obtained by using starknet-cli. Once the classHash is included in CompiledContract, this can be removed
|
|
38
98
|
|
|
39
|
-
|
|
40
|
-
|
|
99
|
+
The _estimateFeeDetails_ object may include any of:
|
|
100
|
+
|
|
101
|
+
- estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
|
|
102
|
+
- estimateFeeDetails.**nonce** - Nonce for the transaction
|
|
41
103
|
|
|
42
104
|
###### _EstimateFeeResponse_
|
|
43
105
|
|
|
@@ -51,17 +113,26 @@ The _options_ object may include any of:
|
|
|
51
113
|
|
|
52
114
|
<hr />
|
|
53
115
|
|
|
54
|
-
account.**execute**(
|
|
116
|
+
account.**execute**(transactions [ , abi , transactionsDetail ]) => _Promise < InvokeFunctionResponse >_
|
|
55
117
|
|
|
56
118
|
Executes one or multiple calls using the account contract.
|
|
57
119
|
|
|
120
|
+
The _transactions_ object structure:
|
|
121
|
+
|
|
122
|
+
- contractPayload.**contractAddress** - the address of the contract
|
|
123
|
+
- contractPayload.**entrypoint** - the entrypoint of the contract
|
|
124
|
+
- contractPayload.**calldata** - (defaults to []) the calldata
|
|
125
|
+
- contractPayload.**signature** - (defaults to []) the signature
|
|
126
|
+
|
|
127
|
+
_abi_ - (optional) the abi of the contract for better displaying
|
|
128
|
+
|
|
58
129
|
The _transactionsDetail_ object may include any of:
|
|
59
130
|
|
|
60
131
|
- transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
|
|
61
132
|
- transactionsDetail.**nonce** - Nonce for the transaction
|
|
62
133
|
- transactionsDetail.**version** - Version for the transaction (default is 1)
|
|
63
134
|
|
|
64
|
-
######
|
|
135
|
+
###### _InvokeFunctionResponse_
|
|
65
136
|
|
|
66
137
|
```typescript
|
|
67
138
|
{
|
|
@@ -71,9 +142,79 @@ The _transactionsDetail_ object may include any of:
|
|
|
71
142
|
|
|
72
143
|
<hr />
|
|
73
144
|
|
|
145
|
+
account.**declare**(contractPayload [ , transactionsDetail ]) => _Promise < DeclareContractResponse >_
|
|
146
|
+
|
|
147
|
+
Declares a given compiled contract (json) to starknet.
|
|
148
|
+
|
|
149
|
+
The _contractPayload_ object consists of:
|
|
150
|
+
|
|
151
|
+
- contractPayload.**contract** - The compiled contract
|
|
152
|
+
- contractPayload.**classHash** - Hash of the compiled contract
|
|
153
|
+
|
|
154
|
+
The _transactionsDetail_ object may include any of:
|
|
155
|
+
|
|
156
|
+
- transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
|
|
157
|
+
- transactionsDetail.**nonce** - Nonce for the transaction
|
|
158
|
+
- transactionsDetail.**version** - Version for the transaction (default is 1)
|
|
159
|
+
|
|
160
|
+
> _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
|
|
161
|
+
|
|
162
|
+
Example:
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
const declareTx = await account.declare({
|
|
166
|
+
contract: compiledErc20,
|
|
167
|
+
// classHash is pre-computed from starknet-cli
|
|
168
|
+
classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
###### _DeclareContractResponse_
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
{
|
|
176
|
+
transaction_hash: string;
|
|
177
|
+
class_hash: string;
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
<hr />
|
|
182
|
+
|
|
183
|
+
account.**deployAccount**(contractPayload [ , transactionsDetail ]) => _Promise < DeployContractResponse >_
|
|
184
|
+
|
|
185
|
+
Declares a given compiled contract (json) to starknet.
|
|
186
|
+
|
|
187
|
+
The _contractPayload_ object consists of:
|
|
188
|
+
|
|
189
|
+
- contractPayload.**classHash** - Hash of the compiled contract
|
|
190
|
+
- contractPayload.**constructorCalldata** - optional
|
|
191
|
+
- contractPayload.**addressSalt** - optional
|
|
192
|
+
- contractPayload.**contractAddress** - optional
|
|
193
|
+
|
|
194
|
+
The _transactionsDetail_ object may include any of:
|
|
195
|
+
|
|
196
|
+
- transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
|
|
197
|
+
- transactionsDetail.**nonce** - Nonce for the transaction
|
|
198
|
+
- transactionsDetail.**version** - Version for the transaction (default is 1)
|
|
199
|
+
|
|
200
|
+
> _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
|
|
201
|
+
|
|
202
|
+
###### _DeployContractResponse_
|
|
203
|
+
|
|
204
|
+
```typescript
|
|
205
|
+
{
|
|
206
|
+
contract_address: string;
|
|
207
|
+
transaction_hash: string;
|
|
208
|
+
};
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
<hr/>
|
|
212
|
+
|
|
74
213
|
account.**signMessage**(typedData) => _Promise < Signature >_
|
|
75
214
|
|
|
76
|
-
|
|
215
|
+
Sign an JSON object for off-chain usage with the starknet private key and return the signature. This adds a message prefix so it cant be interchanged with transactions.
|
|
216
|
+
|
|
217
|
+
_typedData_ - JSON object to be signed
|
|
77
218
|
|
|
78
219
|
###### _Signature_
|
|
79
220
|
|
|
@@ -85,7 +226,11 @@ string[];
|
|
|
85
226
|
|
|
86
227
|
account.**hashMessage**(typedData) => _Promise < string >_
|
|
87
228
|
|
|
88
|
-
|
|
229
|
+
Hash a JSON object with pederson hash and return the hash. This adds a message prefix so it cant be interchanged with transactions.
|
|
230
|
+
|
|
231
|
+
_typedData_ - JSON object to be signed
|
|
232
|
+
|
|
233
|
+
Returns the hash of the JSON object.
|
|
89
234
|
|
|
90
235
|
<hr />
|
|
91
236
|
|
|
@@ -103,4 +248,18 @@ account.**verifyMessage**(typedData, signature) => _Promise < boolean >_
|
|
|
103
248
|
|
|
104
249
|
Verify a signature of a JSON object.
|
|
105
250
|
|
|
251
|
+
_typedData_ - JSON object to be verified
|
|
252
|
+
_signature_ - signature of the JSON object
|
|
253
|
+
|
|
254
|
+
Returns true if the signature is valid, false otherwise
|
|
255
|
+
|
|
106
256
|
<hr />
|
|
257
|
+
|
|
258
|
+
account.**getSuggestedMaxFee**(estimateFeeAction, details) => _Promise < BigNumberish >_
|
|
259
|
+
|
|
260
|
+
Gets Suggested Max Fee based on the transaction type.
|
|
261
|
+
|
|
262
|
+
The _details_ object may include any of:
|
|
263
|
+
|
|
264
|
+
- details.**blockIdentifier**
|
|
265
|
+
- details.**nonce**
|
package/www/docs/API/contract.md
CHANGED
|
@@ -18,6 +18,10 @@ Contracts allow you to transform Cairo values, like `Uint256` to `BigNumber`. It
|
|
|
18
18
|
|
|
19
19
|
## Properties
|
|
20
20
|
|
|
21
|
+
contract.**abi** => _Abi_
|
|
22
|
+
|
|
23
|
+
The ABI the contract was constructed with.
|
|
24
|
+
|
|
21
25
|
contract.**address** => _string_
|
|
22
26
|
|
|
23
27
|
The address the contract was constructed/connected with.
|
|
@@ -30,16 +34,48 @@ contract.**deployTransactionHash** => _string | null_
|
|
|
30
34
|
|
|
31
35
|
If the Contract object is the result of a ContractFactory deployment, this is the transaction which was used to deploy the contract.
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
## Methods
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
contract.**attach**(address) => void
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
Saves the address of the contract deployed on network that will be used for interaction.
|
|
42
|
+
|
|
43
|
+
_address_ - address of the contract.
|
|
44
|
+
|
|
45
|
+
<br></br>
|
|
46
|
+
|
|
47
|
+
contract.**connect**(providerOrAccount) => void
|
|
48
|
+
|
|
49
|
+
Attaches to new Provider or Account
|
|
50
|
+
|
|
51
|
+
<br></br>
|
|
38
52
|
|
|
39
53
|
contract.**deployed**() => _Promise < Contract >_
|
|
40
54
|
|
|
41
55
|
If the Contract object is the result of a ContractFactory deployment, this method will wait for the transaction to be resolved.
|
|
42
56
|
|
|
57
|
+
<br></br>
|
|
58
|
+
|
|
59
|
+
contract.**call**(method, args, options) => _Promise < Result >_
|
|
60
|
+
|
|
61
|
+
Calls a method on a contract.
|
|
62
|
+
|
|
63
|
+
<br></br>
|
|
64
|
+
|
|
65
|
+
contract.**invoke**(method, args, options) => _Promise < InvokeFunctionResponse >_
|
|
66
|
+
|
|
67
|
+
Invokes a method on a contract.
|
|
68
|
+
|
|
69
|
+
<br></br>
|
|
70
|
+
|
|
71
|
+
contract.**estimate**(method, args, options) => _Promise < any >_
|
|
72
|
+
|
|
73
|
+
Estimates a method on a contract.
|
|
74
|
+
|
|
75
|
+
<br></br>
|
|
76
|
+
|
|
77
|
+
contract.**populate**(method, args, options) => _Invocation_
|
|
78
|
+
|
|
43
79
|
## Meta-Class
|
|
44
80
|
|
|
45
81
|
A Meta-Class is a Class which has any of its properties determined at run-time. The Contract object uses a Contract's ABI to determine what methods are available, so the following sections describe the generic ways to interact with the properties added at run-time during the Contract constructor.
|