starknet 2.9.0 → 3.0.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 +3 -1
- package/CHANGELOG.md +24 -0
- package/README.md +16 -14
- package/__tests__/account.test.ts +52 -87
- package/__tests__/accountContract.test.ts +160 -0
- package/__tests__/contract.test.ts +3 -1
- package/__tests__/jest.setup.ts +9 -0
- package/__tests__/provider.test.ts +15 -30
- package/account/default.d.ts +66 -0
- package/account/default.js +440 -0
- package/account/index.d.ts +2 -0
- package/account/index.js +27 -0
- package/account/interface.d.ts +83 -0
- package/account/interface.js +37 -0
- package/contract.d.ts +6 -6
- package/contract.js +16 -14
- package/dist/account/default.d.ts +55 -0
- package/dist/account/default.js +272 -0
- package/dist/account/index.d.ts +2 -0
- package/dist/account/index.js +14 -0
- package/dist/account/interface.d.ts +69 -0
- package/dist/account/interface.js +27 -0
- package/dist/contract.d.ts +6 -6
- package/dist/contract.js +9 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/provider/default.d.ts +23 -13
- package/dist/provider/default.js +150 -93
- package/dist/provider/interface.d.ts +22 -22
- package/dist/provider/utils.d.ts +4 -4
- package/dist/provider/utils.js +16 -6
- package/dist/signer/default.d.ts +7 -51
- package/dist/signer/default.js +24 -177
- package/dist/signer/index.d.ts +1 -1
- package/dist/signer/index.js +1 -1
- package/dist/signer/interface.d.ts +16 -37
- package/dist/signer/interface.js +2 -20
- package/dist/{types.d.ts → types/api.d.ts} +72 -41
- package/dist/{types.js → types/api.js} +0 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +15 -0
- package/dist/types/lib.d.ts +57 -0
- package/dist/types/lib.js +2 -0
- package/dist/types/signer.d.ts +4 -0
- package/dist/types/signer.js +2 -0
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/number.js +5 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +8 -2
- package/provider/default.d.ts +40 -25
- package/provider/default.js +205 -178
- package/provider/interface.d.ts +28 -34
- package/provider/utils.d.ts +4 -4
- package/provider/utils.js +15 -6
- package/signer/default.d.ts +11 -51
- package/signer/default.js +51 -232
- package/signer/index.d.ts +1 -1
- package/signer/index.js +1 -1
- package/signer/interface.d.ts +20 -37
- package/signer/interface.js +3 -32
- package/src/account/default.ts +152 -0
- package/src/account/index.ts +2 -0
- package/src/account/interface.ts +91 -0
- package/src/contract.ts +17 -18
- package/src/index.ts +1 -1
- package/src/provider/default.ts +137 -99
- package/src/provider/interface.ts +28 -34
- package/src/provider/utils.ts +16 -6
- package/src/signer/default.ts +33 -115
- package/src/signer/index.ts +1 -1
- package/src/signer/interface.ts +20 -41
- package/src/types/api.ts +165 -0
- package/src/types/index.ts +3 -0
- package/src/types/lib.ts +73 -0
- package/src/types/signer.ts +5 -0
- package/src/utils/number.ts +4 -0
- package/types/api.d.ts +152 -0
- package/{types.js → types/api.js} +0 -0
- package/types/index.d.ts +3 -0
- package/types/index.js +28 -0
- package/types/lib.d.ts +64 -0
- package/types/lib.js +2 -0
- package/types/signer.d.ts +4 -0
- package/types/signer.js +2 -0
- package/utils/number.d.ts +3 -0
- package/utils/number.js +8 -1
- package/__tests__/signer.test.ts +0 -125
- package/src/types.ts +0 -131
- package/types.d.ts +0 -116
package/types/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
Object.defineProperty(o, k2, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
: function (o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
});
|
|
18
|
+
var __exportStar =
|
|
19
|
+
(this && this.__exportStar) ||
|
|
20
|
+
function (m, exports) {
|
|
21
|
+
for (var p in m)
|
|
22
|
+
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
|
|
23
|
+
__createBinding(exports, m, p);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
26
|
+
__exportStar(require('./lib'), exports);
|
|
27
|
+
__exportStar(require('./api'), exports);
|
|
28
|
+
__exportStar(require('./signer'), exports);
|
package/types/lib.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ec as EC } from 'elliptic';
|
|
2
|
+
|
|
3
|
+
import type { BigNumberish } from '../utils/number';
|
|
4
|
+
export declare type KeyPair = EC.KeyPair;
|
|
5
|
+
export declare type Signature = BigNumberish[];
|
|
6
|
+
export declare type RawCalldata = BigNumberish[];
|
|
7
|
+
export declare type DeployContractPayload = {
|
|
8
|
+
contract: CompiledContract | string;
|
|
9
|
+
constructorCalldata?: RawCalldata;
|
|
10
|
+
addressSalt?: BigNumberish;
|
|
11
|
+
};
|
|
12
|
+
export declare type Invocation = {
|
|
13
|
+
contractAddress: string;
|
|
14
|
+
entrypoint: string;
|
|
15
|
+
calldata?: RawCalldata;
|
|
16
|
+
signature?: Signature;
|
|
17
|
+
};
|
|
18
|
+
export declare type ExecuteInvocation = Omit<Invocation, 'signature'>;
|
|
19
|
+
export declare type InvocationsDetails = {
|
|
20
|
+
nonce?: BigNumberish;
|
|
21
|
+
};
|
|
22
|
+
export declare type Call = Omit<Invocation, 'signature' | 'nonce'>;
|
|
23
|
+
export declare type Status =
|
|
24
|
+
| 'NOT_RECEIVED'
|
|
25
|
+
| 'RECEIVED'
|
|
26
|
+
| 'PENDING'
|
|
27
|
+
| 'ACCEPTED_ON_L2'
|
|
28
|
+
| 'ACCEPTED_ON_L1'
|
|
29
|
+
| 'REJECTED';
|
|
30
|
+
export declare type TransactionStatus = 'TRANSACTION_RECEIVED';
|
|
31
|
+
export declare type Type = 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
32
|
+
export declare type EntryPointType = 'EXTERNAL';
|
|
33
|
+
export declare type CompressedProgram = string;
|
|
34
|
+
export declare type AbiEntry = {
|
|
35
|
+
name: string;
|
|
36
|
+
type: 'felt' | 'felt*' | string;
|
|
37
|
+
};
|
|
38
|
+
export declare type FunctionAbi = {
|
|
39
|
+
inputs: AbiEntry[];
|
|
40
|
+
name: string;
|
|
41
|
+
outputs: AbiEntry[];
|
|
42
|
+
stateMutability?: 'view';
|
|
43
|
+
type: 'function';
|
|
44
|
+
};
|
|
45
|
+
export declare type StructAbi = {
|
|
46
|
+
members: (AbiEntry & {
|
|
47
|
+
offset: number;
|
|
48
|
+
})[];
|
|
49
|
+
name: string;
|
|
50
|
+
size: number;
|
|
51
|
+
type: 'struct';
|
|
52
|
+
};
|
|
53
|
+
export declare type Abi = Array<FunctionAbi | StructAbi>;
|
|
54
|
+
export declare type EntryPointsByType = object;
|
|
55
|
+
export declare type Program = Record<any, any>;
|
|
56
|
+
export declare type BlockNumber = 'pending' | null | number;
|
|
57
|
+
export declare type CompiledContract = {
|
|
58
|
+
abi: Abi;
|
|
59
|
+
entry_points_by_type: EntryPointsByType;
|
|
60
|
+
program: Program;
|
|
61
|
+
};
|
|
62
|
+
export declare type CompressedCompiledContract = Omit<CompiledContract, 'program'> & {
|
|
63
|
+
program: CompressedProgram;
|
|
64
|
+
};
|
package/types/lib.js
ADDED
package/types/signer.js
ADDED
package/utils/number.d.ts
CHANGED
package/utils/number.js
CHANGED
|
@@ -5,7 +5,8 @@ var __importDefault =
|
|
|
5
5
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
6
|
};
|
|
7
7
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.bigNumberishArrayToDecimalStringArray =
|
|
9
|
+
exports.assertInRange =
|
|
9
10
|
exports.hexToDecimalString =
|
|
10
11
|
exports.toHex =
|
|
11
12
|
exports.toBN =
|
|
@@ -50,3 +51,9 @@ function assertInRange(input, lowerBound, upperBound, inputName) {
|
|
|
50
51
|
);
|
|
51
52
|
}
|
|
52
53
|
exports.assertInRange = assertInRange;
|
|
54
|
+
function bigNumberishArrayToDecimalStringArray(rawCalldata) {
|
|
55
|
+
return rawCalldata.map(function (x) {
|
|
56
|
+
return toBN(x).toString(10);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.bigNumberishArrayToDecimalStringArray = bigNumberishArrayToDecimalStringArray;
|
package/__tests__/signer.test.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
import typedDataExample from '../__mocks__/typedDataExample.json';
|
|
4
|
-
import {
|
|
5
|
-
CompiledContract,
|
|
6
|
-
Contract,
|
|
7
|
-
Signer,
|
|
8
|
-
compileCalldata,
|
|
9
|
-
defaultProvider,
|
|
10
|
-
ec,
|
|
11
|
-
json,
|
|
12
|
-
number,
|
|
13
|
-
stark,
|
|
14
|
-
} from '../src';
|
|
15
|
-
|
|
16
|
-
const compiledArgentAccount: CompiledContract = json.parse(
|
|
17
|
-
fs.readFileSync('./__mocks__/ArgentAccount.json').toString('ascii')
|
|
18
|
-
);
|
|
19
|
-
const compiledErc20: CompiledContract = json.parse(
|
|
20
|
-
fs.readFileSync('./__mocks__/ERC20.json').toString('ascii')
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
describe('deploy and test Wallet', () => {
|
|
24
|
-
const privateKey = stark.randomAddress();
|
|
25
|
-
|
|
26
|
-
const starkKeyPair = ec.getKeyPair(privateKey);
|
|
27
|
-
const starkKeyPub = ec.getStarkKey(starkKeyPair);
|
|
28
|
-
let walletAddress: string;
|
|
29
|
-
let erc20: Contract;
|
|
30
|
-
let erc20Address: string;
|
|
31
|
-
let signer: Signer;
|
|
32
|
-
|
|
33
|
-
beforeAll(async () => {
|
|
34
|
-
const { code: codeErc20, address: erc20AddressLocal } = await defaultProvider.deployContract(
|
|
35
|
-
compiledErc20,
|
|
36
|
-
[]
|
|
37
|
-
);
|
|
38
|
-
erc20Address = erc20AddressLocal;
|
|
39
|
-
erc20 = new Contract(compiledErc20.abi, erc20Address);
|
|
40
|
-
|
|
41
|
-
expect(codeErc20).toBe('TRANSACTION_RECEIVED');
|
|
42
|
-
|
|
43
|
-
const { code, address: walletAddressLocal } = await defaultProvider.deployContract(
|
|
44
|
-
compiledArgentAccount,
|
|
45
|
-
compileCalldata({
|
|
46
|
-
signer: starkKeyPub,
|
|
47
|
-
guardian: '0',
|
|
48
|
-
L1_address: '0',
|
|
49
|
-
}),
|
|
50
|
-
starkKeyPub
|
|
51
|
-
);
|
|
52
|
-
walletAddress = walletAddressLocal;
|
|
53
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
54
|
-
|
|
55
|
-
const { code: codeErc20Mint, transaction_hash: txErc20Mint } = await erc20.invoke('mint', {
|
|
56
|
-
recipient: walletAddress,
|
|
57
|
-
amount: '1000',
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
expect(codeErc20Mint).toBe('TRANSACTION_RECEIVED');
|
|
61
|
-
|
|
62
|
-
signer = new Signer(defaultProvider, walletAddressLocal, starkKeyPair);
|
|
63
|
-
|
|
64
|
-
await defaultProvider.waitForTx(txErc20Mint);
|
|
65
|
-
});
|
|
66
|
-
test('same wallet address', () => {
|
|
67
|
-
expect(walletAddress).toBe(signer.address);
|
|
68
|
-
});
|
|
69
|
-
test('read nonce', async () => {
|
|
70
|
-
const { result } = await signer.callContract({
|
|
71
|
-
contract_address: signer.address,
|
|
72
|
-
entry_point_selector: stark.getSelectorFromName('get_nonce'),
|
|
73
|
-
});
|
|
74
|
-
const nonce = result[0];
|
|
75
|
-
|
|
76
|
-
expect(number.toBN(nonce).toString()).toStrictEqual(number.toBN(0).toString());
|
|
77
|
-
});
|
|
78
|
-
test('read balance of wallet', async () => {
|
|
79
|
-
const { res } = await erc20.call('balance_of', {
|
|
80
|
-
user: walletAddress,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
expect(number.toBN(res as string).toString()).toStrictEqual(number.toBN(1000).toString());
|
|
84
|
-
});
|
|
85
|
-
test('execute by wallet owner', async () => {
|
|
86
|
-
const { code, transaction_hash } = await signer.addTransaction({
|
|
87
|
-
type: 'INVOKE_FUNCTION',
|
|
88
|
-
contract_address: erc20Address,
|
|
89
|
-
entry_point_selector: stark.getSelectorFromName('transfer'),
|
|
90
|
-
calldata: [erc20Address, '10'],
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
94
|
-
await defaultProvider.waitForTx(transaction_hash);
|
|
95
|
-
});
|
|
96
|
-
test('read balance of wallet after transfer', async () => {
|
|
97
|
-
const { res } = await erc20.call('balance_of', {
|
|
98
|
-
user: walletAddress,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
expect(number.toBN(res as string).toString()).toStrictEqual(number.toBN(990).toString());
|
|
102
|
-
});
|
|
103
|
-
test('execute with custom nonce', async () => {
|
|
104
|
-
const { result } = await signer.callContract({
|
|
105
|
-
contract_address: signer.address,
|
|
106
|
-
entry_point_selector: stark.getSelectorFromName('get_nonce'),
|
|
107
|
-
});
|
|
108
|
-
const nonce = parseInt(result[0], 10);
|
|
109
|
-
const { code, transaction_hash } = await signer.addTransaction({
|
|
110
|
-
type: 'INVOKE_FUNCTION',
|
|
111
|
-
contract_address: erc20Address,
|
|
112
|
-
entry_point_selector: stark.getSelectorFromName('transfer'),
|
|
113
|
-
calldata: [erc20Address, '10'],
|
|
114
|
-
nonce,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
expect(code).toBe('TRANSACTION_RECEIVED');
|
|
118
|
-
await defaultProvider.waitForTx(transaction_hash);
|
|
119
|
-
});
|
|
120
|
-
test('sign and verify offchain message', async () => {
|
|
121
|
-
const signature = await signer.signMessage(typedDataExample);
|
|
122
|
-
|
|
123
|
-
expect(await signer.verifyMessage(typedDataExample, signature)).toBe(true);
|
|
124
|
-
});
|
|
125
|
-
});
|
package/src/types.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import type { ec as EC } from 'elliptic';
|
|
2
|
-
|
|
3
|
-
import type { BigNumberish } from './utils/number';
|
|
4
|
-
|
|
5
|
-
export type KeyPair = EC.KeyPair;
|
|
6
|
-
export type Signature = BigNumberish[];
|
|
7
|
-
|
|
8
|
-
export type GetContractAddressesResponse = {
|
|
9
|
-
Starknet: string;
|
|
10
|
-
GpsStatementVerifier: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type Status =
|
|
14
|
-
| 'NOT_RECEIVED'
|
|
15
|
-
| 'RECEIVED'
|
|
16
|
-
| 'PENDING'
|
|
17
|
-
| 'ACCEPTED_ON_L2'
|
|
18
|
-
| 'ACCEPTED_ON_L1'
|
|
19
|
-
| 'REJECTED';
|
|
20
|
-
export type TransactionStatus = 'TRANSACTION_RECEIVED';
|
|
21
|
-
export type Type = 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
22
|
-
export type EntryPointType = 'EXTERNAL';
|
|
23
|
-
export type CompressedProgram = string;
|
|
24
|
-
|
|
25
|
-
export type AbiEntry = { name: string; type: 'felt' | 'felt*' | string };
|
|
26
|
-
|
|
27
|
-
export type FunctionAbi = {
|
|
28
|
-
inputs: AbiEntry[];
|
|
29
|
-
name: string;
|
|
30
|
-
outputs: AbiEntry[];
|
|
31
|
-
stateMutability?: 'view';
|
|
32
|
-
type: 'function';
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type StructAbi = {
|
|
36
|
-
members: (AbiEntry & { offset: number })[];
|
|
37
|
-
name: string;
|
|
38
|
-
size: number;
|
|
39
|
-
type: 'struct';
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type Abi = FunctionAbi | StructAbi;
|
|
43
|
-
|
|
44
|
-
export type EntryPointsByType = object;
|
|
45
|
-
export type Program = object;
|
|
46
|
-
export type BlockNumber = 'pending' | null | number;
|
|
47
|
-
|
|
48
|
-
export type CompiledContract = {
|
|
49
|
-
abi: Abi[];
|
|
50
|
-
entry_points_by_type: EntryPointsByType;
|
|
51
|
-
program: Program;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export type CompressedCompiledContract = Omit<CompiledContract, 'program'>;
|
|
55
|
-
|
|
56
|
-
export type DeployTransaction = {
|
|
57
|
-
type: 'DEPLOY';
|
|
58
|
-
contract_definition: CompressedCompiledContract;
|
|
59
|
-
contract_address_salt: BigNumberish;
|
|
60
|
-
constructor_calldata: string[];
|
|
61
|
-
nonce?: BigNumberish;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export type InvokeFunctionTransaction = {
|
|
65
|
-
type: 'INVOKE_FUNCTION';
|
|
66
|
-
contract_address: string;
|
|
67
|
-
signature?: Signature;
|
|
68
|
-
entry_point_type?: EntryPointType;
|
|
69
|
-
entry_point_selector: string;
|
|
70
|
-
calldata?: string[];
|
|
71
|
-
nonce?: BigNumberish;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type'>;
|
|
75
|
-
|
|
76
|
-
export type Transaction = DeployTransaction | InvokeFunctionTransaction;
|
|
77
|
-
|
|
78
|
-
export type CallContractResponse = {
|
|
79
|
-
result: string[];
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export type GetBlockResponse = {
|
|
83
|
-
block_number: number;
|
|
84
|
-
state_root: string;
|
|
85
|
-
block_hash: string;
|
|
86
|
-
transactions: {
|
|
87
|
-
[txHash: string]: Transaction;
|
|
88
|
-
};
|
|
89
|
-
timestamp: number;
|
|
90
|
-
transaction_receipts: {
|
|
91
|
-
[txHash: string]: {
|
|
92
|
-
block_hash: string;
|
|
93
|
-
transaction_hash: string;
|
|
94
|
-
l2_to_l1_messages: {
|
|
95
|
-
to_address: string;
|
|
96
|
-
payload: string[];
|
|
97
|
-
from_address: string;
|
|
98
|
-
}[];
|
|
99
|
-
block_number: BlockNumber;
|
|
100
|
-
status: Status;
|
|
101
|
-
transaction_index: number;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
previous_block_hash: string;
|
|
105
|
-
status: Status;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export type GetCodeResponse = {
|
|
109
|
-
bytecode: string[];
|
|
110
|
-
abi: Abi[];
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export type GetTransactionStatusResponse = {
|
|
114
|
-
tx_status: Status;
|
|
115
|
-
block_hash: string;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export type GetTransactionResponse = {
|
|
119
|
-
status: Status;
|
|
120
|
-
transaction: Transaction;
|
|
121
|
-
block_hash: string;
|
|
122
|
-
block_number: BlockNumber;
|
|
123
|
-
transaction_index: number;
|
|
124
|
-
transaction_hash: string;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export type AddTransactionResponse = {
|
|
128
|
-
code: TransactionStatus;
|
|
129
|
-
transaction_hash: string;
|
|
130
|
-
address?: string;
|
|
131
|
-
};
|
package/types.d.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { ec as EC } from 'elliptic';
|
|
2
|
-
|
|
3
|
-
import type { BigNumberish } from './utils/number';
|
|
4
|
-
export declare type KeyPair = EC.KeyPair;
|
|
5
|
-
export declare type Signature = BigNumberish[];
|
|
6
|
-
export declare type GetContractAddressesResponse = {
|
|
7
|
-
Starknet: string;
|
|
8
|
-
GpsStatementVerifier: string;
|
|
9
|
-
};
|
|
10
|
-
export declare type Status =
|
|
11
|
-
| 'NOT_RECEIVED'
|
|
12
|
-
| 'RECEIVED'
|
|
13
|
-
| 'PENDING'
|
|
14
|
-
| 'ACCEPTED_ON_L2'
|
|
15
|
-
| 'ACCEPTED_ON_L1'
|
|
16
|
-
| 'REJECTED';
|
|
17
|
-
export declare type TransactionStatus = 'TRANSACTION_RECEIVED';
|
|
18
|
-
export declare type Type = 'DEPLOY' | 'INVOKE_FUNCTION';
|
|
19
|
-
export declare type EntryPointType = 'EXTERNAL';
|
|
20
|
-
export declare type CompressedProgram = string;
|
|
21
|
-
export declare type AbiEntry = {
|
|
22
|
-
name: string;
|
|
23
|
-
type: 'felt' | 'felt*' | string;
|
|
24
|
-
};
|
|
25
|
-
export declare type FunctionAbi = {
|
|
26
|
-
inputs: AbiEntry[];
|
|
27
|
-
name: string;
|
|
28
|
-
outputs: AbiEntry[];
|
|
29
|
-
stateMutability?: 'view';
|
|
30
|
-
type: 'function';
|
|
31
|
-
};
|
|
32
|
-
export declare type StructAbi = {
|
|
33
|
-
members: (AbiEntry & {
|
|
34
|
-
offset: number;
|
|
35
|
-
})[];
|
|
36
|
-
name: string;
|
|
37
|
-
size: number;
|
|
38
|
-
type: 'struct';
|
|
39
|
-
};
|
|
40
|
-
export declare type Abi = FunctionAbi | StructAbi;
|
|
41
|
-
export declare type EntryPointsByType = object;
|
|
42
|
-
export declare type Program = object;
|
|
43
|
-
export declare type BlockNumber = 'pending' | null | number;
|
|
44
|
-
export declare type CompiledContract = {
|
|
45
|
-
abi: Abi[];
|
|
46
|
-
entry_points_by_type: EntryPointsByType;
|
|
47
|
-
program: Program;
|
|
48
|
-
};
|
|
49
|
-
export declare type CompressedCompiledContract = Omit<CompiledContract, 'program'>;
|
|
50
|
-
export declare type DeployTransaction = {
|
|
51
|
-
type: 'DEPLOY';
|
|
52
|
-
contract_definition: CompressedCompiledContract;
|
|
53
|
-
contract_address_salt: BigNumberish;
|
|
54
|
-
constructor_calldata: string[];
|
|
55
|
-
nonce?: BigNumberish;
|
|
56
|
-
};
|
|
57
|
-
export declare type InvokeFunctionTransaction = {
|
|
58
|
-
type: 'INVOKE_FUNCTION';
|
|
59
|
-
contract_address: string;
|
|
60
|
-
signature?: Signature;
|
|
61
|
-
entry_point_type?: EntryPointType;
|
|
62
|
-
entry_point_selector: string;
|
|
63
|
-
calldata?: string[];
|
|
64
|
-
nonce?: BigNumberish;
|
|
65
|
-
};
|
|
66
|
-
export declare type CallContractTransaction = Omit<InvokeFunctionTransaction, 'type'>;
|
|
67
|
-
export declare type Transaction = DeployTransaction | InvokeFunctionTransaction;
|
|
68
|
-
export declare type CallContractResponse = {
|
|
69
|
-
result: string[];
|
|
70
|
-
};
|
|
71
|
-
export declare type GetBlockResponse = {
|
|
72
|
-
block_number: number;
|
|
73
|
-
state_root: string;
|
|
74
|
-
block_hash: string;
|
|
75
|
-
transactions: {
|
|
76
|
-
[txHash: string]: Transaction;
|
|
77
|
-
};
|
|
78
|
-
timestamp: number;
|
|
79
|
-
transaction_receipts: {
|
|
80
|
-
[txHash: string]: {
|
|
81
|
-
block_hash: string;
|
|
82
|
-
transaction_hash: string;
|
|
83
|
-
l2_to_l1_messages: {
|
|
84
|
-
to_address: string;
|
|
85
|
-
payload: string[];
|
|
86
|
-
from_address: string;
|
|
87
|
-
}[];
|
|
88
|
-
block_number: BlockNumber;
|
|
89
|
-
status: Status;
|
|
90
|
-
transaction_index: number;
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
previous_block_hash: string;
|
|
94
|
-
status: Status;
|
|
95
|
-
};
|
|
96
|
-
export declare type GetCodeResponse = {
|
|
97
|
-
bytecode: string[];
|
|
98
|
-
abi: Abi[];
|
|
99
|
-
};
|
|
100
|
-
export declare type GetTransactionStatusResponse = {
|
|
101
|
-
tx_status: Status;
|
|
102
|
-
block_hash: string;
|
|
103
|
-
};
|
|
104
|
-
export declare type GetTransactionResponse = {
|
|
105
|
-
status: Status;
|
|
106
|
-
transaction: Transaction;
|
|
107
|
-
block_hash: string;
|
|
108
|
-
block_number: BlockNumber;
|
|
109
|
-
transaction_index: number;
|
|
110
|
-
transaction_hash: string;
|
|
111
|
-
};
|
|
112
|
-
export declare type AddTransactionResponse = {
|
|
113
|
-
code: TransactionStatus;
|
|
114
|
-
transaction_hash: string;
|
|
115
|
-
address?: string;
|
|
116
|
-
};
|