@0xobelisk/sui-client 0.5.16 → 0.5.18
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/dist/index.js +360 -205
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +350 -195
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -5
- package/src/index.ts +9 -8
- package/src/libs/multiSig/client.ts +2 -2
- package/src/libs/multiSig/publickey.ts +3 -3
- package/src/libs/suiAccountManager/index.ts +25 -6
- package/src/libs/suiAccountManager/keypair.ts +1 -1
- package/src/libs/suiAccountManager/util.ts +1 -1
- package/src/libs/suiContractFactory/index.ts +1 -1
- package/src/libs/suiContractFactory/types.ts +1 -1
- package/src/libs/suiInteractor/suiInteractor.ts +4 -4
- package/src/libs/suiModel/suiOwnedObject.ts +6 -4
- package/src/libs/suiModel/suiSharedObject.ts +5 -3
- package/src/libs/suiTxBuilder/index.ts +102 -84
- package/src/libs/suiTxBuilder/util.ts +113 -42
- package/src/metadata/index.ts +2 -3
- package/src/obelisk.ts +200 -91
- package/src/types/index.ts +46 -32
- package/dist/index.d.ts +0 -14
- package/dist/libs/multiSig/client.d.ts +0 -15
- package/dist/libs/multiSig/index.d.ts +0 -1
- package/dist/libs/multiSig/publickey.d.ts +0 -2
- package/dist/libs/suiAccountManager/crypto.d.ts +0 -1
- package/dist/libs/suiAccountManager/index.d.ts +0 -35
- package/dist/libs/suiAccountManager/keypair.d.ts +0 -21
- package/dist/libs/suiAccountManager/util.d.ts +0 -29
- package/dist/libs/suiContractFactory/index.d.ts +0 -20
- package/dist/libs/suiContractFactory/types.d.ts +0 -49
- package/dist/libs/suiInteractor/index.d.ts +0 -1
- package/dist/libs/suiInteractor/suiInteractor.d.ts +0 -50
- package/dist/libs/suiInteractor/util.d.ts +0 -1
- package/dist/libs/suiModel/index.d.ts +0 -2
- package/dist/libs/suiModel/suiOwnedObject.d.ts +0 -24
- package/dist/libs/suiModel/suiSharedObject.d.ts +0 -11
- package/dist/libs/suiTxBuilder/index.d.ts +0 -333
- package/dist/libs/suiTxBuilder/util.d.ts +0 -58
- package/dist/metadata/index.d.ts +0 -3
- package/dist/obelisk.d.ts +0 -136
- package/dist/types/index.d.ts +0 -152
- package/dist/utils/index.d.ts +0 -3
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { Ed25519Keypair } from '@mysten/sui
|
|
1
|
+
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
2
|
+
import {
|
|
3
|
+
SUI_PRIVATE_KEY_PREFIX,
|
|
4
|
+
decodeSuiPrivateKey,
|
|
5
|
+
} from '@mysten/sui/cryptography';
|
|
6
|
+
|
|
2
7
|
import { getKeyPair } from './keypair';
|
|
3
8
|
import { hexOrBase64ToUint8Array, normalizePrivateKey } from './util';
|
|
4
9
|
import { generateMnemonic } from './crypto';
|
|
5
|
-
import type { AccountMangerParams, DerivePathParams } from '
|
|
10
|
+
import type { AccountMangerParams, DerivePathParams } from 'src/types';
|
|
6
11
|
|
|
7
12
|
export class SuiAccountManager {
|
|
8
13
|
private mnemonics: string;
|
|
@@ -17,7 +22,7 @@ export class SuiAccountManager {
|
|
|
17
22
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
18
23
|
*
|
|
19
24
|
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
20
|
-
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
|
|
25
|
+
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored
|
|
21
26
|
*/
|
|
22
27
|
constructor({ mnemonics, secretKey }: AccountMangerParams = {}) {
|
|
23
28
|
// If the mnemonics or secretKey is provided, use it
|
|
@@ -30,13 +35,27 @@ export class SuiAccountManager {
|
|
|
30
35
|
|
|
31
36
|
// Init the current account
|
|
32
37
|
this.currentKeyPair = this.secretKey
|
|
33
|
-
?
|
|
34
|
-
normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey))
|
|
35
|
-
)
|
|
38
|
+
? this.parseSecretKey(this.secretKey)
|
|
36
39
|
: getKeyPair(this.mnemonics);
|
|
37
40
|
this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Check if the secretKey starts with bench32 format
|
|
45
|
+
*/
|
|
46
|
+
parseSecretKey(secretKey: string) {
|
|
47
|
+
if (secretKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {
|
|
48
|
+
const { secretKey: uint8ArraySecretKey } = decodeSuiPrivateKey(secretKey);
|
|
49
|
+
return Ed25519Keypair.fromSecretKey(
|
|
50
|
+
normalizePrivateKey(uint8ArraySecretKey)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return Ed25519Keypair.fromSecretKey(
|
|
55
|
+
normalizePrivateKey(hexOrBase64ToUint8Array(secretKey))
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
/**
|
|
41
60
|
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.
|
|
42
61
|
* else:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { SuiClient } from '@mysten/sui
|
|
1
|
+
import { SuiClient } from '@mysten/sui/client';
|
|
2
2
|
import type {
|
|
3
3
|
SuiTransactionBlockResponseOptions,
|
|
4
4
|
SuiTransactionBlockResponse,
|
|
5
5
|
SuiObjectDataOptions,
|
|
6
6
|
SuiObjectData,
|
|
7
|
-
} from '@mysten/sui
|
|
8
|
-
import type * as RpcTypes from '@mysten/sui
|
|
9
|
-
import { requestSuiFromFaucetV0, getFaucetHost } from '@mysten/sui
|
|
7
|
+
} from '@mysten/sui/client';
|
|
8
|
+
import type * as RpcTypes from '@mysten/sui/dist/cjs/client/types/generated';
|
|
9
|
+
import { requestSuiFromFaucetV0, getFaucetHost } from '@mysten/sui/faucet';
|
|
10
10
|
import { FaucetNetworkType, NetworkType, ObjectData } from '../../types';
|
|
11
11
|
import { SuiOwnedObject, SuiSharedObject } from '../suiModel';
|
|
12
12
|
import { delay } from './util';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SuiTransactionBlockResponse } from '@mysten/sui
|
|
2
|
-
import
|
|
1
|
+
import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
2
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
3
3
|
|
|
4
4
|
export class SuiOwnedObject {
|
|
5
5
|
public readonly objectId: string;
|
|
@@ -21,13 +21,15 @@ export class SuiOwnedObject {
|
|
|
21
21
|
return !!this.version && !!this.digest;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
asCallArg(): CallArg | string {
|
|
24
|
+
asCallArg(): typeof bcs.CallArg.$inferType | string {
|
|
25
25
|
if (!this.version || !this.digest) {
|
|
26
26
|
return this.objectId;
|
|
27
27
|
}
|
|
28
28
|
return {
|
|
29
|
+
$kind: 'Object',
|
|
29
30
|
Object: {
|
|
30
|
-
|
|
31
|
+
$kind: 'ImmOrOwnedObject',
|
|
32
|
+
ImmOrOwnedObject: {
|
|
31
33
|
objectId: this.objectId,
|
|
32
34
|
version: this.version,
|
|
33
35
|
digest: this.digest,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
2
2
|
|
|
3
3
|
export class SuiSharedObject {
|
|
4
4
|
public readonly objectId: string;
|
|
@@ -13,13 +13,15 @@ export class SuiSharedObject {
|
|
|
13
13
|
this.initialSharedVersion = param.initialSharedVersion;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
asCallArg(mutable: boolean = false): CallArg | string {
|
|
16
|
+
asCallArg(mutable: boolean = false): typeof bcs.CallArg.$inferType | string {
|
|
17
17
|
if (!this.initialSharedVersion) {
|
|
18
18
|
return this.objectId;
|
|
19
19
|
}
|
|
20
20
|
return {
|
|
21
|
+
$kind: 'Object',
|
|
21
22
|
Object: {
|
|
22
|
-
|
|
23
|
+
$kind: 'SharedObject',
|
|
24
|
+
SharedObject: {
|
|
23
25
|
objectId: this.objectId,
|
|
24
26
|
initialSharedVersion: this.initialSharedVersion,
|
|
25
27
|
mutable,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SUI_SYSTEM_STATE_OBJECT_ID } from '@mysten/sui
|
|
3
|
-
import {
|
|
4
|
-
import type { SuiClient, SuiObjectRef } from '@mysten/sui.js/client';
|
|
5
|
-
import type { TransactionObjectArgument } from '@mysten/sui.js/transactions';
|
|
1
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
+
import { SUI_SYSTEM_STATE_OBJECT_ID } from '@mysten/sui/utils';
|
|
3
|
+
import type { SuiClient, SuiObjectRef } from '@mysten/sui/client';
|
|
6
4
|
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from '@mysten/sui
|
|
10
|
-
import
|
|
5
|
+
TransactionObjectArgument,
|
|
6
|
+
TransactionObjectInput,
|
|
7
|
+
} from '@mysten/sui/transactions';
|
|
8
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
9
|
+
import type { Keypair } from '@mysten/sui/cryptography';
|
|
10
|
+
import { SerializedBcs } from '@mysten/bcs';
|
|
11
|
+
|
|
11
12
|
import type {
|
|
12
13
|
ObjectCallArg,
|
|
13
14
|
TransactionType,
|
|
@@ -16,67 +17,85 @@ import type {
|
|
|
16
17
|
SuiObjectArg,
|
|
17
18
|
SuiVecTxArg,
|
|
18
19
|
} from '../../types';
|
|
20
|
+
import {
|
|
21
|
+
convertArgs,
|
|
22
|
+
convertAddressArg,
|
|
23
|
+
convertObjArg,
|
|
24
|
+
getDefaultSuiInputType,
|
|
25
|
+
} from './util';
|
|
19
26
|
|
|
20
|
-
export class
|
|
21
|
-
public
|
|
27
|
+
export class SuiTx {
|
|
28
|
+
public tx: Transaction;
|
|
22
29
|
|
|
23
|
-
constructor(transaction?:
|
|
24
|
-
|
|
30
|
+
constructor(transaction?: Transaction) {
|
|
31
|
+
if (transaction !== undefined) {
|
|
32
|
+
this.tx = Transaction.from(transaction);
|
|
33
|
+
} else {
|
|
34
|
+
this.tx = new Transaction();
|
|
35
|
+
}
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
/* Directly wrap methods and properties of TransactionBlock */
|
|
28
39
|
get gas() {
|
|
29
|
-
return this.
|
|
40
|
+
return this.tx.gas;
|
|
30
41
|
}
|
|
31
42
|
get blockData() {
|
|
32
|
-
return this.
|
|
43
|
+
return this.tx.blockData;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
autoPure(value: string, type?: string) {
|
|
47
|
+
if (type === undefined) {
|
|
48
|
+
return convertArgs(this.tx, [value]);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return;
|
|
33
52
|
}
|
|
34
53
|
|
|
35
54
|
address(value: string) {
|
|
36
|
-
return this.
|
|
55
|
+
return this.tx.pure.address(value);
|
|
37
56
|
}
|
|
38
|
-
pure(value:
|
|
39
|
-
return this.
|
|
57
|
+
pure(value: SerializedBcs<any, any> | Uint8Array) {
|
|
58
|
+
return this.tx.pure(value);
|
|
40
59
|
}
|
|
41
|
-
object(value:
|
|
42
|
-
return this.
|
|
60
|
+
object(value: TransactionObjectInput) {
|
|
61
|
+
return this.tx.object(value);
|
|
43
62
|
}
|
|
44
63
|
objectRef(ref: SuiObjectRef) {
|
|
45
|
-
return this.
|
|
64
|
+
return this.tx.objectRef(ref);
|
|
46
65
|
}
|
|
47
|
-
sharedObjectRef(ref: SharedObjectRef) {
|
|
48
|
-
return this.
|
|
66
|
+
sharedObjectRef(ref: typeof bcs.SharedObjectRef.$inferType) {
|
|
67
|
+
return this.tx.sharedObjectRef(ref);
|
|
49
68
|
}
|
|
50
69
|
setSender(sender: string) {
|
|
51
|
-
return this.
|
|
70
|
+
return this.tx.setSender(sender);
|
|
52
71
|
}
|
|
53
72
|
setSenderIfNotSet(sender: string) {
|
|
54
|
-
return this.
|
|
73
|
+
return this.tx.setSenderIfNotSet(sender);
|
|
55
74
|
}
|
|
56
|
-
setExpiration(expiration?: TransactionExpiration) {
|
|
57
|
-
return this.
|
|
75
|
+
setExpiration(expiration?: typeof bcs.TransactionExpiration.$inferType) {
|
|
76
|
+
return this.tx.setExpiration(expiration);
|
|
58
77
|
}
|
|
59
78
|
setGasPrice(price: number | bigint) {
|
|
60
|
-
return this.
|
|
79
|
+
return this.tx.setGasPrice(price);
|
|
61
80
|
}
|
|
62
81
|
setGasBudget(budget: number | bigint) {
|
|
63
|
-
return this.
|
|
82
|
+
return this.tx.setGasBudget(budget);
|
|
64
83
|
}
|
|
65
84
|
setGasOwner(owner: string) {
|
|
66
|
-
return this.
|
|
85
|
+
return this.tx.setGasOwner(owner);
|
|
67
86
|
}
|
|
68
87
|
setGasPayment(payments: SuiObjectRef[]) {
|
|
69
|
-
return this.
|
|
88
|
+
return this.tx.setGasPayment(payments);
|
|
70
89
|
}
|
|
71
90
|
serialize() {
|
|
72
|
-
return this.
|
|
91
|
+
return this.tx.serialize();
|
|
73
92
|
}
|
|
74
93
|
sign(params: {
|
|
75
94
|
signer: Keypair;
|
|
76
95
|
client?: SuiClient;
|
|
77
96
|
onlyTransactionKind?: boolean;
|
|
78
97
|
}) {
|
|
79
|
-
return this.
|
|
98
|
+
return this.tx.sign(params);
|
|
80
99
|
}
|
|
81
100
|
build(
|
|
82
101
|
params: {
|
|
@@ -84,13 +103,13 @@ export class SuiTxBlock {
|
|
|
84
103
|
onlyTransactionKind?: boolean;
|
|
85
104
|
} = {}
|
|
86
105
|
) {
|
|
87
|
-
return this.
|
|
106
|
+
return this.tx.build(params);
|
|
88
107
|
}
|
|
89
108
|
getDigest(params: { client?: SuiClient } = {}) {
|
|
90
|
-
return this.
|
|
109
|
+
return this.tx.getDigest(params);
|
|
91
110
|
}
|
|
92
111
|
add(...args: TransactionType) {
|
|
93
|
-
return this.
|
|
112
|
+
return this.tx.add(...args);
|
|
94
113
|
}
|
|
95
114
|
publish({
|
|
96
115
|
modules,
|
|
@@ -99,54 +118,59 @@ export class SuiTxBlock {
|
|
|
99
118
|
modules: number[][] | string[];
|
|
100
119
|
dependencies: string[];
|
|
101
120
|
}) {
|
|
102
|
-
return this.
|
|
121
|
+
return this.tx.publish({ modules, dependencies });
|
|
103
122
|
}
|
|
104
123
|
upgrade({
|
|
105
124
|
modules,
|
|
106
125
|
dependencies,
|
|
107
|
-
packageId,
|
|
126
|
+
package: packageId,
|
|
108
127
|
ticket,
|
|
109
128
|
}: {
|
|
110
129
|
modules: number[][] | string[];
|
|
111
130
|
dependencies: string[];
|
|
112
|
-
|
|
131
|
+
package: string;
|
|
113
132
|
ticket: TransactionObjectArgument | string;
|
|
114
133
|
}) {
|
|
115
|
-
return this.
|
|
134
|
+
return this.tx.upgrade({
|
|
135
|
+
modules,
|
|
136
|
+
dependencies,
|
|
137
|
+
package: packageId,
|
|
138
|
+
ticket,
|
|
139
|
+
});
|
|
116
140
|
}
|
|
117
141
|
makeMoveVec({
|
|
118
|
-
|
|
142
|
+
elements,
|
|
119
143
|
type,
|
|
120
144
|
}: {
|
|
121
|
-
|
|
145
|
+
elements: (TransactionObjectArgument | string)[];
|
|
122
146
|
type?: string;
|
|
123
147
|
}) {
|
|
124
|
-
return this.
|
|
148
|
+
return this.tx.makeMoveVec({ elements, type });
|
|
125
149
|
}
|
|
126
150
|
|
|
127
151
|
/* Override methods of TransactionBlock */
|
|
128
152
|
|
|
129
153
|
transferObjects(objects: SuiObjectArg[], address: SuiAddressArg) {
|
|
130
|
-
return this.
|
|
131
|
-
objects.map((object) => convertObjArg(this.
|
|
132
|
-
convertAddressArg(this.
|
|
154
|
+
return this.tx.transferObjects(
|
|
155
|
+
objects.map((object) => convertObjArg(this.tx, object)),
|
|
156
|
+
convertAddressArg(this.tx, address)
|
|
133
157
|
);
|
|
134
158
|
}
|
|
135
159
|
|
|
136
160
|
splitCoins(coin: SuiObjectArg, amounts: SuiTxArg[]) {
|
|
137
|
-
const res = this.
|
|
138
|
-
convertObjArg(this.
|
|
139
|
-
convertArgs(this.
|
|
161
|
+
const res = this.tx.splitCoins(
|
|
162
|
+
convertObjArg(this.tx, coin),
|
|
163
|
+
convertArgs(this.tx, amounts)
|
|
140
164
|
);
|
|
141
165
|
return amounts.map((_, i) => res[i]);
|
|
142
166
|
}
|
|
143
167
|
|
|
144
168
|
mergeCoins(destination: SuiObjectArg, sources: SuiObjectArg[]) {
|
|
145
|
-
const destinationObject = convertObjArg(this.
|
|
169
|
+
const destinationObject = convertObjArg(this.tx, destination);
|
|
146
170
|
const sourceObjects = sources.map((source) =>
|
|
147
|
-
convertObjArg(this.
|
|
171
|
+
convertObjArg(this.tx, source)
|
|
148
172
|
);
|
|
149
|
-
return this.
|
|
173
|
+
return this.tx.mergeCoins(destinationObject, sourceObjects);
|
|
150
174
|
}
|
|
151
175
|
|
|
152
176
|
/**
|
|
@@ -168,8 +192,8 @@ export class SuiTxBlock {
|
|
|
168
192
|
throw new Error(
|
|
169
193
|
'Invalid target format. Expected `${string}::${string}::${string}`'
|
|
170
194
|
);
|
|
171
|
-
const convertedArgs = convertArgs(this.
|
|
172
|
-
return this.
|
|
195
|
+
const convertedArgs = convertArgs(this.tx, args);
|
|
196
|
+
return this.tx.moveCall({
|
|
173
197
|
target: target as `${string}::${string}::${string}`,
|
|
174
198
|
arguments: convertedArgs,
|
|
175
199
|
typeArguments: typeArgs,
|
|
@@ -185,15 +209,15 @@ export class SuiTxBlock {
|
|
|
185
209
|
'transferSuiToMany: recipients.length !== amounts.length'
|
|
186
210
|
);
|
|
187
211
|
}
|
|
188
|
-
const coins = this.
|
|
189
|
-
this.
|
|
190
|
-
convertArgs(this.
|
|
212
|
+
const coins = this.tx.splitCoins(
|
|
213
|
+
this.tx.gas,
|
|
214
|
+
convertArgs(this.tx, amounts)
|
|
191
215
|
);
|
|
192
216
|
const recipientObjects = recipients.map((recipient) =>
|
|
193
|
-
convertAddressArg(this.
|
|
217
|
+
convertAddressArg(this.tx, recipient)
|
|
194
218
|
);
|
|
195
219
|
recipientObjects.forEach((address, index) => {
|
|
196
|
-
this.
|
|
220
|
+
this.tx.transferObjects([coins[index]], address);
|
|
197
221
|
});
|
|
198
222
|
return this;
|
|
199
223
|
}
|
|
@@ -203,34 +227,31 @@ export class SuiTxBlock {
|
|
|
203
227
|
}
|
|
204
228
|
|
|
205
229
|
takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiTxArg) {
|
|
206
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
230
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
207
231
|
const mergedCoin = coinObjects[0];
|
|
208
232
|
if (coins.length > 1) {
|
|
209
|
-
this.
|
|
233
|
+
this.tx.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
210
234
|
}
|
|
211
|
-
const [sendCoin] = this.
|
|
235
|
+
const [sendCoin] = this.tx.splitCoins(
|
|
212
236
|
mergedCoin,
|
|
213
|
-
convertArgs(this.
|
|
237
|
+
convertArgs(this.tx, [amount])
|
|
214
238
|
);
|
|
215
239
|
return [sendCoin, mergedCoin];
|
|
216
240
|
}
|
|
217
241
|
|
|
218
242
|
splitSUIFromGas(amounts: SuiTxArg[]) {
|
|
219
|
-
return this.
|
|
220
|
-
this.txBlock.gas,
|
|
221
|
-
convertArgs(this.txBlock, amounts)
|
|
222
|
-
);
|
|
243
|
+
return this.tx.splitCoins(this.tx.gas, convertArgs(this.tx, amounts));
|
|
223
244
|
}
|
|
224
245
|
|
|
225
246
|
splitMultiCoins(coins: SuiObjectArg[], amounts: SuiTxArg[]) {
|
|
226
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
247
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
227
248
|
const mergedCoin = coinObjects[0];
|
|
228
249
|
if (coins.length > 1) {
|
|
229
|
-
this.
|
|
250
|
+
this.tx.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
230
251
|
}
|
|
231
|
-
const splitedCoins = this.
|
|
252
|
+
const splitedCoins = this.tx.splitCoins(
|
|
232
253
|
mergedCoin,
|
|
233
|
-
convertArgs(this.
|
|
254
|
+
convertArgs(this.tx, amounts)
|
|
234
255
|
);
|
|
235
256
|
return { splitedCoins, mergedCoin };
|
|
236
257
|
}
|
|
@@ -247,21 +268,18 @@ export class SuiTxBlock {
|
|
|
247
268
|
'transferSuiToMany: recipients.length !== amounts.length'
|
|
248
269
|
);
|
|
249
270
|
}
|
|
250
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.
|
|
271
|
+
const coinObjects = coins.map((coin) => convertObjArg(this.tx, coin));
|
|
251
272
|
const { splitedCoins, mergedCoin } = this.splitMultiCoins(
|
|
252
273
|
coinObjects,
|
|
253
274
|
amounts
|
|
254
275
|
);
|
|
255
276
|
const recipientObjects = recipients.map((recipient) =>
|
|
256
|
-
convertAddressArg(this.
|
|
277
|
+
convertAddressArg(this.tx, recipient)
|
|
257
278
|
);
|
|
258
279
|
recipientObjects.forEach((address, index) => {
|
|
259
|
-
this.
|
|
280
|
+
this.tx.transferObjects([splitedCoins[index]], address);
|
|
260
281
|
});
|
|
261
|
-
this.
|
|
262
|
-
[mergedCoin],
|
|
263
|
-
convertAddressArg(this.txBlock, sender)
|
|
264
|
-
);
|
|
282
|
+
this.tx.transferObjects([mergedCoin], convertAddressArg(this.tx, sender));
|
|
265
283
|
return this;
|
|
266
284
|
}
|
|
267
285
|
|
|
@@ -275,16 +293,16 @@ export class SuiTxBlock {
|
|
|
275
293
|
}
|
|
276
294
|
|
|
277
295
|
stakeSui(amount: SuiTxArg, validatorAddr: SuiAddressArg) {
|
|
278
|
-
const [stakeCoin] = this.
|
|
279
|
-
this.
|
|
280
|
-
convertArgs(this.
|
|
296
|
+
const [stakeCoin] = this.tx.splitCoins(
|
|
297
|
+
this.tx.gas,
|
|
298
|
+
convertArgs(this.tx, [amount])
|
|
281
299
|
);
|
|
282
|
-
return this.
|
|
300
|
+
return this.tx.moveCall({
|
|
283
301
|
target: '0x3::sui_system::request_add_stake',
|
|
284
|
-
arguments: convertArgs(this.
|
|
302
|
+
arguments: convertArgs(this.tx, [
|
|
285
303
|
SUI_SYSTEM_STATE_OBJECT_ID,
|
|
286
304
|
stakeCoin,
|
|
287
|
-
this.
|
|
305
|
+
this.tx.pure.address(validatorAddr.toString()),
|
|
288
306
|
]),
|
|
289
307
|
});
|
|
290
308
|
}
|