starknet 4.13.2 → 4.14.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/CODE_OF_CONDUCT.md +128 -0
  3. package/README.md +2 -2
  4. package/__tests__/account.test.ts +38 -14
  5. package/__tests__/contract.test.ts +70 -57
  6. package/__tests__/defaultProvider.test.ts +14 -13
  7. package/__tests__/fixtures.ts +26 -27
  8. package/__tests__/rpcProvider.test.ts +19 -16
  9. package/__tests__/sequencerProvider.test.ts +47 -55
  10. package/__tests__/utils/utils.test.ts +10 -0
  11. package/dist/index.d.ts +112 -28
  12. package/dist/index.global.js +511 -453
  13. package/dist/index.global.js.map +1 -1
  14. package/dist/index.js +107 -49
  15. package/dist/index.js.map +1 -1
  16. package/dist/index.mjs +107 -49
  17. package/dist/index.mjs.map +1 -1
  18. package/index.d.ts +112 -28
  19. package/index.global.js +511 -453
  20. package/index.global.js.map +1 -1
  21. package/index.js +107 -49
  22. package/index.js.map +1 -1
  23. package/index.mjs +107 -49
  24. package/index.mjs.map +1 -1
  25. package/package.json +2 -2
  26. package/src/account/default.ts +29 -7
  27. package/src/account/interface.ts +71 -5
  28. package/src/contract/contractFactory.ts +20 -13
  29. package/src/contract/default.ts +10 -1
  30. package/src/provider/default.ts +26 -11
  31. package/src/provider/interface.ts +9 -3
  32. package/src/provider/rpc.ts +15 -11
  33. package/src/provider/sequencer.ts +11 -6
  34. package/src/provider/utils.ts +19 -11
  35. package/src/types/account.ts +21 -1
  36. package/src/types/lib.ts +5 -2
  37. package/src/types/provider.ts +0 -5
  38. package/src/utils/events.ts +32 -0
  39. package/src/utils/number.ts +6 -0
  40. package/www/docs/API/account.md +156 -2
  41. package/www/docs/API/contractFactory.md +7 -11
  42. package/www/docs/API/provider.md +5 -9
  43. package/www/docs/API/utils.md +8 -0
  44. package/www/guides/account.md +89 -38
  45. package/www/guides/erc20.md +115 -59
  46. package/www/guides/intro.md +11 -4
@@ -1,11 +1,13 @@
1
1
  import fs from 'fs';
2
+ import path from 'path';
2
3
 
3
4
  import { Account, ProviderInterface, RpcProvider, SequencerProvider, ec, json } from '../src';
4
- import { CompiledContract, DeployContractPayload } from '../src/types';
5
- import { encodeShortString } from '../src/utils/shortString';
5
+ import { CompiledContract } from '../src/types';
6
6
 
7
7
  const readContract = (name: string): CompiledContract =>
8
- json.parse(fs.readFileSync(`./__mocks__/${name}.json`).toString('ascii'));
8
+ json.parse(
9
+ fs.readFileSync(path.resolve(__dirname, `../__mocks__/${name}.json`)).toString('ascii')
10
+ );
9
11
 
10
12
  export const compiledOpenZeppelinAccount = readContract('Account');
11
13
  export const compiledErc20 = readContract('ERC20');
@@ -14,33 +16,37 @@ export const compiledTypeTransformation = readContract('contract');
14
16
  export const compiledMulticall = readContract('multicall');
15
17
  export const compiledTestDapp = readContract('TestDapp');
16
18
 
17
- const DEFAULT_TEST_PROVIDER_BASE_URL = 'http://127.0.0.1:5050/';
18
- const DEFAULT_TEST_ACCOUNT_ADDRESS = // run `starknet-devnet --seed 0` and this will be the first account
19
+ /* Default test config based on run `starknet-devnet --seed 0` */
20
+ const DEFAULT_TEST_PROVIDER_SEQUENCER_URL = 'http://127.0.0.1:5050/';
21
+ const DEFAULT_TEST_ACCOUNT_ADDRESS =
19
22
  '0x7e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a';
20
23
  const DEFAULT_TEST_ACCOUNT_PRIVATE_KEY = '0xe3e70682c2094cac629f6fbed82c07cd';
21
24
 
22
- const BASE_URL = process.env.TEST_PROVIDER_BASE_URL || DEFAULT_TEST_PROVIDER_BASE_URL;
25
+ /* User defined config or default one */
26
+ const BASE_URL = process.env.TEST_PROVIDER_BASE_URL || DEFAULT_TEST_PROVIDER_SEQUENCER_URL;
23
27
  const RPC_URL = process.env.TEST_RPC_URL;
24
28
 
25
- const IS_RPC = !!RPC_URL;
26
- const IS_RPC_DEVNET = Boolean(
27
- RPC_URL && (RPC_URL.includes('localhost') || RPC_URL.includes('127.0.0.1'))
28
- );
29
- const IS_SEQUENCER = !IS_RPC;
30
- const IS_SEQUENCER_DEVNET = !BASE_URL.includes('starknet.io');
31
- export const IS_SEQUENCER_GOERLI = BASE_URL === 'https://alpha4-2.starknet.io';
32
- export const IS_DEVNET = IS_SEQUENCER ? IS_SEQUENCER_DEVNET : IS_RPC_DEVNET;
29
+ /* Detect user defined node or sequencer, if none default to sequencer if both default to node */
30
+ const PROVIDER_URL = RPC_URL || BASE_URL;
31
+
32
+ /* Detect is localhost devnet */
33
+ export const IS_LOCALHOST_DEVNET =
34
+ PROVIDER_URL.includes('localhost') || PROVIDER_URL.includes('127.0.0.1');
35
+
36
+ /* Definitions */
37
+ export const IS_RPC = !!RPC_URL;
38
+ export const IS_SEQUENCER = !RPC_URL;
33
39
 
34
40
  export const getTestProvider = (): ProviderInterface => {
35
41
  const provider = RPC_URL
36
42
  ? new RpcProvider({ nodeUrl: RPC_URL })
37
43
  : new SequencerProvider({ baseUrl: BASE_URL });
38
44
 
39
- if (IS_DEVNET) {
45
+ if (IS_LOCALHOST_DEVNET) {
40
46
  // accelerate the tests when running locally
41
47
  const originalWaitForTransaction = provider.waitForTransaction.bind(provider);
42
48
  provider.waitForTransaction = (txHash, retryInterval) => {
43
- return originalWaitForTransaction(txHash, retryInterval || 1000);
49
+ return originalWaitForTransaction(txHash, undefined, retryInterval || 1000);
44
50
  };
45
51
  }
46
52
 
@@ -52,11 +58,10 @@ export const getTestAccount = (provider: ProviderInterface) => {
52
58
  let testAccountAddress = process.env.TEST_ACCOUNT_ADDRESS;
53
59
  let testAccountPrivateKey = process.env.TEST_ACCOUNT_PRIVATE_KEY;
54
60
 
55
- if (!IS_DEVNET) {
61
+ if (!IS_LOCALHOST_DEVNET) {
56
62
  if (!testAccountPrivateKey) {
57
63
  throw new Error('TEST_ACCOUNT_PRIVATE_KEY is not set');
58
64
  }
59
-
60
65
  if (!testAccountAddress) {
61
66
  throw new Error('TEST_ACCOUNT_ADDRESS is not set');
62
67
  }
@@ -69,15 +74,9 @@ export const getTestAccount = (provider: ProviderInterface) => {
69
74
  };
70
75
 
71
76
  const describeIf = (condition: boolean) => (condition ? describe : describe.skip);
72
- export const describeIfSequencer = describeIf(IS_DEVNET);
77
+ export const describeIfSequencer = describeIf(IS_SEQUENCER);
73
78
  export const describeIfRpc = describeIf(IS_RPC);
74
- export const describeIfNotDevnet = describeIf(!IS_DEVNET);
79
+ export const describeIfNotDevnet = describeIf(!IS_LOCALHOST_DEVNET);
80
+ export const describeIfDevnet = describeIf(IS_LOCALHOST_DEVNET);
75
81
 
76
82
  export const erc20ClassHash = '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a';
77
-
78
- export const getERC20DeployPayload = (recipient: string): DeployContractPayload => {
79
- return {
80
- contract: compiledErc20,
81
- constructorCalldata: [encodeShortString('Token'), encodeShortString('ERC20'), recipient],
82
- };
83
- };
@@ -2,21 +2,19 @@ import { Account, GetBlockResponse, RpcProvider, ec } from '../src';
2
2
  import { StarknetChainId } from '../src/constants';
3
3
  import {
4
4
  compiledOpenZeppelinAccount,
5
+ describeIfNotDevnet,
5
6
  describeIfRpc,
6
7
  getTestAccount,
7
8
  getTestProvider,
8
9
  } from './fixtures';
9
10
 
10
11
  describeIfRpc('RPCProvider', () => {
11
- let rpcProvider: RpcProvider;
12
+ const rpcProvider = getTestProvider() as RpcProvider;
13
+ const account = getTestAccount(rpcProvider);
12
14
  let accountPublicKey: string;
13
15
 
14
16
  beforeAll(async () => {
15
- rpcProvider = getTestProvider() as RpcProvider;
16
- const account = getTestAccount(rpcProvider);
17
-
18
17
  expect(account).toBeInstanceOf(Account);
19
-
20
18
  const accountKeyPair = ec.genKeyPair();
21
19
  accountPublicKey = ec.getStarkKey(accountKeyPair);
22
20
  });
@@ -28,11 +26,6 @@ describeIfRpc('RPCProvider', () => {
28
26
  );
29
27
  });
30
28
 
31
- test('getPendingTransactions', async () => {
32
- const transactions = await rpcProvider.getPendingTransactions();
33
- expect(Array.isArray(transactions)).toBe(true);
34
- });
35
-
36
29
  test('getTransactionCount', async () => {
37
30
  const count = await rpcProvider.getTransactionCount('latest');
38
31
  expect(typeof count).toBe('number');
@@ -52,10 +45,17 @@ describeIfRpc('RPCProvider', () => {
52
45
  expect(stateUpdate).toHaveProperty('state_diff');
53
46
  });
54
47
 
55
- xtest('getProtocolVersion', async () => {
48
+ xtest('getProtocolVersion - pathfinder not implement', async () => {
56
49
  await rpcProvider.getProtocolVersion();
57
50
  });
58
51
 
52
+ describeIfNotDevnet('devnet not implement', () => {
53
+ test('getPendingTransactions', async () => {
54
+ const transactions = await rpcProvider.getPendingTransactions();
55
+ expect(Array.isArray(transactions)).toBe(true);
56
+ });
57
+ });
58
+
59
59
  describe('RPC methods', () => {
60
60
  let latestBlock: GetBlockResponse;
61
61
 
@@ -90,15 +90,18 @@ describeIfRpc('RPCProvider', () => {
90
90
  let transaction_hash;
91
91
 
92
92
  beforeAll(async () => {
93
- ({ contract_address, transaction_hash } = await rpcProvider.deployContract({
93
+ const { deploy } = await account.declareDeploy({
94
94
  contract: compiledOpenZeppelinAccount,
95
+ classHash: '0x03fcbf77b28c96f4f2fb5bd2d176ab083a12a5e123adeb0de955d7ee228c9854',
95
96
  constructorCalldata: [accountPublicKey],
96
- addressSalt: accountPublicKey,
97
- }));
98
- await rpcProvider.waitForTransaction(transaction_hash);
97
+ salt: accountPublicKey,
98
+ });
99
+
100
+ contract_address = deploy.contract_address;
101
+ transaction_hash = deploy.transaction_hash;
99
102
  });
100
103
 
101
- test('deployContract result', () => {
104
+ test('declareDeploy()', () => {
102
105
  expect(contract_address).toBeTruthy();
103
106
  expect(transaction_hash).toBeTruthy();
104
107
  });
@@ -1,46 +1,35 @@
1
1
  import { Contract, Provider, SequencerProvider, stark } from '../src';
2
2
  import { toBN } from '../src/utils/number';
3
+ import { encodeShortString } from '../src/utils/shortString';
3
4
  import {
4
- IS_SEQUENCER_GOERLI,
5
5
  compiledErc20,
6
6
  compiledL1L2,
7
+ describeIfDevnet,
7
8
  describeIfNotDevnet,
8
9
  describeIfSequencer,
9
- getERC20DeployPayload,
10
+ getTestAccount,
10
11
  getTestProvider,
11
12
  } from './fixtures';
12
13
 
13
- // Run only if Devnet Sequencer
14
14
  describeIfSequencer('SequencerProvider', () => {
15
- let sequencerProvider: SequencerProvider;
15
+ const sequencerProvider = getTestProvider() as SequencerProvider;
16
+ const account = getTestAccount(sequencerProvider);
16
17
  let customSequencerProvider: Provider;
17
18
  let exampleContractAddress: string;
18
19
 
19
- beforeAll(async () => {
20
- sequencerProvider = getTestProvider() as SequencerProvider;
21
- customSequencerProvider = new Provider({
22
- sequencer: {
23
- baseUrl: 'http://127.0.0.1:5050/',
24
- feederGatewayUrl: 'feeder_gateway',
25
- gatewayUrl: 'gateway',
26
- }, // Similar to arguements used in docs
27
- });
28
- });
29
-
30
20
  describe('Gateway specific methods', () => {
31
21
  let exampleTransactionHash: string;
32
22
  const wallet = stark.randomAddress();
33
23
 
34
24
  beforeAll(async () => {
35
- const erc20DeployPayload = getERC20DeployPayload(wallet);
36
-
37
- const { contract_address, transaction_hash } = await sequencerProvider.deployContract(
38
- erc20DeployPayload
39
- );
25
+ const { deploy } = await account.declareDeploy({
26
+ contract: compiledErc20,
27
+ classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
28
+ constructorCalldata: [encodeShortString('Token'), encodeShortString('ERC20'), wallet],
29
+ });
40
30
 
41
- await sequencerProvider.waitForTransaction(transaction_hash);
42
- exampleTransactionHash = transaction_hash;
43
- exampleContractAddress = contract_address;
31
+ exampleTransactionHash = deploy.transaction_hash;
32
+ exampleContractAddress = deploy.contract_address;
44
33
  });
45
34
 
46
35
  test('getTransactionStatus()', async () => {
@@ -69,43 +58,16 @@ describeIfSequencer('SequencerProvider', () => {
69
58
  });
70
59
  });
71
60
 
72
- describe('Test calls with Custom Sequencer Provider', () => {
73
- let erc20: Contract;
74
- const wallet = stark.randomAddress();
75
-
76
- beforeAll(async () => {
77
- const erc20DeployPayload = getERC20DeployPayload(wallet);
78
-
79
- const { contract_address, transaction_hash } = await customSequencerProvider.deployContract(
80
- erc20DeployPayload
81
- );
82
-
83
- await customSequencerProvider.waitForTransaction(transaction_hash);
84
- erc20 = new Contract(compiledErc20.abi, contract_address, customSequencerProvider);
85
- });
86
-
87
- test('Check ERC20 balance using Custom Sequencer Provider', async () => {
88
- const result = await erc20.balanceOf(wallet);
89
- const [res] = result;
90
- expect(res.low).toStrictEqual(toBN(1000));
91
- expect(res).toStrictEqual(result.balance);
92
- });
93
- });
94
-
95
61
  describe('Test Estimate message fee', () => {
96
62
  const L1_ADDRESS = '0x8359E4B0152ed5A731162D3c7B0D8D56edB165A0';
97
63
  let l1l2ContractAddress: string;
98
64
 
99
65
  beforeAll(async () => {
100
- if (IS_SEQUENCER_GOERLI) {
101
- l1l2ContractAddress = '0x2863141e0d9a74e9b484c1f5b1e3a2f6cbb6b84df8233c7c1cbe31334d9aed8';
102
- } else {
103
- const { transaction_hash, contract_address } = await sequencerProvider.deployContract({
104
- contract: compiledL1L2,
105
- });
106
- await sequencerProvider.waitForTransaction(transaction_hash);
107
- l1l2ContractAddress = contract_address;
108
- }
66
+ const { deploy } = await account.declareDeploy({
67
+ contract: compiledL1L2,
68
+ classHash: '0x028d1671fb74ecb54d848d463cefccffaef6df3ae40db52130e19fe8299a7b43',
69
+ });
70
+ l1l2ContractAddress = deploy.contract_address;
109
71
  });
110
72
 
111
73
  test('estimate message fee', async () => {
@@ -128,4 +90,34 @@ describeIfSequencer('SequencerProvider', () => {
128
90
  );
129
91
  });
130
92
  });
93
+
94
+ describeIfDevnet('Test calls with Custom Devnet Sequencer Provider', () => {
95
+ let erc20: Contract;
96
+ const wallet = stark.randomAddress();
97
+
98
+ beforeAll(async () => {
99
+ customSequencerProvider = new Provider({
100
+ sequencer: {
101
+ baseUrl: 'http://127.0.0.1:5050/',
102
+ feederGatewayUrl: 'feeder_gateway',
103
+ gatewayUrl: 'gateway',
104
+ },
105
+ });
106
+ const accountCustom = getTestAccount(customSequencerProvider);
107
+ const { deploy } = await accountCustom.declareDeploy({
108
+ contract: compiledErc20,
109
+ classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
110
+ constructorCalldata: [encodeShortString('Token'), encodeShortString('ERC20'), wallet],
111
+ });
112
+
113
+ erc20 = new Contract(compiledErc20.abi, deploy.contract_address, customSequencerProvider);
114
+ });
115
+
116
+ test('Check ERC20 balance using Custom Sequencer Provider', async () => {
117
+ const result = await erc20.balanceOf(wallet);
118
+ const [res] = result;
119
+ expect(res.low).toStrictEqual(toBN(1000));
120
+ expect(res).toStrictEqual(result.balance);
121
+ });
122
+ });
131
123
  });
@@ -27,12 +27,21 @@ describe('compressProgram()', () => {
27
27
  expect(compressed).toMatchSnapshot();
28
28
  });
29
29
  });
30
+
30
31
  describe('hexToDecimalString()', () => {
31
32
  test('parse 0xa23', () => {
32
33
  expect(number.hexToDecimalString('0xa23')).toBe('2595');
33
34
  });
34
35
  });
35
36
 
37
+ describe('cleanHex()', () => {
38
+ test('parse 0xa23', () => {
39
+ expect(number.cleanHex('0x023Ab')).toBe('0x23ab');
40
+ expect(number.cleanHex('0x000023Ab')).toBe('0x23ab');
41
+ expect(number.cleanHex('0x23Ab')).toBe('0x23ab');
42
+ });
43
+ });
44
+
36
45
  describe('makeAddress()', () => {
37
46
  test('test on eth address', () => {
38
47
  const ethAddress = '0xdFD0F27FCe99b50909de0bDD328Aed6eAbe76BC5';
@@ -42,6 +51,7 @@ describe('makeAddress()', () => {
42
51
  expect(starkAddress).toBe('0xdfd0f27fce99b50909de0bdd328aed6eabe76bc5');
43
52
  });
44
53
  });
54
+
45
55
  describe('getSelectorFromName()', () => {
46
56
  test('hash works for value="test"', () => {
47
57
  expect(hash.getSelectorFromName('test')).toBe(
package/dist/index.d.ts CHANGED
@@ -9,6 +9,11 @@ declare function toBN(number: BigNumberish, base?: number | 'hex'): BN__default;
9
9
  declare function toHex(number: BN__default): string;
10
10
  declare function hexToDecimalString(hex: string): string;
11
11
  declare function toFelt(num: BigNumberish): string;
12
+ /**
13
+ * Remove hex string leading zero and lower case '0x01A'.. -> '0x1a..'
14
+ * @param hex string
15
+ */
16
+ declare const cleanHex: (hex: string) => string;
12
17
  declare function assertInRange(input: BigNumberish, lowerBound: BigNumberish, upperBound: BigNumberish, inputName?: string): void;
13
18
  declare function bigNumberishArrayToDecimalStringArray(rawCalldata: BigNumberish[]): string[];
14
19
  declare function bigNumberishArrayToHexadecimalStringArray(rawCalldata: BigNumberish[]): string[];
@@ -25,6 +30,7 @@ declare const number_toBN: typeof toBN;
25
30
  declare const number_toHex: typeof toHex;
26
31
  declare const number_hexToDecimalString: typeof hexToDecimalString;
27
32
  declare const number_toFelt: typeof toFelt;
33
+ declare const number_cleanHex: typeof cleanHex;
28
34
  declare const number_assertInRange: typeof assertInRange;
29
35
  declare const number_bigNumberishArrayToDecimalStringArray: typeof bigNumberishArrayToDecimalStringArray;
30
36
  declare const number_bigNumberishArrayToHexadecimalStringArray: typeof bigNumberishArrayToHexadecimalStringArray;
@@ -42,6 +48,7 @@ declare namespace number {
42
48
  number_toHex as toHex,
43
49
  number_hexToDecimalString as hexToDecimalString,
44
50
  number_toFelt as toFelt,
51
+ number_cleanHex as cleanHex,
45
52
  number_assertInRange as assertInRange,
46
53
  number_bigNumberishArrayToDecimalStringArray as bigNumberishArrayToDecimalStringArray,
47
54
  number_bigNumberishArrayToHexadecimalStringArray as bigNumberishArrayToHexadecimalStringArray,
@@ -686,8 +693,8 @@ interface ContractClass {
686
693
  }
687
694
  declare type UniversalDeployerContractPayload = {
688
695
  classHash: BigNumberish;
689
- salt: string;
690
- unique: boolean;
696
+ salt?: string;
697
+ unique?: boolean;
691
698
  constructorCalldata?: RawArgs;
692
699
  additionalCalls?: AllowArray<Call>;
693
700
  };
@@ -709,6 +716,7 @@ declare type DeclareContractPayload = {
709
716
  contract: CompiledContract | string;
710
717
  classHash: BigNumberish;
711
718
  };
719
+ declare type DeclareDeployContractPayload = DeclareContractPayload & UniversalDeployerContractPayload;
712
720
  declare type DeclareContractTransaction = {
713
721
  contractDefinition: ContractClass;
714
722
  senderAddress: string;
@@ -1013,10 +1021,6 @@ interface EstimateFeeResponse {
1013
1021
  interface InvokeFunctionResponse {
1014
1022
  transaction_hash: string;
1015
1023
  }
1016
- interface DeployContractResponse {
1017
- contract_address: string;
1018
- transaction_hash: string;
1019
- }
1020
1024
  interface DeclareContractResponse {
1021
1025
  transaction_hash: string;
1022
1026
  class_hash: string;
@@ -1045,6 +1049,23 @@ interface EstimateFeeDetails {
1045
1049
  nonce?: BigNumberish;
1046
1050
  blockIdentifier?: BlockIdentifier;
1047
1051
  }
1052
+ interface DeployContractResponse {
1053
+ contract_address: string;
1054
+ transaction_hash: string;
1055
+ }
1056
+ interface DeployContractUDCResponse extends DeployContractResponse {
1057
+ address: string;
1058
+ deployer: string;
1059
+ unique: string;
1060
+ classHash: string;
1061
+ calldata_len: string;
1062
+ calldata: Array<string>;
1063
+ salt: string;
1064
+ }
1065
+ declare type DeclareDeployContractResponse = {
1066
+ declare: DeclareTransactionReceiptResponse;
1067
+ deploy: DeployContractUDCResponse;
1068
+ };
1048
1069
 
1049
1070
  declare type GetTransactionStatusResponse = {
1050
1071
  tx_status: Status;
@@ -1413,7 +1434,7 @@ declare abstract class ProviderInterface {
1413
1434
  * @param contractAddress - contract address
1414
1435
  * @returns the hex nonce
1415
1436
  */
1416
- abstract getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1437
+ abstract getNonceForAddress(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1417
1438
  /**
1418
1439
  * Gets the contract's storage variable at a specific key.
1419
1440
  *
@@ -1448,7 +1469,7 @@ declare abstract class ProviderInterface {
1448
1469
  * - address salt
1449
1470
  * @returns a confirmation of sending a transaction on the starknet contract
1450
1471
  */
1451
- abstract deployContract(payload: DeployContractPayload, details?: InvocationsDetails): Promise<DeployContractResponse>;
1472
+ abstract deployContract(payload: DeployContractPayload | any, details?: InvocationsDetails): Promise<DeployContractResponse>;
1452
1473
  /**
1453
1474
  * Deploys a given compiled Account contract (json) to starknet
1454
1475
  *
@@ -1554,8 +1575,9 @@ declare abstract class ProviderInterface {
1554
1575
  * Wait for the transaction to be accepted
1555
1576
  * @param txHash - transaction hash
1556
1577
  * @param retryInterval - retry interval
1578
+ * @return GetTransactionReceiptResponse
1557
1579
  */
1558
- abstract waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
1580
+ abstract waitForTransaction(txHash: BigNumberish, successStates?: Array<Status>, retryInterval?: number): Promise<GetTransactionReceiptResponse>;
1559
1581
  }
1560
1582
 
1561
1583
  declare type RpcProviderOptions = {
@@ -1579,7 +1601,7 @@ declare class RpcProvider implements ProviderInterface {
1579
1601
  getBlockWithTxHashes(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxHashesResponse>;
1580
1602
  getBlockWithTxs(blockIdentifier?: BlockIdentifier): Promise<RPC.GetBlockWithTxs>;
1581
1603
  getClassHashAt(contractAddress: RPC.ContractAddress, blockIdentifier?: BlockIdentifier): Promise<RPC.Felt>;
1582
- getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.Nonce>;
1604
+ getNonceForAddress(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<RPC.Nonce>;
1583
1605
  getPendingTransactions(): Promise<RPC.PendingTransactions>;
1584
1606
  getProtocolVersion(): Promise<Error>;
1585
1607
  getStateUpdate(blockIdentifier?: BlockIdentifier): Promise<RPC.StateUpdate>;
@@ -1606,7 +1628,7 @@ declare class RpcProvider implements ProviderInterface {
1606
1628
  callContract(call: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
1607
1629
  traceTransaction(transactionHash: RPC.TransactionHash): Promise<RPC.Trace>;
1608
1630
  traceBlockTransactions(blockHash: RPC.BlockHash): Promise<RPC.Traces>;
1609
- waitForTransaction(txHash: string, retryInterval?: number): Promise<void>;
1631
+ waitForTransaction(txHash: string, successStates?: string[], retryInterval?: number): Promise<any>;
1610
1632
  /**
1611
1633
  * Gets the transaction count from a block.
1612
1634
  *
@@ -1666,7 +1688,7 @@ declare class SequencerProvider implements ProviderInterface {
1666
1688
  getChainId(): Promise<StarknetChainId>;
1667
1689
  callContract({ contractAddress, entrypoint: entryPointSelector, calldata }: Call, blockIdentifier?: BlockIdentifier): Promise<CallContractResponse>;
1668
1690
  getBlock(blockIdentifier?: BlockIdentifier): Promise<GetBlockResponse>;
1669
- getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1691
+ getNonceForAddress(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1670
1692
  getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1671
1693
  getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
1672
1694
  getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
@@ -1685,7 +1707,7 @@ declare class SequencerProvider implements ProviderInterface {
1685
1707
  getDeclareEstimateFee({ senderAddress, contractDefinition, signature }: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1686
1708
  getDeployAccountEstimateFee({ classHash, addressSalt, constructorCalldata, signature }: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1687
1709
  getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<Sequencer.GetCodeResponse>;
1688
- waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
1710
+ waitForTransaction(txHash: BigNumberish, successStates?: string[], retryInterval?: number): Promise<GetTransactionReceiptResponse>;
1689
1711
  /**
1690
1712
  * Gets the status of a transaction.
1691
1713
  *
@@ -1728,7 +1750,7 @@ declare class Provider implements ProviderInterface {
1728
1750
  getClassByHash(classHash: string): Promise<ContractClass>;
1729
1751
  getEstimateFee(invocationWithTxType: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1730
1752
  getInvokeEstimateFee(invocationWithTxType: Invocation, invocationDetails: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1731
- getNonce(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1753
+ getNonceForAddress(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1732
1754
  getStorageAt(contractAddress: string, key: BigNumberish, blockIdentifier?: BlockIdentifier): Promise<BigNumberish>;
1733
1755
  getTransaction(txHash: BigNumberish): Promise<GetTransactionResponse>;
1734
1756
  getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
@@ -1737,13 +1759,13 @@ declare class Provider implements ProviderInterface {
1737
1759
  /**
1738
1760
  * @deprecated This method won't be supported, use Account.deploy instead
1739
1761
  */
1740
- deployContract(payload: DeployContractPayload, details: InvocationsDetails): Promise<DeployContractResponse>;
1762
+ deployContract(payload: DeployContractPayload | any, details: InvocationsDetails): Promise<DeployContractResponse>;
1741
1763
  deployAccountContract(payload: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeployContractResponse>;
1742
1764
  declareContract(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce): Promise<DeclareContractResponse>;
1743
1765
  getDeclareEstimateFee(transaction: DeclareContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1744
1766
  getDeployAccountEstimateFee(transaction: DeployAccountContractTransaction, details: InvocationsDetailsWithNonce, blockIdentifier?: BlockIdentifier): Promise<EstimateFeeResponse>;
1745
1767
  getCode(contractAddress: string, blockIdentifier?: BlockIdentifier): Promise<GetCodeResponse>;
1746
- waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise<void>;
1768
+ waitForTransaction(txHash: BigNumberish, successStates?: Array<Status>, retryInterval?: number): Promise<any>;
1747
1769
  }
1748
1770
 
1749
1771
  declare class GatewayError extends CustomError {
@@ -2041,7 +2063,6 @@ declare abstract class AccountInterface extends ProviderInterface {
2041
2063
  * @param contractPayload transaction payload to be deployed containing:
2042
2064
  - contract: compiled contract code
2043
2065
  - classHash: computed class hash of compiled contract
2044
- - signature
2045
2066
  * @param transactionsDetail Invocation Details containing:
2046
2067
  - optional nonce
2047
2068
  - optional version
@@ -2055,16 +2076,72 @@ declare abstract class AccountInterface extends ProviderInterface {
2055
2076
  *
2056
2077
  * @param deployContractPayload containing
2057
2078
  * - classHash: computed class hash of compiled contract
2058
- * - salt: address salt
2059
- * - unique: bool if true ensure unique salt
2060
- * - calldata: constructor calldata
2061
- * - additionalCalls - optional additional calls array to support multicall
2079
+ * - constructorCalldata: constructor calldata
2080
+ * - optional salt: address salt - default random
2081
+ * - optional unique: bool if true ensure unique salt - default true
2082
+ * - optional additionalCalls - optional additional calls array to support multi-call
2062
2083
  * @param transactionsDetail Invocation Details containing:
2063
2084
  * - optional nonce
2064
2085
  * - optional version
2065
2086
  * - optional maxFee
2087
+ * @returns Promise<InvokeFunctionResponse>
2088
+ * - transaction_hash
2066
2089
  */
2067
2090
  abstract deploy(deployContractPayload: UniversalDeployerContractPayload, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2091
+ /**
2092
+ * Simplify deploy simulating old DeployContract with same response + UDC specific response
2093
+ *
2094
+ * @param payload UniversalDeployerContractPayload
2095
+ * - classHash: computed class hash of compiled contract
2096
+ * - constructorCalldata: constructor calldata
2097
+ * - optional salt: address salt - default random
2098
+ * - optional unique: bool if true ensure unique salt - default true
2099
+ * - optional additionalCalls - optional additional calls array to support multi-call
2100
+ * @param details InvocationsDetails
2101
+ * - optional nonce
2102
+ * - optional version
2103
+ * - optional maxFee
2104
+ * @returns Promise<DeployContractUDCResponse>
2105
+ * - contract_address
2106
+ * - transaction_hash
2107
+ * - address
2108
+ * - deployer
2109
+ * - unique
2110
+ * - classHash
2111
+ * - calldata_len
2112
+ * - calldata
2113
+ * - salt
2114
+ */
2115
+ abstract deployContract(payload: UniversalDeployerContractPayload, details: InvocationsDetails): Promise<DeployContractUDCResponse>;
2116
+ /**
2117
+ * Declares and Deploy a given compiled contract (json) to starknet using UDC
2118
+ *
2119
+ * @param declareDeployerContractPayload containing
2120
+ * - contract: compiled contract code
2121
+ * - classHash: computed class hash of compiled contract
2122
+ * - optional constructorCalldata: constructor calldata
2123
+ * - optional salt: address salt - default random
2124
+ * - optional unique: bool if true ensure unique salt - default true
2125
+ * - optional additionalCalls: - optional additional calls array to support multicall
2126
+ * @param details
2127
+ * - optional nonce
2128
+ * - optional version
2129
+ * - optional maxFee
2130
+ * @returns Promise<DeclareDeployContractResponse>
2131
+ * - declare
2132
+ * - transaction_hash
2133
+ * - deploy
2134
+ * - contract_address
2135
+ * - transaction_hash
2136
+ * - address
2137
+ * - deployer
2138
+ * - unique
2139
+ * - classHash
2140
+ * - calldata_len
2141
+ * - calldata
2142
+ * - salt
2143
+ */
2144
+ abstract declareDeploy(declareDeployerContractPayload: DeclareDeployContractPayload, details?: InvocationsDetails): Promise<DeclareDeployContractResponse>;
2068
2145
  /**
2069
2146
  * Deploy the account on Starknet
2070
2147
  *
@@ -2146,7 +2223,12 @@ declare class Account extends Provider implements AccountInterface {
2146
2223
  estimateDeployFee({ classHash, salt, unique, constructorCalldata, additionalCalls, }: UniversalDeployerContractPayload, transactionsDetail?: InvocationsDetails | undefined): Promise<EstimateFee>;
2147
2224
  execute(calls: AllowArray<Call>, abis?: Abi[] | undefined, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2148
2225
  declare({ classHash, contract }: DeclareContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeclareContractResponse>;
2149
- deploy({ classHash, salt, unique, constructorCalldata, additionalCalls, }: UniversalDeployerContractPayload, transactionsDetail?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2226
+ deploy({ classHash, salt, unique, constructorCalldata, additionalCalls, }: UniversalDeployerContractPayload, invocationsDetails?: InvocationsDetails): Promise<InvokeFunctionResponse>;
2227
+ deployContract(payload: UniversalDeployerContractPayload, details?: InvocationsDetails): Promise<DeployContractUDCResponse>;
2228
+ declareDeploy({ classHash, contract, constructorCalldata }: DeclareDeployContractPayload, details?: InvocationsDetails): Promise<{
2229
+ declare: any;
2230
+ deploy: DeployContractUDCResponse;
2231
+ }>;
2150
2232
  deployAccount({ classHash, constructorCalldata, addressSalt, contractAddress: providedContractAddress, }: DeployAccountContractPayload, transactionsDetail?: InvocationsDetails): Promise<DeployContractResponse>;
2151
2233
  signMessage(typedData: TypedData): Promise<Signature>;
2152
2234
  hashMessage(typedData: TypedData): Promise<string>;
@@ -2338,8 +2420,9 @@ declare class Contract implements ContractInterface {
2338
2420
  declare class ContractFactory {
2339
2421
  abi: Abi;
2340
2422
  compiledContract: CompiledContract;
2341
- providerOrAccount: ProviderInterface | AccountInterface;
2342
- constructor(compiledContract: CompiledContract, providerOrAccount?: ProviderInterface | AccountInterface, abi?: Abi);
2423
+ classHash: string;
2424
+ account: AccountInterface;
2425
+ constructor(compiledContract: CompiledContract, classHash: string, account: AccountInterface, abi?: Abi);
2343
2426
  /**
2344
2427
  * Deploys contract and returns new instance of the Contract
2345
2428
  *
@@ -2347,13 +2430,14 @@ declare class ContractFactory {
2347
2430
  * @param addressSalt (optional) - Address Salt for deployment
2348
2431
  * @returns deployed Contract
2349
2432
  */
2350
- deploy(constructorCalldata?: RawCalldata, addressSalt?: string | undefined): Promise<Contract>;
2433
+ deploy(constructorCalldata?: RawArgs, addressSalt?: string | undefined): Promise<Contract>;
2351
2434
  /**
2352
2435
  * Attaches to new Provider or Account
2353
2436
  *
2354
- * @param providerOrAccount - new Provider or Account to attach to
2437
+ * @param account - new Provider or Account to attach to
2438
+ * @returns ContractFactory
2355
2439
  */
2356
- connect(providerOrAccount: ProviderInterface | AccountInterface): ContractFactory;
2440
+ connect(account: AccountInterface): ContractFactory;
2357
2441
  /**
2358
2442
  * Attaches current abi and provider or account to the new address
2359
2443
  *
@@ -2648,4 +2732,4 @@ declare function validateChecksumAddress(address: string): boolean;
2648
2732
  declare function isUrl(s?: string): boolean;
2649
2733
  declare function buildUrl(baseUrl: string, defaultPath: string, urlOrPath?: string): string;
2650
2734
 
2651
- export { Abi, AbiEntry, Account, AccountInterface, AllowArray, Args, AsyncContractFunction, BlockNumber, BlockTag, Call, CallContractResponse, CallDetails, CallL1Handler, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompressedCompiledContract, CompressedProgram, Contract, ContractClass, ContractEntryPoint, ContractFactory, ContractFunction, ContractInterface, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractPayload, DeployContractResponse, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeDetails, EstimateFeeResponse, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, GetTransactionTraceResponse, HttpError, Invocation, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, KeyPair, MessageToL1, MessageToL2, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, RPC, RawArgs, RawCalldata, Result, RpcProvider, RpcProviderOptions, Sequencer, SequencerProvider, SequencerProviderOptions, Signature, Signer, SignerInterface, Status, Struct, StructAbi, TransactionStatus, TransactionType, UniversalDeployerContractPayload, addAddressPadding, buildUrl, constants, defaultProvider, ellipticCurve as ec, encode, getChecksumAddress, hash, isUrl, json, merkle, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress };
2735
+ export { Abi, AbiEntry, Account, AccountInterface, AllowArray, Args, AsyncContractFunction, BlockNumber, BlockTag, Call, CallContractResponse, CallDetails, CallL1Handler, Calldata, CommonTransactionReceiptResponse, CommonTransactionResponse, CompiledContract, CompressedCompiledContract, CompressedProgram, Contract, ContractClass, ContractEntryPoint, ContractFactory, ContractFunction, ContractInterface, DeclareContractPayload, DeclareContractResponse, DeclareContractTransaction, DeclareDeployContractPayload, DeclareDeployContractResponse, DeclareSignerDetails, DeclareTransactionReceiptResponse, DeclareTransactionResponse, DeployAccountContractPayload, DeployAccountContractTransaction, DeployAccountSignerDetails, DeployContractPayload, DeployContractResponse, DeployContractUDCResponse, EntryPointType, EntryPointsByType, EstimateFee, EstimateFeeAction, EstimateFeeDetails, EstimateFeeResponse, Event, ExecutionResources, FunctionAbi, FunctionInvocation, GatewayError, GetBlockResponse, GetCodeResponse, GetContractAddressesResponse, GetTransactionReceiptResponse, GetTransactionResponse, GetTransactionStatusResponse, GetTransactionTraceResponse, HttpError, Invocation, InvocationsDetails, InvocationsDetailsWithNonce, InvocationsSignerDetails, InvokeFunctionResponse, InvokeTransactionReceiptResponse, InvokeTransactionResponse, KeyPair, MessageToL1, MessageToL2, Overrides, ParsedStruct, Program, Provider, ProviderInterface, ProviderOptions, RPC, RawArgs, RawCalldata, Result, RpcProvider, RpcProviderOptions, Sequencer, SequencerProvider, SequencerProviderOptions, Signature, Signer, SignerInterface, Status, Struct, StructAbi, TransactionStatus, TransactionType, UniversalDeployerContractPayload, addAddressPadding, buildUrl, constants, defaultProvider, ellipticCurve as ec, encode, getChecksumAddress, hash, isUrl, json, merkle, number, shortString, stark, transaction, index as typedData, uint256, validateAndParseAddress, validateChecksumAddress };