@typemove/sui 1.2.0-rc.3 → 1.2.0-rc.4

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 (2) hide show
  1. package/Readme.md +33 -24
  2. package/package.json +2 -2
package/Readme.md CHANGED
@@ -96,33 +96,42 @@ console.log(decodedObjects[0].value.info.delivery_info?.price)
96
96
  IDE could infer result type correctly.
97
97
  ![dynamic_fields.png](../../images/dynamic_fields.png)
98
98
 
99
- ### Building transaction
99
+ ### View Function
100
+ With type move, you could, call view functions and get decoded result very easily, e.g.
100
101
  ```typescript
101
- import { clob_v2 } from './types/0xdee9.js'
102
-
103
- clob_v2.builder.getMarketPrice(
104
- tx,
105
- ['0x5d2687b354f2ad4bce90c828974346d91ac1787ff170e5d09cb769e5dbcdefae'],
106
- [
107
- '0x2::sui::SUI',
108
- '0x219d80b1be5d586ff3bdbfeaf4d051ec721442c3a6498a3222773c6945a73d9f::usdt::USDT',
109
- ]
110
- )
102
+ import { _0x2 } from '@typemove/sui/builtin'
103
+
104
+ res = (await _0x2.math.view.min(client, [20n, 4n]))
105
+
106
+ console.log(res?.results_decoded[0])
107
+ ```
108
+
109
+ Typemove's generated view function stubs wraps the `devInspectTransactionBlock` API and decode the result,
110
+ it adds an fully typed `results_decoded` field to the result object. e.g. the above `min` function generated has type annotation as below:
111
111
 
112
- const result = await provider.devInspectTransactionBlock({
113
- transactionBlock: tx
114
- })
112
+ ```typescript
113
+ module math {
114
+ export async function min(
115
+ client: SuiClient,
116
+ args: [bigint | TransactionArgument, bigint | TransactionArgument],
117
+ ): Promise<TypedDevInspectResults<[bigint]>> {
118
+ ...
119
+ }
120
+ }
115
121
  ```
116
- If you just want to call `devInspectTransactionBlock` for single function, you can simply do
122
+
123
+ ### Building transaction
124
+ Similar to original transaction building process, but you could use generated builder function to replace the
125
+ `txb.moveCall`.
126
+
117
127
  ```typescript
118
- import { clob_v2 } from './types/0xdee9.js'
119
-
120
- await clob_v2.view.getMarketPrice(provider,
121
- ['0x5d2687b354f2ad4bce90c828974346d91ac1787ff170e5d09cb769e5dbcdefae'],
122
- [
123
- '0x2::sui::SUI',
124
- '0x219d80b1be5d586ff3bdbfeaf4d051ec721442c3a6498a3222773c6945a73d9f::usdt::USDT',
125
- ])
128
+ import { clob_v2 } from './types/testnet/0xdee9.js'
129
+
130
+ const client = new SuiClient({ url: getFullnodeUrl('testnet') })
131
+ const tx = new TransactionBlock()
132
+ clob_v2.builder.createAccount(tx, ["0xd9e6dc1e7f0790c18acf96b629f0a236d56de2f96537d921197bcb0e071b12bd"])
133
+ ... more tx build
134
+ client.signAndExecuteTransactionBlock({transactionBlock: tx, signer: keypair})
126
135
  ```
127
136
 
128
- Checkout our [example](./examples/sui) for full codes。
137
+ Checkout our [tests](./src/tests/move-call.test.ts) for more examples.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typemove/sui",
3
- "version": "1.2.0-rc.3",
3
+ "version": "1.2.0-rc.4",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -34,7 +34,7 @@
34
34
  "@mysten/sui.js": "^0.41.2",
35
35
  "chalk": "^5.3.0",
36
36
  "radash": "^11.0.0",
37
- "@typemove/move": "1.2.0-rc.3"
37
+ "@typemove/move": "1.2.0-rc.4"
38
38
  },
39
39
  "url": "https://github.com/sentioxyz/typemove",
40
40
  "scripts": {