|
2 | 2 | sidebar_position: 101
|
3 | 3 | ---
|
4 | 4 |
|
5 |
| -# Migrate from v5 to v6 |
| 5 | +# Migrate from v6 to v7 |
6 | 6 |
|
7 |
| -This document only covers the features present in v5 which have changed in some significant way in v6. |
| 7 | +This document only covers the features present in v6 which have changed in some significant way in v7. |
8 | 8 |
|
9 | 9 | If you encounter any missing changes, please let us know and we will update this guide.
|
10 | 10 |
|
11 |
| -## Transaction receipt |
| 11 | +## Fetch dependencies |
12 | 12 |
|
13 |
| -When sending a transaction, the receipt type has changed. |
14 |
| -In V5, it's an object that can have varied definitions, depending on the status and the type of transaction. |
15 |
| -In V6, this object is in `TxR.value`, and several helpers are available (`.statusReceipt`, `isSuccess()`, `isRejected()`, `isReverted()`, `.isError()`, `match`, ...) |
| 13 | +`isomorphic-fetch` and `fetch-cookie` have been removed as dependencies. |
16 | 14 |
|
17 |
| -```typescript |
18 |
| -const response = await ethContract.approve(swapContractAddress, cairo.uint256(100000)); |
19 |
| -const transactionReceipt = await provider.waitForTransaction(response.transaction_hash); |
20 |
| - |
21 |
| -// v5 : transactionReceipt is just an object |
22 |
| -{ |
23 |
| -type: 'INVOKE', |
24 |
| - transaction_hash: '0x5286217518c621581ac85505a99ffe182ce1114abaa8fce8b418d2b27c3c04c', |
25 |
| - actual_fee: { unit: 'WEI', amount: '0x1c1902fe99800' }, |
26 |
| - messages_sent: [], |
27 |
| - execution_status: 'SUCCEEDED', |
28 |
| - finality_status: 'ACCEPTED_ON_L2', |
29 |
| - // ... |
30 |
| -} |
31 |
| -// v6 : transactionReceipt is an object + helpers |
32 |
| -const receipt = transactionReceipt.value; |
33 |
| -const status: boolean = transactionReceipt.isSuccess(); |
34 |
| - |
35 |
| -``` |
36 |
| - |
37 |
| -> See this [guide](./interact.md#transaction-receipt-response) |
38 |
| -
|
39 |
| -## Long strings |
40 |
| - |
41 |
| -Starknet.js v6 is compatible with Cairo v2.4.0. It means that long strings (>31 characters) are automatically handled and converted to the Cairo `ByteArray` type. |
42 |
| -This means that the approach to convert a long string to an array of felts (for Cairo 0 contracts for example) has changed: |
| 15 | +For users who might require the features of either library, a `baseFetch` override parameter has been enabled for the `RpcProvider` and `RpcChannel` classes, including classes that inherit from them such as `Account` and `WalletAccount`. |
43 | 16 |
|
44 | 17 | ```typescript
|
45 |
| -// v5 |
46 |
| -const feltArray: BigNumberish[] = CallData.compile( |
47 |
| - 'http://addressOfMyERC721pictures/storage/image1.jpg' |
48 |
| -); |
| 18 | +import makeFetchCookie from 'fetch-cookie'; |
| 19 | +import isomorphicFetch from 'isomorphic-fetch'; |
49 | 20 |
|
50 |
| -// v6 |
51 |
| -const feltArray: BigNumberish[] = CallData.compile( |
52 |
| - shortString.splitLongString('http://addressOfMyERC721pictures/storage/image1.jpg') |
53 |
| -); |
| 21 | +const provider = new RpcProvider({ |
| 22 | + baseFetch: makeFetchCookie(isomorphicFetch), |
| 23 | +}); |
54 | 24 | ```
|
55 | 25 |
|
56 |
| -## Fees |
57 |
| - |
58 |
| -All functions related to gas price and fee estimation have changed output types. |
59 |
| - |
60 |
| -For example, if you read the content of a block with v5 the ETH gas price was a top level property, with v6 the same information is nested a level deeper: |
61 |
| - |
62 |
| -```typescript |
63 |
| -const resp: GetBlockResponse = await myProvider.getBlock('latest'); |
64 |
| - |
65 |
| -// v5 |
66 |
| -const gasPrice = resp.gas_price; |
67 |
| - |
68 |
| -// v6 |
69 |
| -const gasPrice = resp.l1_gas_price.price_in_wei; |
70 |
| -``` |
71 |
| - |
72 |
| -Another example is `estimateDeclareFee()` where the response object has changed: |
73 |
| - |
74 |
| -```typescript |
75 |
| -const fee = await account0.estimateDeclareFee({ contract: compiledContract }); |
76 |
| - |
77 |
| -// v5 response |
78 |
| -fee = { |
79 |
| - overall_fee: 247700000000000n, |
80 |
| - gas_consumed: 2477n, |
81 |
| - gas_price: 100000000000n, |
82 |
| - suggestedMaxFee: 371550000000000n, |
83 |
| -}; |
84 |
| - |
85 |
| -// v6 response |
86 |
| -fee = { |
87 |
| - overall_fee: 247700000000000n, |
88 |
| - gas_consumed: 2477n, |
89 |
| - gas_price: 100000000000n, |
90 |
| - unit: undefined, |
91 |
| - suggestedMaxFee: 371550000000000n, |
92 |
| - resourceBounds: { |
93 |
| - l2_gas: { max_amount: '0x0', max_price_per_unit: '0x0' }, |
94 |
| - l1_gas: { max_amount: '0xaa4', max_price_per_unit: '0x22ecb25c00' }, |
95 |
| - }, |
96 |
| -}; |
97 |
| -``` |
98 |
| - |
99 |
| -You have to adapt your code to all these new entries. |
100 |
| -In general, pay attention to the result types of methods that return a response from an RPC node. |
101 |
| - |
102 |
| -<br/> |
103 |
| -<hr/> |
104 |
| - |
105 |
| -For the old v4 to v5 migration instructions check [here](./migrate_v4). |
| 26 | +## ... |
0 commit comments