suidouble 0.0.13 → 0.0.14
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 +4 -2
- package/lib/SuiPackageModule.js +2 -2
- package/package.json +1 -1
- package/test/sui_master_onlocal.test.js +1 -1
package/README.md
CHANGED
|
@@ -155,10 +155,12 @@ const res = await contract.moveCall('chat', 'post', ['0x10cded4f9df05e37b44e3be2
|
|
|
155
155
|
}
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
-
If you need to transfer some SUI as part of executing contract method, you can use a magic parameter in form of '
|
|
158
|
+
If you need to transfer some SUI as part of executing contract method, you can use a magic parameter in form of {type: 'SUI', amount: 400000000000n} where 400000000000 is the amount of MIST you want to send. SuiPackageModule will convert this amount to Coin object using Transactions.SplitCoins method.
|
|
159
|
+
|
|
160
|
+
`amount: 400000000000n`, `amount: '400000000000'`, `amount: 400000000000` will work too
|
|
159
161
|
|
|
160
162
|
```javascript
|
|
161
|
-
const moveCallResult = await contract.moveCall('suidouble_chat', 'post_pay', [chatShopObjectId, '
|
|
163
|
+
const moveCallResult = await contract.moveCall('suidouble_chat', 'post_pay', [chatShopObjectId, {type: 'SUI', amount: 400000000000n}, messageText, 'metadata']);
|
|
162
164
|
```
|
|
163
165
|
|
|
164
166
|
@todo: sending other Coins
|
package/lib/SuiPackageModule.js
CHANGED
|
@@ -79,8 +79,8 @@ class SuiPackageModule extends SuiCommonMethods {
|
|
|
79
79
|
|
|
80
80
|
const callArgs = [];
|
|
81
81
|
for (let param of params) {
|
|
82
|
-
if (param.
|
|
83
|
-
let amount = BigInt(param.
|
|
82
|
+
if (param && param.type && param.amount && param.type === 'SUI') {
|
|
83
|
+
let amount = BigInt(param.amount);
|
|
84
84
|
const coin = tx.add(sui.Transactions.SplitCoins(tx.gas, [tx.pure(amount)]));
|
|
85
85
|
callArgs.push(coin);
|
|
86
86
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Set of provider, package and object classes for javascript representation of Sui Move smart contracts. Use same code for publishing, upgrading, integration testing, interaction with smart contracts and integration in browser web3 dapps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -255,7 +255,7 @@ test('testing move call with coins', async t => {
|
|
|
255
255
|
t.rejects(contract.moveCall('suidouble_chat', 'post', [chatShopObjectId, longMessageYouCanNotPostForFree, 'metadata']));
|
|
256
256
|
|
|
257
257
|
// but can post with with post_pay function sending some sui to it
|
|
258
|
-
const moveCallResult = await contract.moveCall('suidouble_chat', 'post_pay', [chatShopObjectId, '
|
|
258
|
+
const moveCallResult = await contract.moveCall('suidouble_chat', 'post_pay', [chatShopObjectId, {type: 'SUI', amount: 400000000000n}, longMessageYouCanNotPostForFree, 'metadata']);
|
|
259
259
|
|
|
260
260
|
// there're at least some object created
|
|
261
261
|
t.ok(moveCallResult.created.length > 0);
|