@msafe/sui3-sdk 0.0.63 → 0.0.65
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.cjs +100 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -31
- package/dist/index.d.ts +31 -31
- package/dist/index.js +62 -63
- package/dist/index.js.map +1 -1
- package/package.json +10 -13
- package/src/backend/BackendImpl.ts +2 -2
- package/src/backend/interface.ts +2 -2
- package/src/core/AddressBookSDK.ts +1 -1
- package/src/core/CreateHelper.ts +3 -3
- package/src/core/InvitationSDK.ts +1 -1
- package/src/core/MSafeAccount.ts +25 -26
- package/src/core/MSafeClient.ts +1 -1
- package/src/core/PublicKeyHelper.ts +6 -6
- package/src/core/ReportSDK.ts +1 -1
- package/src/globals/MSafeGlobals.ts +6 -6
- package/src/globals/const.ts +9 -9
- package/src/simulate/simulator.ts +6 -6
- package/src/types/assets.ts +1 -1
- package/src/types/msafe.ts +4 -4
- package/src/types/wallet.ts +7 -7
- package/src/utils/coin.ts +5 -5
- package/src/utils/crypto.ts +3 -3
- package/src/utils/format.ts +4 -4
- package/src/utils/iter/object.ts +28 -28
- package/src/utils/sui.ts +10 -10
package/src/utils/sui.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { PublicKeySerde } from '@msafe/
|
|
2
|
-
import {
|
|
3
|
-
import { parseSerializedSignature, PublicKey, SerializedSignature } from '@
|
|
4
|
-
import { MultiSigPublicKey } from '@
|
|
1
|
+
import { PublicKeySerde } from '@msafe/iota-utils';
|
|
2
|
+
import { IotaClient, PaginatedTransactionResponse, PaginatedCoins, CoinStruct } from '@iota/iota-sdk/client';
|
|
3
|
+
import { parseSerializedSignature, PublicKey, SerializedSignature } from '@iota/iota-sdk/cryptography';
|
|
4
|
+
import { MultiSigPublicKey } from '@iota/iota-sdk/multisig';
|
|
5
5
|
|
|
6
6
|
import { Formatter } from '@/utils/format';
|
|
7
7
|
|
|
8
8
|
export const SUI_COIN = '0x2::sui::SUI';
|
|
9
9
|
|
|
10
|
-
export async function getPublicKeyFromChain(
|
|
10
|
+
export async function getPublicKeyFromChain(client: IotaClient, address: string): Promise<PublicKey | undefined> {
|
|
11
11
|
let txs: PaginatedTransactionResponse;
|
|
12
12
|
try {
|
|
13
|
-
txs = await
|
|
13
|
+
txs = await client.queryTransactionBlocks({
|
|
14
14
|
// Disable naming rule since the variable is defined by Mysten
|
|
15
15
|
filter: { FromAddress: address },
|
|
16
16
|
options: { showInput: true },
|
|
@@ -44,7 +44,7 @@ function getAddressFromSignatures(serializedSig: SerializedSignature, targetAddr
|
|
|
44
44
|
const decoded = parseSerializedSignature(serializedSig);
|
|
45
45
|
switch (decoded.signatureScheme) {
|
|
46
46
|
case 'MultiSig': {
|
|
47
|
-
const multiSigAddress = new MultiSigPublicKey(decoded.multisig.multisig_pk).
|
|
47
|
+
const multiSigAddress = new MultiSigPublicKey(decoded.multisig.multisig_pk).toIotaAddress();
|
|
48
48
|
if (Formatter.isSuiAddressEqual(multiSigAddress, targetAddress)) {
|
|
49
49
|
throw new Error('multi-sig wallet cannot be owner');
|
|
50
50
|
}
|
|
@@ -61,7 +61,7 @@ function getAddressFromSignatures(serializedSig: SerializedSignature, targetAddr
|
|
|
61
61
|
case 'Secp256k1':
|
|
62
62
|
case 'Secp256r1': {
|
|
63
63
|
const pk = PublicKeySerde.de({ publicKeyEncoded: decoded.publicKey, schema: decoded.signatureScheme });
|
|
64
|
-
if (Formatter.isSuiAddressEqual(pk.
|
|
64
|
+
if (Formatter.isSuiAddressEqual(pk.toIotaAddress(), targetAddress)) {
|
|
65
65
|
return pk;
|
|
66
66
|
}
|
|
67
67
|
return undefined;
|
|
@@ -72,12 +72,12 @@ function getAddressFromSignatures(serializedSig: SerializedSignature, targetAddr
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
export async function getAllCoins(input: {
|
|
75
|
+
export async function getAllCoins(input: { client: IotaClient; owner: string; coinType: string | undefined }) {
|
|
76
76
|
let hasNext = true;
|
|
77
77
|
let cursor: string | undefined | null;
|
|
78
78
|
const res: CoinStruct[] = [];
|
|
79
79
|
while (hasNext) {
|
|
80
|
-
const currentPage: PaginatedCoins = await input.
|
|
80
|
+
const currentPage: PaginatedCoins = await input.client.getCoins({
|
|
81
81
|
owner: input.owner,
|
|
82
82
|
coinType: input.coinType,
|
|
83
83
|
cursor,
|