@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.
- package/Readme.md +33 -24
- 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
|

|
|
98
98
|
|
|
99
|
-
###
|
|
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 {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
113
|
-
|
|
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
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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 [
|
|
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
|
+
"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.
|
|
37
|
+
"@typemove/move": "1.2.0-rc.4"
|
|
38
38
|
},
|
|
39
39
|
"url": "https://github.com/sentioxyz/typemove",
|
|
40
40
|
"scripts": {
|