suidouble 0.0.37 → 0.0.38
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/index.js +4 -0
- package/lib/SuiPackageModule.js +26 -21
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const SuiInBrowser = require('./lib/SuiInBrowser.js');
|
|
|
3
3
|
const SuiTestScenario = require('./lib/SuiTestScenario.js');
|
|
4
4
|
const SuiObject = require('./lib/SuiObject.js');
|
|
5
5
|
const SuiLocalTestValidator = require('./lib/SuiLocalTestValidator.js');
|
|
6
|
+
const sui = require('@mysten/sui.js');
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
SuiMaster,
|
|
@@ -11,4 +12,7 @@ module.exports = {
|
|
|
11
12
|
SuiTestScenario,
|
|
12
13
|
SuiLocalTestValidator,
|
|
13
14
|
MIST_PER_SUI: SuiMaster.MIST_PER_SUI,
|
|
15
|
+
|
|
16
|
+
TransactionBlock: sui.TransactionBlock,
|
|
17
|
+
Transactions: sui.Transactions,
|
|
14
18
|
};
|
package/lib/SuiPackageModule.js
CHANGED
|
@@ -115,29 +115,34 @@ class SuiPackageModule extends SuiCommonMethods {
|
|
|
115
115
|
async moveCall(methodName, params) {
|
|
116
116
|
await this._package.checkOnChainIfNeeded();
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
118
|
+
let tx = null;
|
|
119
|
+
if (params.tx) {
|
|
120
|
+
tx = params.tx;
|
|
121
|
+
} else {
|
|
122
|
+
tx = new sui.TransactionBlock();
|
|
123
|
+
|
|
124
|
+
const callArgs = [];
|
|
125
|
+
|
|
126
|
+
for (let param of params) {
|
|
127
|
+
if (param && param.type && param.amount && param.type === 'SUI') {
|
|
128
|
+
let amount = BigInt(param.amount);
|
|
129
|
+
const coin = tx.add(sui.Transactions.SplitCoins(tx.gas, [tx.pure(amount)]));
|
|
130
|
+
callArgs.push(coin);
|
|
131
|
+
} else if (param && Array.isArray(param) && param.length == 1 && param[0].type && param[0].amount && param[0].type === 'SUI') {
|
|
132
|
+
// vector<Coin<SUI>>
|
|
133
|
+
let amount = BigInt(param[0].amount);
|
|
134
|
+
const coin = tx.add(sui.Transactions.SplitCoins(tx.gas, [tx.pure(amount)]));
|
|
135
|
+
callArgs.push(tx.makeMoveVec({ objects: [coin]}));
|
|
136
|
+
} else {
|
|
137
|
+
callArgs.push(tx.pure(param));
|
|
138
|
+
}
|
|
134
139
|
}
|
|
140
|
+
|
|
141
|
+
tx.moveCall({
|
|
142
|
+
target: `${this._package.address}::${this._moduleName}::${methodName}`,
|
|
143
|
+
arguments: callArgs,
|
|
144
|
+
});
|
|
135
145
|
}
|
|
136
|
-
|
|
137
|
-
tx.moveCall({
|
|
138
|
-
target: `${this._package.address}::${this._moduleName}::${methodName}`,
|
|
139
|
-
arguments: callArgs,
|
|
140
|
-
});
|
|
141
146
|
|
|
142
147
|
const result = await this._suiMaster._signer.signAndExecuteTransactionBlock({
|
|
143
148
|
transactionBlock: tx,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
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": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "Jeka Kiselyov <jeka911@gmail.com> (https://github.com/jeka-kiselyov)",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@mysten/sui.js": "^0.
|
|
24
|
+
"@mysten/sui.js": "^0.39.0",
|
|
25
25
|
"@wallet-standard/core": "^1.0.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|