starknet 4.2.0 → 4.4.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 +44 -0
- package/__mocks__/typedDataSessionExample.json +42 -0
- package/__tests__/defaultProvider.test.ts +11 -24
- package/__tests__/rpcProvider.test.ts +3 -3
- package/__tests__/sequencerProvider.test.ts +40 -2
- package/__tests__/utils/__snapshots__/ellipticalCurve.test.ts.snap +2 -0
- package/__tests__/utils/ellipticalCurve.test.ts +5 -0
- package/__tests__/utils/merkle.test.ts +146 -0
- package/__tests__/utils/typedData.test.ts +107 -9
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/provider/default.d.ts +2 -2
- package/dist/provider/default.js +3 -3
- package/dist/provider/interface.d.ts +6 -3
- package/dist/provider/rpc.d.ts +9 -4
- package/dist/provider/rpc.js +67 -25
- package/dist/provider/sequencer.d.ts +2 -2
- package/dist/provider/sequencer.js +9 -9
- package/dist/provider/utils.d.ts +12 -0
- package/dist/provider/utils.js +17 -1
- package/dist/signer/default.d.ts +1 -1
- package/dist/signer/default.js +1 -0
- package/dist/types/api/openrpc.d.ts +151 -0
- package/dist/types/api/openrpc.js +9 -0
- package/dist/types/api/rpc.d.ts +22 -43
- package/dist/types/provider.d.ts +5 -5
- package/dist/utils/ellipticCurve.d.ts +13 -0
- package/dist/utils/ellipticCurve.js +20 -16
- package/dist/utils/hash.js +8 -6
- package/dist/utils/merkle.d.ts +10 -0
- package/dist/utils/merkle.js +90 -0
- package/dist/utils/number.js +1 -1
- package/dist/utils/responseParser/rpc.d.ts +13 -3
- package/dist/utils/responseParser/rpc.js +2 -10
- package/dist/utils/responseParser/sequencer.d.ts +4 -1
- package/dist/utils/responseParser/sequencer.js +1 -7
- package/dist/utils/typedData/index.d.ts +23 -8
- package/dist/utils/typedData/index.js +70 -31
- package/dist/utils/typedData/types.d.ts +8 -3
- package/dist/utils/url.d.ts +7 -0
- package/dist/utils/url.js +49 -0
- package/index.d.ts +2 -0
- package/index.js +3 -1
- package/package.json +1 -1
- package/provider/default.d.ts +2 -2
- package/provider/default.js +3 -3
- package/provider/interface.d.ts +6 -3
- package/provider/rpc.d.ts +9 -4
- package/provider/rpc.js +67 -25
- package/provider/sequencer.d.ts +2 -2
- package/provider/sequencer.js +9 -9
- package/provider/utils.d.ts +12 -0
- package/provider/utils.js +17 -1
- package/signer/default.d.ts +1 -1
- package/signer/default.js +1 -0
- package/src/index.ts +2 -0
- package/src/provider/default.ts +2 -3
- package/src/provider/interface.ts +5 -3
- package/src/provider/rpc.ts +56 -34
- package/src/provider/sequencer.ts +11 -9
- package/src/provider/utils.ts +22 -1
- package/src/signer/default.ts +2 -2
- package/src/types/api/openrpc.ts +168 -0
- package/src/types/api/rpc.ts +22 -45
- package/src/types/provider.ts +5 -5
- package/src/utils/ellipticCurve.ts +20 -16
- package/src/utils/hash.ts +8 -6
- package/src/utils/merkle.ts +70 -0
- package/src/utils/number.ts +1 -1
- package/src/utils/responseParser/rpc.ts +16 -13
- package/src/utils/responseParser/sequencer.ts +5 -8
- package/src/utils/typedData/index.ts +88 -34
- package/src/utils/typedData/types.ts +12 -4
- package/src/utils/url.ts +53 -0
- package/types/api/openrpc.d.ts +151 -0
- package/types/api/openrpc.js +9 -0
- package/types/api/rpc.d.ts +22 -43
- package/types/provider.d.ts +5 -5
- package/utils/ellipticCurve.d.ts +13 -0
- package/utils/ellipticCurve.js +20 -16
- package/utils/hash.js +8 -6
- package/utils/merkle.d.ts +10 -0
- package/utils/merkle.js +90 -0
- package/utils/number.js +1 -1
- package/utils/responseParser/rpc.d.ts +13 -3
- package/utils/responseParser/rpc.js +2 -10
- package/utils/responseParser/sequencer.d.ts +4 -1
- package/utils/responseParser/sequencer.js +1 -7
- package/utils/typedData/index.d.ts +23 -8
- package/utils/typedData/index.js +70 -31
- package/utils/typedData/types.d.ts +8 -3
- package/utils/url.d.ts +7 -0
- package/utils/url.js +49 -0
- package/www/docs/API/account.md +20 -18
- package/www/docs/API/contract.md +10 -10
- package/www/docs/API/contractFactory.md +14 -11
- package/www/docs/API/provider.md +60 -37
- package/www/docs/API/signer.md +8 -10
- package/www/docs/API/utils.md +151 -74
- package/www/guides/account.md +12 -12
- package/www/guides/erc20.md +19 -4
- package/www/guides/intro.md +3 -1
package/www/guides/account.md
CHANGED
|
@@ -43,9 +43,9 @@ const compiledAccount = json.parse(
|
|
|
43
43
|
);
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
> **Note**
|
|
47
|
-
>
|
|
48
|
-
> below example uses [Argent's](https://github.com/argentlabs/argent-contracts-starknet/blob/develop/contracts/ArgentAccount.cairo) account contract
|
|
46
|
+
> **Note**
|
|
47
|
+
>
|
|
48
|
+
> below example uses [Argent's](https://github.com/argentlabs/argent-contracts-starknet/blob/develop/contracts/ArgentAccount.cairo) account contract
|
|
49
49
|
|
|
50
50
|
```javascript
|
|
51
51
|
const accountResponse = await defaultProvider.deployContract({
|
|
@@ -54,9 +54,9 @@ const accountResponse = await defaultProvider.deployContract({
|
|
|
54
54
|
});
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
> **Note**
|
|
58
|
-
>
|
|
59
|
-
> below example uses [OpenZeppelin's](https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/openzeppelin/account/presets/Account.cairo) account contract
|
|
57
|
+
> **Note**
|
|
58
|
+
>
|
|
59
|
+
> below example uses [OpenZeppelin's](https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/openzeppelin/account/presets/Account.cairo) account contract
|
|
60
60
|
|
|
61
61
|
```javascript
|
|
62
62
|
const accountResponse = await defaultProvider.deployContract({
|
|
@@ -74,16 +74,16 @@ Wait for the deployment transaction to be accepted and assign the address of the
|
|
|
74
74
|
await defaultProvider.waitForTransaction(accountResponse.transaction_hash);
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
Once account contract is deployed [Account](../docs/API/account.md) instance can be created. Use your new account instance to sign transactions, messages or verify signatures!
|
|
78
|
-
|
|
79
|
-
> **Note**
|
|
80
|
-
>
|
|
81
|
-
> Make sure your Account has enough funds to execute invocations. Use this [faucet](https://faucet.goerli.starknet.io/) for funding on testnet.
|
|
77
|
+
Once account contract is deployed [Account](../docs/API/account.md) instance can be created. Use your new account instance to sign transactions, messages or verify signatures!
|
|
82
78
|
|
|
83
79
|
```js
|
|
84
80
|
const account = new Account(
|
|
85
81
|
defaultProvider,
|
|
86
|
-
accountResponse.
|
|
82
|
+
accountResponse.contract_address,
|
|
87
83
|
starkKeyPair
|
|
88
84
|
);
|
|
89
85
|
```
|
|
86
|
+
|
|
87
|
+
## Fund your new account!
|
|
88
|
+
|
|
89
|
+
Make sure your Account has enough funds to execute invocations. Use this [faucet](https://faucet.goerli.starknet.io/) for funding on testnet.
|
package/www/guides/erc20.md
CHANGED
|
@@ -20,26 +20,41 @@ await defaultProvider.waitForTransaction(erc20Response.transaction_hash);
|
|
|
20
20
|
## Get the erc20 contract address and create the contact object
|
|
21
21
|
|
|
22
22
|
```javascript
|
|
23
|
-
const erc20Address = erc20Response.
|
|
24
|
-
const erc20 = new Contract(compiledErc20.abi, erc20Address);
|
|
23
|
+
const erc20Address = erc20Response.contract_address;
|
|
24
|
+
const erc20 = new Contract(compiledErc20.abi, erc20Address, defaultProvider);
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Mint tokens to an account address
|
|
28
28
|
|
|
29
29
|
Make sure you created the `Account` instance following the [Creating an Account](./account.md) guide.
|
|
30
30
|
|
|
31
|
+
Also make sure you added funds to your account!
|
|
32
|
+
|
|
31
33
|
```javascript
|
|
32
34
|
erc20.connect(account);
|
|
33
35
|
|
|
34
36
|
const { transaction_hash: mintTxHash } = await erc20.mint(
|
|
35
37
|
account.address,
|
|
36
|
-
"1000"
|
|
38
|
+
"1000",
|
|
39
|
+
{
|
|
40
|
+
maxFee: "1"
|
|
41
|
+
}
|
|
37
42
|
);
|
|
38
43
|
|
|
39
44
|
console.log(`Waiting for Tx to be Accepted on Starknet - Minting...`);
|
|
40
45
|
await defaultProvider.waitForTransaction(mintTxHash);
|
|
41
46
|
```
|
|
42
47
|
|
|
48
|
+
> **Note**
|
|
49
|
+
>
|
|
50
|
+
> Transaction can be rejected if `maxFee` is lower than actual.
|
|
51
|
+
>
|
|
52
|
+
> _Error: REJECTED: FEE_TRANSFER_FAILURE_
|
|
53
|
+
>
|
|
54
|
+
> _Actual fee exceeded max fee._
|
|
55
|
+
>
|
|
56
|
+
> If this occurs, set `maxFee` to a higher value, for example: 999999995330000
|
|
57
|
+
|
|
43
58
|
## Check balance after mint
|
|
44
59
|
|
|
45
60
|
```javascript
|
|
@@ -64,7 +79,7 @@ const { transaction_hash: transferTxHash } = await account.execute(
|
|
|
64
79
|
calldata: [erc20Address, "10"],
|
|
65
80
|
},
|
|
66
81
|
undefined,
|
|
67
|
-
{ maxFee: "
|
|
82
|
+
{ maxFee: "1" }
|
|
68
83
|
);
|
|
69
84
|
|
|
70
85
|
// Wait for the invoke transaction to be accepted on StarkNet
|
package/www/guides/intro.md
CHANGED
|
@@ -16,6 +16,8 @@ npm install starknet@next
|
|
|
16
16
|
|
|
17
17
|
Please check the StarkNet documentation <ins>[here](https://www.cairo-lang.org/docs/hello_starknet/intro.html)</ins> to compile starknet contracts.
|
|
18
18
|
|
|
19
|
+
Additional helpful resources can also be found at [OpenZeppelin](https://docs.openzeppelin.com/contracts-cairo/0.3.1/) documentation site.
|
|
20
|
+
|
|
19
21
|
## Full example with account & erc20
|
|
20
22
|
|
|
21
|
-
Please
|
|
23
|
+
Please take a look at our workshop <ins>[here](https://github.com/0xs34n/starknet.js-workshop)</ins>.
|