@mysten/docs 0.1.1
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/README.md +24 -0
- package/dist/bcs/index.md +358 -0
- package/dist/bcs/llms-index.md +4 -0
- package/dist/codegen/index.md +441 -0
- package/dist/codegen/llms-index.md +4 -0
- package/dist/dapp-kit/actions/connect-wallet.md +69 -0
- package/dist/dapp-kit/actions/disconnect-wallet.md +38 -0
- package/dist/dapp-kit/actions/sign-and-execute-transaction.md +96 -0
- package/dist/dapp-kit/actions/sign-personal-message.md +58 -0
- package/dist/dapp-kit/actions/sign-transaction.md +65 -0
- package/dist/dapp-kit/actions/switch-account.md +37 -0
- package/dist/dapp-kit/actions/switch-network.md +37 -0
- package/dist/dapp-kit/dapp-kit-instance.md +162 -0
- package/dist/dapp-kit/getting-started/create-dapp.md +151 -0
- package/dist/dapp-kit/getting-started/next-js.md +162 -0
- package/dist/dapp-kit/getting-started/react.md +172 -0
- package/dist/dapp-kit/getting-started/vue.md +193 -0
- package/dist/dapp-kit/index.md +70 -0
- package/dist/dapp-kit/llms-index.md +26 -0
- package/dist/dapp-kit/react/components/connect-button.md +42 -0
- package/dist/dapp-kit/react/components/connect-modal.md +51 -0
- package/dist/dapp-kit/react/components/index.md +13 -0
- package/dist/dapp-kit/react/dapp-kit-provider.md +86 -0
- package/dist/dapp-kit/react/hooks/index.md +25 -0
- package/dist/dapp-kit/react/hooks/use-current-account.md +33 -0
- package/dist/dapp-kit/react/hooks/use-current-client.md +36 -0
- package/dist/dapp-kit/react/hooks/use-current-network.md +28 -0
- package/dist/dapp-kit/react/hooks/use-current-wallet.md +36 -0
- package/dist/dapp-kit/react/hooks/use-dapp-kit.md +100 -0
- package/dist/dapp-kit/react/hooks/use-wallet-connection.md +48 -0
- package/dist/dapp-kit/react/hooks/use-wallets.md +33 -0
- package/dist/dapp-kit/state.md +169 -0
- package/dist/dapp-kit/theming.md +196 -0
- package/dist/dapp-kit/web-components/connect-button.md +89 -0
- package/dist/dapp-kit/web-components/connect-modal.md +177 -0
- package/dist/kiosk/advanced-examples.md +101 -0
- package/dist/kiosk/from-v1.md +320 -0
- package/dist/kiosk/index.md +22 -0
- package/dist/kiosk/kiosk-client/introduction.md +52 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/examples.md +119 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/kiosk-transaction.md +103 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/managing.md +235 -0
- package/dist/kiosk/kiosk-client/kiosk-transaction/purchasing.md +110 -0
- package/dist/kiosk/kiosk-client/querying.md +237 -0
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/introduction.md +79 -0
- package/dist/kiosk/kiosk-client/transfer-policy-transaction/using-the-manager.md +115 -0
- package/dist/kiosk/llms-index.md +8 -0
- package/dist/llms-index.md +125 -0
- package/dist/payment-kit/getting-started.md +256 -0
- package/dist/payment-kit/index.md +132 -0
- package/dist/payment-kit/llms-index.md +8 -0
- package/dist/payment-kit/payment-kit-sdk.md +747 -0
- package/dist/payment-kit/payment-processing.md +372 -0
- package/dist/payment-kit/registry-management.md +529 -0
- package/dist/seal/index.md +85 -0
- package/dist/seal/llms-index.md +4 -0
- package/dist/slush-wallet/dapp.md +95 -0
- package/dist/slush-wallet/deep-linking.md +465 -0
- package/dist/slush-wallet/index.md +7 -0
- package/dist/slush-wallet/llms-index.md +6 -0
- package/dist/sui/bcs.md +134 -0
- package/dist/sui/clients/core.md +606 -0
- package/dist/sui/clients/graphql.md +101 -0
- package/dist/sui/clients/grpc.md +155 -0
- package/dist/sui/clients/index.md +95 -0
- package/dist/sui/clients/json-rpc.md +239 -0
- package/dist/sui/cryptography/keypairs.md +267 -0
- package/dist/sui/cryptography/multisig.md +194 -0
- package/dist/sui/cryptography/passkey.md +111 -0
- package/dist/sui/cryptography/webcrypto-signer.md +81 -0
- package/dist/sui/executors.md +148 -0
- package/dist/sui/faucet.md +26 -0
- package/dist/sui/hello-sui.md +115 -0
- package/dist/sui/index.md +53 -0
- package/dist/sui/install.md +61 -0
- package/dist/sui/llm-docs.md +32 -0
- package/dist/sui/llms-index.md +44 -0
- package/dist/sui/migrations/0.38.md +58 -0
- package/dist/sui/migrations/sui-1.0.md +455 -0
- package/dist/sui/migrations/sui-2.0/agent-prompt.md +42 -0
- package/dist/sui/migrations/sui-2.0/dapp-kit.md +350 -0
- package/dist/sui/migrations/sui-2.0/deepbook-v3.md +33 -0
- package/dist/sui/migrations/sui-2.0/index.md +158 -0
- package/dist/sui/migrations/sui-2.0/json-rpc-migration.md +386 -0
- package/dist/sui/migrations/sui-2.0/kiosk.md +120 -0
- package/dist/sui/migrations/sui-2.0/sdk-maintainers.md +90 -0
- package/dist/sui/migrations/sui-2.0/seal.md +14 -0
- package/dist/sui/migrations/sui-2.0/sui.md +341 -0
- package/dist/sui/migrations/sui-2.0/suins.md +43 -0
- package/dist/sui/migrations/sui-2.0/wallet-builders.md +66 -0
- package/dist/sui/migrations/sui-2.0/walrus.md +41 -0
- package/dist/sui/migrations/sui-2.0/zksend.md +95 -0
- package/dist/sui/plugins.md +258 -0
- package/dist/sui/sdk-building.md +344 -0
- package/dist/sui/transaction-building/basics.md +299 -0
- package/dist/sui/transaction-building/gas.md +62 -0
- package/dist/sui/transaction-building/intents.md +62 -0
- package/dist/sui/transaction-building/offline.md +73 -0
- package/dist/sui/transaction-building/sponsored-transactions.md +22 -0
- package/dist/sui/utils/derived_objects.md +59 -0
- package/dist/sui/utils/index.md +52 -0
- package/dist/sui/zklogin.md +83 -0
- package/dist/walrus/index.md +527 -0
- package/dist/walrus/llms-index.md +4 -0
- package/dist/zksend/index.md +27 -0
- package/dist/zksend/link-builder.md +192 -0
- package/dist/zksend/llms-index.md +5 -0
- package/package.json +66 -0
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# Migrate to 1.0
|
|
2
|
+
|
|
3
|
+
> Migrate to Sui TypeScript SDK 1.0
|
|
4
|
+
|
|
5
|
+
We are excited to announce the 1.0 release of the Typescript SDK. This release includes a lot of new
|
|
6
|
+
features, as well as number of renames, and cleanup of old APIs that no longer make sense.
|
|
7
|
+
|
|
8
|
+
This migration guide will primarily focus on helping migrate existing features that have changed in
|
|
9
|
+
this release, and won't cover all the new features that have been added, but here are some
|
|
10
|
+
highlights:
|
|
11
|
+
|
|
12
|
+
- [A new GraphQL Client for the newly released Sui GraphQL API](/sui/clients/graphql)
|
|
13
|
+
- [New Transaction Executor classes for efficient Transaction execution](../executors)
|
|
14
|
+
- [New Transaction Intents to simplify common transaction patterns](../transaction-building/intents)
|
|
15
|
+
- [A new Plugin system for Extending Transaction Building](../plugins)
|
|
16
|
+
|
|
17
|
+
The majority of changes in this release are in the `@mysten/sui` package, but the changes to API
|
|
18
|
+
require some breaking changes across all the Typescript SDKs. You can find migration guides for all
|
|
19
|
+
affected packages below:
|
|
20
|
+
|
|
21
|
+
## Changes to `@mysten/sui`
|
|
22
|
+
|
|
23
|
+
As part of the 1.0 release the `@mysten/sui.js` package has been renamed to `@mysten/sui`
|
|
24
|
+
|
|
25
|
+
To upgrade to the new version, uninstall the old package and install the new one:
|
|
26
|
+
|
|
27
|
+
```sh npm2yarn
|
|
28
|
+
npm uninstall @mysten/sui.js
|
|
29
|
+
npm install @mysten/sui
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then update all imports to use the new package name:
|
|
33
|
+
|
|
34
|
+
```diff
|
|
35
|
+
- import { SuiJsonRpcClient } from '@mysten/sui.js'
|
|
36
|
+
+ import { SuiJsonRpcClient } from '@mysten/sui'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### `@mysten/sui/transactions`
|
|
40
|
+
|
|
41
|
+
The largest changes in the 1.0 release are all centered around how Transactions are built and
|
|
42
|
+
executed. This includes are complete rewrite of the internal representation of transactions, as well
|
|
43
|
+
as as changes to the terminology used in the SDK and corresponding documentation.
|
|
44
|
+
|
|
45
|
+
The `TransactionBlock` class has been renamed to `Transaction`, and most methods and properties that
|
|
46
|
+
previously used `transactionBlock` have been updated to use `transaction` instead.
|
|
47
|
+
|
|
48
|
+
The distinction between TransactionBlocks and transactions has been a source of confusion for many
|
|
49
|
+
people. With this release we are hoping to disambiguate these terms, and similar changes will be
|
|
50
|
+
coming to other parts of the SUI ecosystem in the future.
|
|
51
|
+
|
|
52
|
+
A `Transaction` now refers to a Programable Transaction Block, which consists of 1 or more
|
|
53
|
+
`commands` (previously called transactions). A `Command` refers to a single step in Programable
|
|
54
|
+
Transaction Block.
|
|
55
|
+
|
|
56
|
+
### Transaction
|
|
57
|
+
|
|
58
|
+
The `TransactionBlock` class has been renamed to `Transaction`, along with many related APIs:
|
|
59
|
+
|
|
60
|
+
- `TransactionBlock` -> `Transaction`
|
|
61
|
+
- `isTransactionBlock` -> `isTransaction`
|
|
62
|
+
- `TransactionBlockInput` -> `TransactionInput`
|
|
63
|
+
- `signer.signTransactionBlock` -> `signer.signTransaction`
|
|
64
|
+
- `pubkey.verifyTransactionBlock` -> `pubkey.verifyTransaction`
|
|
65
|
+
- `suiClient.waitForTransactionBlock({ transactionBlock })` ->
|
|
66
|
+
`suiClient.waitForTransaction({ transaction })`
|
|
67
|
+
- `suiClient.signAndExecuteTransactionBlock({ transactionBlock })` ->
|
|
68
|
+
`suiClient.signAndExecuteTransaction({ transaction })`
|
|
69
|
+
|
|
70
|
+
There are a few methods on SuiJsonRpcClient that retain the `TransactionBlock` name because they
|
|
71
|
+
correspond to specific JSON RPC calls. The following methods are unchanged:
|
|
72
|
+
|
|
73
|
+
- `suiClient.getTransactionBlock`
|
|
74
|
+
- `suiClient.queryTransactionBlocks`
|
|
75
|
+
- `suiClient.executeTransactionBlock`
|
|
76
|
+
- `suiClient.dryRunTransactionBlock`
|
|
77
|
+
- `suiClient.devInspectTransactionBlock`
|
|
78
|
+
|
|
79
|
+
### Building Transactions
|
|
80
|
+
|
|
81
|
+
With the introduction of the Transaction plugin API, and Transaction Intents, serializing
|
|
82
|
+
transactions is now an asynchronous process.
|
|
83
|
+
|
|
84
|
+
`transaction.serialize()` has been deprecated in favor of `transaction.toJSON()`. The `toJSON`
|
|
85
|
+
method will invoke any serialization plugins used by the transaction, and return JSON in a new
|
|
86
|
+
Transaction JSON Format.
|
|
87
|
+
|
|
88
|
+
We have also removed the protocol config and limits options since enforcing these limits in the
|
|
89
|
+
Transaction builder adds little practical value, and required additional API calls every time a
|
|
90
|
+
transaction was build.
|
|
91
|
+
|
|
92
|
+
#### Cloning a Transaction
|
|
93
|
+
|
|
94
|
+
Cloning a transaction can now be done the `transaction.from` rather than the TransactionBlock
|
|
95
|
+
constructor:
|
|
96
|
+
|
|
97
|
+
```diff
|
|
98
|
+
- const newTransaction = new TransactionBlock(oldTransaction)
|
|
99
|
+
+ const newTransaction = Transaction.from(oldTransaction)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### `transaction.blockData` -> `transaction.getData()`
|
|
103
|
+
|
|
104
|
+
The `blockData` property has been deprecated and will be removed in a future release. A new
|
|
105
|
+
`txb.getData()` method has been added, and returns the new internal representation of a
|
|
106
|
+
TransactionBlock. The `blockData` property will continue to return the old representation to allow a
|
|
107
|
+
more gradual migration, but will be removed in a future minor release.
|
|
108
|
+
|
|
109
|
+
#### `transaction.pure`
|
|
110
|
+
|
|
111
|
+
The previously deprecated uses of `txb.pure` have now been removed. `transaction.pure()` used to
|
|
112
|
+
accept raw values at would attempt to infer the correct BCS encoding based on usage. This behavior
|
|
113
|
+
was the source of a lot of bugs and confusion. transaction.pure() now accepts serialized bcs values,
|
|
114
|
+
and includes a number of helper method for the most common cases.
|
|
115
|
+
|
|
116
|
+
The latest release of the BCS library has also removed its type registry, so the `transaction.pure`
|
|
117
|
+
can no longer be called with a bcs type-name. All pure values must now either be serialized using
|
|
118
|
+
the bcs library, or use one of the provided helper methods.
|
|
119
|
+
|
|
120
|
+
```diff
|
|
121
|
+
- txb.pure('0x123')
|
|
122
|
+
+ txb.pure.address('0x123')
|
|
123
|
+
+ txb.pure(bcs.Address.serialize('0x123'))
|
|
124
|
+
- txb.pure(123)
|
|
125
|
+
+ txb.pure.u64(123n)
|
|
126
|
+
+ txb.pure(bcs.U64.serialize(123n))
|
|
127
|
+
- txb.pure(123, 'u64')
|
|
128
|
+
+ txb.pure.u64(123n)
|
|
129
|
+
- txb.pure(['0x123'], 'vector<address>')
|
|
130
|
+
+ txb.pure(bcs.vector(bcs.Address).serialize(['0x123']))
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Commands
|
|
134
|
+
|
|
135
|
+
The `Transactions` export has been renamed to `Commands` and some of the options have been renamed:
|
|
136
|
+
|
|
137
|
+
```diff
|
|
138
|
+
- import { Transactions } from '@mysten/sui/transactions'
|
|
139
|
+
+ import { Commands } from '@mysten/sui/transactions'
|
|
140
|
+
|
|
141
|
+
tx.makeMoveVec({
|
|
142
|
+
type: '0x123::foo:Bar'
|
|
143
|
+
- objects: [tx.object(objectId)],
|
|
144
|
+
+ elements: [tx.object(objectId)]
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
tx.upgrade({
|
|
148
|
+
modules,
|
|
149
|
+
dependencies,
|
|
150
|
+
packageId: EXAMPLE_PACKAGE_ID,
|
|
151
|
+
ticket: tx.object(ticketId),
|
|
152
|
+
- packageId: '0x123',
|
|
153
|
+
+ package: '0x123'
|
|
154
|
+
})
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Transaction types
|
|
158
|
+
|
|
159
|
+
The shapes of the following types have change. We expect that for most use-cases, this will not
|
|
160
|
+
require any migration because these types represent values created by other parts of the SDK that
|
|
161
|
+
have been updated to return the new format
|
|
162
|
+
|
|
163
|
+
- [`TransactionObjectArgument`](/typedoc/types/_mysten_sui.transactions.TransactionObjectArgument.html)
|
|
164
|
+
shape changed
|
|
165
|
+
- [`TransactionResult`](/typedoc/types/_mysten_sui.transactions.TransactionResult.html) shape
|
|
166
|
+
changed
|
|
167
|
+
- [`TransactionObjectInput`](/typedoc/types/_mysten_sui.transactions.TransactionObjectInput.html)
|
|
168
|
+
shape changed
|
|
169
|
+
- [`TransactionArgument`](/typedoc/types/_mysten_sui.transactions.TransactionArgument.html) shape
|
|
170
|
+
changed
|
|
171
|
+
- [`TransactionBlockInput`](/typedoc/types/_mysten_sui.transactions.TransactionBlockInput.html)
|
|
172
|
+
shape changed
|
|
173
|
+
|
|
174
|
+
### `getPureSerializationType`
|
|
175
|
+
|
|
176
|
+
The `getPureSerializationType` utility function has been removed.
|
|
177
|
+
|
|
178
|
+
## `@mysten/sui/bcs`
|
|
179
|
+
|
|
180
|
+
### Bcs Types
|
|
181
|
+
|
|
182
|
+
Many of the BCS type definitions exported from the Typescript SDK have been updated to more closely
|
|
183
|
+
align with the Rust definitions. If you were using these types to parse transactions from BCS, you
|
|
184
|
+
may find that some of the data structures have been updated.
|
|
185
|
+
|
|
186
|
+
We have also removed some redundant exports that mirror the exported BCS types. These types often
|
|
187
|
+
conflicted with other types in the Typescript SDK, leading to confusion about which version to use.
|
|
188
|
+
|
|
189
|
+
The correct way to get Typescript types for the exported BCS types is to use the $inferType type
|
|
190
|
+
helper:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
|
|
194
|
+
function callArg(arg: typeof bcs.CallArg.$inferType) {
|
|
195
|
+
// ...
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## /utils
|
|
200
|
+
|
|
201
|
+
The typescript SDK no longer uses `superstruct` for type validation, so the `is` and `assert`
|
|
202
|
+
helpers have been removed.
|
|
203
|
+
|
|
204
|
+
## /multisig
|
|
205
|
+
|
|
206
|
+
The `publicKeyFromSuiBytes` has been moved to `@mysten/sui/verify`
|
|
207
|
+
|
|
208
|
+
```diff
|
|
209
|
+
- import { publicKeyFromSuiBytes } from '@mysten/sui/multisig'
|
|
210
|
+
+ import { publicKeyFromSuiBytes } from '@mysten/sui/verify'
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## /verify
|
|
214
|
+
|
|
215
|
+
The methods for verifying signatures have been renamed
|
|
216
|
+
|
|
217
|
+
```diff
|
|
218
|
+
- import {
|
|
219
|
+
- verifyTransactionBlock
|
|
220
|
+
- verifyPersonalMessage
|
|
221
|
+
- } from '@mysten/sui/verify'
|
|
222
|
+
+ import {
|
|
223
|
+
+ verifyTransactionSignature
|
|
224
|
+
+ verifyPersonalMessageSignature
|
|
225
|
+
+ } from '@mysten/sui/verify'
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## /cryptography
|
|
229
|
+
|
|
230
|
+
The `signData` method has been removed from Signers and Keypair classes. Use `sign` instead.
|
|
231
|
+
|
|
232
|
+
```diff
|
|
233
|
+
- keypair.signData(data)
|
|
234
|
+
+ await keypair.sign(data)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
For some keypair implementations, the `signPersonalMessage` method incorrectly returned a BCS
|
|
238
|
+
encoded version of the signed message. All `signPersonalMessage` implementations now correctly
|
|
239
|
+
return the unwrapped bytes of the message that was signed
|
|
240
|
+
|
|
241
|
+
# @mysten/bcs
|
|
242
|
+
|
|
243
|
+
## The Registry
|
|
244
|
+
|
|
245
|
+
We have removed the previously deprecated registry from the BCS library. The registry was removed
|
|
246
|
+
from the documentation when BCS was re-written last year, and is now being removed entirely.
|
|
247
|
+
|
|
248
|
+
The registry was dependent on side-effects to register type definitions, and had no way to enforce
|
|
249
|
+
type-safety. The new BCS API works much better in bundlers, and provides great type-safety when
|
|
250
|
+
parsing a serializing BCS data.
|
|
251
|
+
|
|
252
|
+
## Size limits
|
|
253
|
+
|
|
254
|
+
Previously the `size` option was used both as an initial size and a maximum size when creating a bcs
|
|
255
|
+
writer instance. We replaced the `size` option with a new `initialSize` option, and have updated
|
|
256
|
+
`maxSize` to default to Infinity rather than defaulting to `size`.
|
|
257
|
+
|
|
258
|
+
## new methods on BcsType
|
|
259
|
+
|
|
260
|
+
We have added `fromBase64`, `fromBase58`, and `fromHex` methods to `BcsType` instances, making it
|
|
261
|
+
easier to parse BCS data from various string encodings.
|
|
262
|
+
|
|
263
|
+
## Generics
|
|
264
|
+
|
|
265
|
+
We previously deprecated the `generic` helper exported from `@mysten/bcs`. This helper has now been
|
|
266
|
+
entirely removed.
|
|
267
|
+
|
|
268
|
+
## Enums
|
|
269
|
+
|
|
270
|
+
We have updated the typescript types associated with BCS enum types to simplify working with parsed
|
|
271
|
+
enums in typescript. Parsed enums now have a `$kind` property that can be used to discriminate
|
|
272
|
+
between enum variants. Checking properties of the enum type now works without using the `in`
|
|
273
|
+
operator:
|
|
274
|
+
|
|
275
|
+
```ts
|
|
276
|
+
const MyEnum = bcs.enum('MyEnum', {
|
|
277
|
+
Variant0: bcs.u16(),
|
|
278
|
+
Variant1: bcs.u8(),
|
|
279
|
+
Variant2: bcs.string(),
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
const parsed = MyEnum.deserialize(data);
|
|
283
|
+
|
|
284
|
+
// Discriminate using the $kind property
|
|
285
|
+
if (parsed.$kind === 'Variant0') {
|
|
286
|
+
parsed.Variant0; // type is number
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// We can also directly the enum properties
|
|
290
|
+
if (parsed.Variant0 !== undefined) {
|
|
291
|
+
parsed.Variant0; // type is number
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
# @mysten/kiosk
|
|
296
|
+
|
|
297
|
+
The options passed to `KioskTransaction` and `TransferPolicyTransaction` have been updated to
|
|
298
|
+
replace `transactionBlock` with `transaction`.
|
|
299
|
+
|
|
300
|
+
```diff
|
|
301
|
+
- const kioskTransaction = new KioskTransaction({ transactionBlock, ...otherOptions })
|
|
302
|
+
+ const kioskTransaction = new KioskTransaction({ transaction, ...otherOptions })
|
|
303
|
+
|
|
304
|
+
- const transferPolicyTransaction = new TransferPolicyTransaction({ transactionBlock, ...otherOptions })
|
|
305
|
+
+ const transferPolicyTransaction = new TransferPolicyTransaction({ transaction, ...otherOptions })
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
The options passed to `resolveRuleFunction` have also been updated to pass the `transaction` rather
|
|
309
|
+
than the `transactionBlock`.
|
|
310
|
+
|
|
311
|
+
```diff
|
|
312
|
+
- resolveRuleFunction({ transactionBlock }) => { ... }
|
|
313
|
+
+ resolveRuleFunction({ transaction }) => { ... }
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
# @mysten/enoki
|
|
317
|
+
|
|
318
|
+
The Enoki SDK has been updated to replace TransactionBlock terminology with Transaction throughout
|
|
319
|
+
the API:
|
|
320
|
+
|
|
321
|
+
```diff
|
|
322
|
+
- enokiFlow.sponsorAndExecuteTransactionBlock({ transactionBlock })
|
|
323
|
+
+ enokiFlow.sponsorAndExecuteTransaction({ transaction })
|
|
324
|
+
|
|
325
|
+
- enokiFlow.sponsorTransactionBlock({ transactionBlock })
|
|
326
|
+
+ enokiFlow.sponsorTransaction({ transaction })
|
|
327
|
+
|
|
328
|
+
- enokiFlow.executeTransactionBlock({ ... })
|
|
329
|
+
+ enokiFlow.executeTransaction({ ... })
|
|
330
|
+
|
|
331
|
+
- enokiClient.createSponsoredTransactionBlock({ transactionBlockKindBytes })
|
|
332
|
+
+ enokiClient.createSponsoredTransaction({ transactionKindBytes })
|
|
333
|
+
|
|
334
|
+
- enokiClient.executeSponsoredTransactionBlock({ ... })
|
|
335
|
+
+ enokiClient.executeSponsoredTransaction({ ... })
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
# dapp-kit
|
|
339
|
+
|
|
340
|
+
## `useSignTransactionBlock`
|
|
341
|
+
|
|
342
|
+
The `useSignTransactionBlock` has been named to `useSignTransaction` and now returns bytes instead
|
|
343
|
+
of transactionBlockBytes
|
|
344
|
+
|
|
345
|
+
```diff
|
|
346
|
+
- const { mutate: signTransactionBlock } = useSignTransactionBlock()
|
|
347
|
+
+ const { mutate: signTransaction } = useSignTransaction()
|
|
348
|
+
...
|
|
349
|
+
- const { signature, transactionBlockBytes } = await signTransactionBlock({ transactionBlock })
|
|
350
|
+
+ const { signature, bytes } = await signTransaction({ transaction })
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## `useSignAndExecuteTransactionBlock`
|
|
354
|
+
|
|
355
|
+
The `useSignAndExecuteTransactionBlock` has been named to `useSignAndExecuteTransaction` and
|
|
356
|
+
redesigned to work the updated wallet-standard methods.
|
|
357
|
+
|
|
358
|
+
`useSignAndExecuteTransaction` no-longer accepts the options passed to
|
|
359
|
+
`suiClient.executeTransactionBlock` for returning additional data.
|
|
360
|
+
|
|
361
|
+
By default useSignAndExecuteTransactionBlock will now return an object with the transaction `digest`
|
|
362
|
+
and the bcs encoded transaction effects:
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
const { mutate: signAndExecuteTransaction } = useSignAndExecuteTransaction()
|
|
366
|
+
...
|
|
367
|
+
const { digest, effects } = await signAndExecuteTransaction({ transaction })
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
To fetch additional data, you can provide a customized `execute` function:
|
|
371
|
+
|
|
372
|
+
```diff
|
|
373
|
+
- const { mutate: signAndExecuteTransactionBlock } = useSignAndExecuteTransactionBlock()
|
|
374
|
+
- const { digest, objectChanges } = await signAndExecuteTransactionBlock({
|
|
375
|
+
- transactionBlock: transaction,
|
|
376
|
+
- options: {
|
|
377
|
+
- showObjectChanges: true,
|
|
378
|
+
- },
|
|
379
|
+
- })
|
|
380
|
+
|
|
381
|
+
+ const { mutate: signAndExecuteTransactionBlock } = useSignAndExecuteTransactionBlock({
|
|
382
|
+
+ execute: async ({ bytes, signature }) =>
|
|
383
|
+
+ await suiClient.executeTransactionBlock({
|
|
384
|
+
+ transactionBlock: bytes,
|
|
385
|
+
+ signature,
|
|
386
|
+
+ options: {
|
|
387
|
+
+ // Raw effects are required so the effects can be reported back to the wallet
|
|
388
|
+
+ showRawEffects: true,
|
|
389
|
+
+ // Select additional data to return
|
|
390
|
+
+ showObjectChanges: true,
|
|
391
|
+
+ },
|
|
392
|
+
+ }),
|
|
393
|
+
+ });
|
|
394
|
+
|
|
395
|
+
+ const { digest, objectChanges } = await signAndExecuteTransaction({
|
|
396
|
+
+ transaction,
|
|
397
|
+
+ });
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
When using a custom `execute` function, the you must return the rawEffects by setting
|
|
401
|
+
`showRawEffects` to true if using `suiClient.executeTransactionBlock`, or by returning an object
|
|
402
|
+
matching `{ effects: { bcs: string` } }` with the base64 encoded bcs effects when using a GraphQL
|
|
403
|
+
query to execute the transaction.
|
|
404
|
+
|
|
405
|
+
This change decouples the `useSignAndExecuteTransaction` hook from a specific RPC API
|
|
406
|
+
implementation, and will enable migration to GraphQL without additional breaking changes in this
|
|
407
|
+
hook.
|
|
408
|
+
|
|
409
|
+
# @mysten/zksend
|
|
410
|
+
|
|
411
|
+
The `getSentTransactionBlocksWithLinks` method has been renamed to `getSentTransactionsWithLinks`,
|
|
412
|
+
and all methods that previously accepted a `transactionBlock` option now accept a `transaction`
|
|
413
|
+
instead instead.
|
|
414
|
+
|
|
415
|
+
```diff
|
|
416
|
+
- import { getSentTransactionBlocksWithLinks, ZkSendLinkBuilder } from '@mysten/zksend'
|
|
417
|
+
+ import { getSentTransactionsWithLinks, ZkSendLinkBuilder } from '@mysten/zksend'
|
|
418
|
+
|
|
419
|
+
const tx = new Transaction();
|
|
420
|
+
const link = new ZkSendLinkBuilder({
|
|
421
|
+
sender: '0x...',
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
link.createSendTransaction({
|
|
425
|
+
- transactionBlock: tx,
|
|
426
|
+
+ transaction: tx,
|
|
427
|
+
});
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
# @mysten/wallet-standard
|
|
431
|
+
|
|
432
|
+
### New wallet-standard features
|
|
433
|
+
|
|
434
|
+
We have added 3 new features to the wallet standard designed to allow efficient execution of
|
|
435
|
+
Transactions in wallets without waiting for previous transactions to be indexed in the wallets RPC
|
|
436
|
+
API.
|
|
437
|
+
|
|
438
|
+
For more details on how wallets can take advantage of these features, see the
|
|
439
|
+
[wallet-standard documentation](https://docs.sui.io/standards/wallet-standard).
|
|
440
|
+
|
|
441
|
+
The old `sui:signTransactionBlock` and `sui:signAndExecuteTransactionBlock` methods have been
|
|
442
|
+
deprecated in favor of the new `sui:signTransaction` and `sui:signAndExecuteTransaction` methods,
|
|
443
|
+
but wallets should continue to implement these deprecated methods until the new methods have been
|
|
444
|
+
broadly adopted by dapps.
|
|
445
|
+
|
|
446
|
+
### helpers
|
|
447
|
+
|
|
448
|
+
2 new helpers have been added to make it easier for dapps to handle wallets that have implemented
|
|
449
|
+
either the new or old wallet-standard methods: `signTransaction` and `signAndExecuteTransaction`.
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
|
|
453
|
+
const { signature, bytes } = await signTransaction(wallet, { transaction });
|
|
454
|
+
const { digest, effects } = await signAndExecuteTransaction(wallet, { transaction });
|
|
455
|
+
```
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Agent Migration Prompt
|
|
2
|
+
|
|
3
|
+
> AI agent prompt for automated SDK 2.0 migration
|
|
4
|
+
|
|
5
|
+
Copy and paste the following prompt into your AI coding assistant (Claude Code, Cursor, etc.) to
|
|
6
|
+
migrate your codebase to v2. If a planning mode is available we recommend starting there first.
|
|
7
|
+
|
|
8
|
+
```txt
|
|
9
|
+
## Sui TypeScript SDK v2 Migration
|
|
10
|
+
|
|
11
|
+
Migrate this codebase to the latest version of `@mysten/*` packages.
|
|
12
|
+
|
|
13
|
+
### Step 1: Identify Project Tools
|
|
14
|
+
|
|
15
|
+
Examine the project to identify:
|
|
16
|
+
- Package manager (npm, pnpm, yarn, bun) - check for lock files
|
|
17
|
+
- Build tools and scripts in package.json
|
|
18
|
+
- Type checking, linting, and test commands
|
|
19
|
+
|
|
20
|
+
### Step 2: Read the Migration Guide
|
|
21
|
+
|
|
22
|
+
Fetch and read the full migration guide from:
|
|
23
|
+
https://sdk.mystenlabs.com/sui/migrations/sui-2.0/llms.txt
|
|
24
|
+
|
|
25
|
+
This file contains the migration instructions for most affected @mysten package, but please be sure to install the
|
|
26
|
+
latest version of all @mysten packages even if they do not have an explicit migration guide
|
|
27
|
+
|
|
28
|
+
### Step 3: Migrate
|
|
29
|
+
|
|
30
|
+
Apply the migration patterns from the guide. Do not make changes without first reading the relevant section of the migration guide.
|
|
31
|
+
|
|
32
|
+
### Step 4: Validate
|
|
33
|
+
|
|
34
|
+
Run all validation scripts to verify the migration including:
|
|
35
|
+
|
|
36
|
+
* Type check
|
|
37
|
+
* Lint
|
|
38
|
+
* Build
|
|
39
|
+
* Test
|
|
40
|
+
|
|
41
|
+
Fix all errors before considering the migration complete.
|
|
42
|
+
```
|