@scallop-io/sui-kit 0.44.2 → 0.45.0
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 +18 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -5
- package/dist/index.mjs.map +1 -1
- package/dist/libs/suiAccountManager/index.d.ts +5 -1
- package/dist/libs/suiTxBuilder/index.d.ts +47 -62
- package/dist/libs/suiTxBuilder/util.d.ts +2 -2
- package/dist/suiKit.d.ts +1 -1
- package/package.json +4 -3
- package/src/libs/suiAccountManager/index.ts +22 -4
- package/src/suiKit.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -97,6 +97,7 @@ var generateMnemonic = (numberOfWords = 24) => {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
// src/libs/suiAccountManager/index.ts
|
|
100
|
+
var import_cryptography = require("@mysten/sui.js/cryptography");
|
|
100
101
|
var SuiAccountManager = class {
|
|
101
102
|
/**
|
|
102
103
|
* Support the following ways to init the SuiToolkit:
|
|
@@ -105,7 +106,7 @@ var SuiAccountManager = class {
|
|
|
105
106
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
106
107
|
*
|
|
107
108
|
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
108
|
-
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
|
|
109
|
+
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored
|
|
109
110
|
*/
|
|
110
111
|
constructor({ mnemonics, secretKey } = {}) {
|
|
111
112
|
this.mnemonics = mnemonics || "";
|
|
@@ -113,11 +114,23 @@ var SuiAccountManager = class {
|
|
|
113
114
|
if (!this.mnemonics && !this.secretKey) {
|
|
114
115
|
this.mnemonics = generateMnemonic(24);
|
|
115
116
|
}
|
|
116
|
-
this.currentKeyPair = this.secretKey ?
|
|
117
|
-
normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey))
|
|
118
|
-
) : getKeyPair(this.mnemonics);
|
|
117
|
+
this.currentKeyPair = this.secretKey ? this.parseSecretKey(this.secretKey) : getKeyPair(this.mnemonics);
|
|
119
118
|
this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();
|
|
120
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Check if the secretKey starts with bench32 format
|
|
122
|
+
*/
|
|
123
|
+
parseSecretKey(secretKey) {
|
|
124
|
+
if (secretKey.startsWith(import_cryptography.SUI_PRIVATE_KEY_PREFIX)) {
|
|
125
|
+
const { secretKey: uint8ArraySecretKey } = (0, import_cryptography.decodeSuiPrivateKey)(secretKey);
|
|
126
|
+
return import_ed255192.Ed25519Keypair.fromSecretKey(
|
|
127
|
+
normalizePrivateKey(uint8ArraySecretKey)
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
return import_ed255192.Ed25519Keypair.fromSecretKey(
|
|
131
|
+
normalizePrivateKey(hexOrBase64ToUint8Array(secretKey))
|
|
132
|
+
);
|
|
133
|
+
}
|
|
121
134
|
/**
|
|
122
135
|
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.
|
|
123
136
|
* else:
|
|
@@ -699,7 +712,7 @@ var SuiKit = class {
|
|
|
699
712
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
700
713
|
*
|
|
701
714
|
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
702
|
-
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
|
|
715
|
+
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored
|
|
703
716
|
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'
|
|
704
717
|
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
|
|
705
718
|
*/
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/suiKit.ts","../src/libs/suiAccountManager/index.ts","../src/libs/suiAccountManager/keypair.ts","../src/libs/suiAccountManager/util.ts","../src/libs/suiAccountManager/crypto.ts","../src/libs/suiTxBuilder/index.ts","../src/libs/suiTxBuilder/util.ts","../src/libs/suiInteractor/suiInteractor.ts","../src/libs/suiModel/suiOwnedObject.ts","../src/libs/suiModel/suiSharedObject.ts","../src/libs/suiInteractor/util.ts","../src/libs/multiSig/client.ts","../src/libs/multiSig/publickey.ts"],"sourcesContent":["export * from '@mysten/sui.js/utils';\nexport * from '@mysten/sui.js/transactions';\nexport { SuiKit } from './suiKit';\nexport { SuiAccountManager } from './libs/suiAccountManager';\nexport { SuiTxBlock } from './libs/suiTxBuilder';\nexport { MultiSigClient } from './libs/multiSig';\nexport type * from './types';\n","/**\n * @description This file is used to aggregate the tools that used to interact with SUI network.\n */\nimport { getFullnodeUrl } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { SuiAccountManager } from './libs/suiAccountManager';\nimport { SuiTxBlock } from './libs/suiTxBuilder';\nimport { SuiInteractor } from './libs/suiInteractor';\nimport type {\n SuiTransactionBlockResponse,\n DevInspectResults,\n SuiObjectDataOptions,\n DryRunTransactionBlockResponse,\n} from '@mysten/sui.js/client';\nimport type { SuiSharedObject, SuiOwnedObject } from './libs/suiModel';\nimport type {\n SuiKitParams,\n DerivePathParams,\n SuiTxArg,\n SuiVecTxArg,\n} from './types';\n\n/**\n * @class SuiKit\n * @description This class is used to aggregate the tools that used to interact with SUI network.\n */\nexport class SuiKit {\n public accountManager: SuiAccountManager;\n public suiInteractor: SuiInteractor;\n\n /**\n * Support the following ways to init the SuiToolkit:\n * 1. mnemonics\n * 2. secretKey (base64 or hex)\n * If none of them is provided, will generate a random mnemonics with 24 words.\n *\n * @param mnemonics, 12 or 24 mnemonics words, separated by space\n * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored\n * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'\n * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type\n */\n constructor({\n mnemonics,\n secretKey,\n networkType,\n fullnodeUrls,\n }: SuiKitParams = {}) {\n // Init the account manager\n this.accountManager = new SuiAccountManager({ mnemonics, secretKey });\n // Init the sui interactor\n fullnodeUrls = fullnodeUrls || [getFullnodeUrl(networkType ?? 'mainnet')];\n this.suiInteractor = new SuiInteractor(fullnodeUrls);\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the keypair.\n * else:\n * it will generate signer from the mnemonic with the given derivePathParams.\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n getKeypair(derivePathParams?: DerivePathParams) {\n return this.accountManager.getKeyPair(derivePathParams);\n }\n\n /**\n * @description Switch the current account with the given derivePathParams\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n switchAccount(derivePathParams: DerivePathParams) {\n this.accountManager.switchAccount(derivePathParams);\n }\n\n /**\n * @description Get the address of the account for the given derivePathParams\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n getAddress(derivePathParams?: DerivePathParams) {\n return this.accountManager.getAddress(derivePathParams);\n }\n\n currentAddress() {\n return this.accountManager.currentAddress;\n }\n\n async getBalance(coinType?: string, derivePathParams?: DerivePathParams) {\n const owner = this.accountManager.getAddress(derivePathParams);\n return this.suiInteractor.currentClient.getBalance({ owner, coinType });\n }\n\n client() {\n return this.suiInteractor.currentClient;\n }\n\n async getObjects(objectIds: string[], options?: SuiObjectDataOptions) {\n return this.suiInteractor.getObjects(objectIds, options);\n }\n\n /**\n * @description Update objects in a batch\n * @param suiObjects\n */\n async updateObjects(suiObjects: (SuiSharedObject | SuiOwnedObject)[]) {\n return this.suiInteractor.updateObjects(suiObjects);\n }\n\n async signTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ) {\n if (tx instanceof SuiTxBlock) {\n tx.setSender(this.getAddress(derivePathParams));\n }\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n const txBytes =\n txBlock instanceof TransactionBlock\n ? await txBlock.build({ client: this.client() })\n : txBlock;\n const keyPair = this.getKeypair(derivePathParams);\n return await keyPair.signTransactionBlock(txBytes);\n }\n\n async signAndSendTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<SuiTransactionBlockResponse> {\n const { bytes, signature } = await this.signTxn(tx, derivePathParams);\n return this.suiInteractor.sendTx(bytes, signature);\n }\n\n async dryRunTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<DryRunTransactionBlockResponse> {\n if (tx instanceof SuiTxBlock) {\n tx.setSender(this.getAddress(derivePathParams));\n }\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n const txBytes =\n txBlock instanceof TransactionBlock\n ? await txBlock.build({ client: this.client() })\n : txBlock;\n return this.suiInteractor.dryRunTx(txBytes);\n }\n\n /**\n * Transfer the given amount of SUI to the recipient\n * @param recipient\n * @param amount\n * @param derivePathParams\n */\n async transferSui(\n recipient: string,\n amount: number,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferSui(recipient, amount);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Transfer to mutliple recipients\n * @param recipients the recipients addresses\n * @param amounts the amounts of SUI to transfer to each recipient, the length of amounts should be the same as the length of recipients\n * @param derivePathParams\n */\n async transferSuiToMany(\n recipients: string[],\n amounts: number[],\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferSuiToMany(recipients, amounts);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Transfer the given amounts of coin to multiple recipients\n * @param recipients the list of recipient address\n * @param amounts the amounts to transfer for each recipient\n * @param coinType any custom coin type but not SUI\n * @param derivePathParams the derive path params for the current signer\n */\n async transferCoinToMany(\n recipients: string[],\n amounts: number[],\n coinType: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n const owner = this.accountManager.getAddress(derivePathParams);\n const totalAmount = amounts.reduce((a, b) => a + b, 0);\n const coins = await this.suiInteractor.selectCoins(\n owner,\n totalAmount,\n coinType\n );\n tx.transferCoinToMany(\n coins.map((c) => c.objectId),\n owner,\n recipients,\n amounts\n );\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n async transferCoin(\n recipient: string,\n amount: number,\n coinType: string,\n derivePathParams?: DerivePathParams\n ) {\n return this.transferCoinToMany(\n [recipient],\n [amount],\n coinType,\n derivePathParams\n );\n }\n\n async transferObjects(\n objects: string[],\n recipient: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferObjects(objects, recipient);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n async moveCall(callParams: {\n target: string;\n arguments?: (SuiTxArg | SuiVecTxArg)[];\n typeArguments?: string[];\n derivePathParams?: DerivePathParams;\n }) {\n const {\n target,\n arguments: args = [],\n typeArguments = [],\n derivePathParams,\n } = callParams;\n const tx = new SuiTxBlock();\n tx.moveCall(target, args, typeArguments);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount\n * @param amount\n * @param coinType\n * @param owner\n */\n async selectCoinsWithAmount(\n amount: number,\n coinType: string,\n owner?: string\n ) {\n owner = owner || this.accountManager.currentAddress;\n const coins = await this.suiInteractor.selectCoins(owner, amount, coinType);\n return coins.map((c) => c.objectId);\n }\n\n /**\n * stake the given amount of SUI to the validator\n * @param amount the amount of SUI to stake\n * @param validatorAddr the validator address\n * @param derivePathParams the derive path params for the current signer\n */\n async stakeSui(\n amount: number,\n validatorAddr: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.stakeSui(amount, validatorAddr);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.\n * Since the transaction is not submitted, its gas cost is not charged.\n * @param tx the transaction to execute\n * @param derivePathParams the derive path params\n * @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.\n */\n async inspectTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<DevInspectResults> {\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n return this.suiInteractor.currentClient.devInspectTransactionBlock({\n transactionBlock: txBlock,\n sender: this.getAddress(derivePathParams),\n });\n }\n}\n","import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport { getKeyPair } from './keypair';\nimport { hexOrBase64ToUint8Array, normalizePrivateKey } from './util';\nimport { generateMnemonic } from './crypto';\nimport type { AccountMangerParams, DerivePathParams } from 'src/types';\n\nexport class SuiAccountManager {\n private mnemonics: string;\n private secretKey: string;\n public currentKeyPair: Ed25519Keypair;\n public currentAddress: string;\n\n /**\n * Support the following ways to init the SuiToolkit:\n * 1. mnemonics\n * 2. secretKey (base64 or hex)\n * If none of them is provided, will generate a random mnemonics with 24 words.\n *\n * @param mnemonics, 12 or 24 mnemonics words, separated by space\n * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored\n */\n constructor({ mnemonics, secretKey }: AccountMangerParams = {}) {\n // If the mnemonics or secretKey is provided, use it\n // Otherwise, generate a random mnemonics with 24 words\n this.mnemonics = mnemonics || '';\n this.secretKey = secretKey || '';\n if (!this.mnemonics && !this.secretKey) {\n this.mnemonics = generateMnemonic(24);\n }\n\n // Init the current account\n this.currentKeyPair = this.secretKey\n ? Ed25519Keypair.fromSecretKey(\n normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey))\n )\n : getKeyPair(this.mnemonics);\n this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.\n * else:\n * it will generate keyPair from the mnemonic with the given derivePathParams.\n */\n getKeyPair(derivePathParams?: DerivePathParams) {\n if (!derivePathParams || !this.mnemonics) return this.currentKeyPair;\n return getKeyPair(this.mnemonics, derivePathParams);\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the currentAddress.\n * else:\n * it will generate address from the mnemonic with the given derivePathParams.\n */\n getAddress(derivePathParams?: DerivePathParams) {\n if (!derivePathParams || !this.mnemonics) return this.currentAddress;\n return getKeyPair(this.mnemonics, derivePathParams)\n .getPublicKey()\n .toSuiAddress();\n }\n\n /**\n * Switch the current account with the given derivePathParams.\n * This is only useful when the mnemonics is provided. For secretKey mode, it will always use the same account.\n */\n switchAccount(derivePathParams: DerivePathParams) {\n if (this.mnemonics) {\n this.currentKeyPair = getKeyPair(this.mnemonics, derivePathParams);\n this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();\n }\n }\n}\n","import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport type { DerivePathParams } from 'src/types';\n\n/**\n * @description Get ed25519 derive path for SUI\n * @param derivePathParams\n */\nexport const getDerivePathForSUI = (\n derivePathParams: DerivePathParams = {}\n) => {\n const {\n accountIndex = 0,\n isExternal = false,\n addressIndex = 0,\n } = derivePathParams;\n return `m/44'/784'/${accountIndex}'/${isExternal ? 1 : 0}'/${addressIndex}'`;\n};\n\n/**\n * the format is m/44'/784'/accountIndex'/${isExternal ? 1 : 0}'/addressIndex'\n *\n * accountIndex is the index of the account, default is 0.\n *\n * isExternal is the type of the address, default is false. Usually, the external address is used to receive coins. The internal address is used to change coins.\n *\n * addressIndex is the index of the address, default is 0. It's used to generate multiple addresses for one account.\n *\n * @description Get keypair from mnemonics and derive path\n * @param mnemonics\n * @param derivePathParams\n */\nexport const getKeyPair = (\n mnemonics: string,\n derivePathParams: DerivePathParams = {}\n) => {\n const derivePath = getDerivePathForSUI(derivePathParams);\n return Ed25519Keypair.deriveKeypair(mnemonics, derivePath);\n};\n","import { fromB64 } from '@mysten/sui.js/utils';\n\n/**\n * @description This regular expression matches any string that contains only hexadecimal digits (0-9, A-F, a-f).\n * @param str\n */\nexport const isHex = (str: string) =>\n /^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(str);\n\n/**\n * @description This regular expression matches any string that contains only base64 digits (0-9, A-Z, a-z, +, /, =).\n * Note that the \"=\" signs at the end are optional padding characters that may be present in some base64 encoded strings.\n * @param str\n */\nexport const isBase64 = (str: string) => /^[a-zA-Z0-9+/]+={0,2}$/g.test(str);\n\n/**\n * Convert a hex string to Uint8Array\n * @param hexStr\n */\nexport const fromHEX = (hexStr: string): Uint8Array => {\n if (!hexStr) {\n throw new Error('cannot parse empty string to Uint8Array');\n }\n const intArr = hexStr\n .replace('0x', '')\n .match(/.{1,2}/g)\n ?.map((byte) => parseInt(byte, 16));\n\n if (!intArr || intArr.length === 0) {\n throw new Error(`Unable to parse HEX: ${hexStr}`);\n }\n return Uint8Array.from(intArr);\n};\n\n/**\n * @description Convert a hex or base64 string to Uint8Array\n */\nexport const hexOrBase64ToUint8Array = (str: string): Uint8Array => {\n if (isHex(str)) {\n return fromHEX(str);\n } else if (isBase64(str)) {\n return fromB64(str);\n } else {\n throw new Error('The string is not a valid hex or base64 string.');\n }\n};\n\nconst PRIVATE_KEY_SIZE = 32;\nconst LEGACY_PRIVATE_KEY_SIZE = 64;\n/**\n * normalize a private key\n * A private key is a 32-byte array.\n * But there are two different formats for private keys:\n * 1. A 32-byte array\n * 2. A 64-byte array with the first 32 bytes being the private key and the last 32 bytes being the public key\n * 3. A 33-byte array with the first byte being 0x00 (sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning)\n */\nexport const normalizePrivateKey = (key: Uint8Array): Uint8Array => {\n if (key.length === LEGACY_PRIVATE_KEY_SIZE) {\n // This is a legacy secret key, we need to strip the public key bytes and only read the first 32 bytes\n key = key.slice(0, PRIVATE_KEY_SIZE);\n } else if (key.length === PRIVATE_KEY_SIZE + 1 && key[0] === 0) {\n // sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning\n return key.slice(1);\n } else if (key.length === PRIVATE_KEY_SIZE) {\n return key;\n }\n throw new Error('invalid secret key');\n};\n","import { generateMnemonic as genMnemonic } from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\n\nexport const generateMnemonic = (numberOfWords: 12 | 24 = 24) => {\n const strength = numberOfWords === 12 ? 128 : 256;\n return genMnemonic(wordlist, strength);\n};\n","import { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { SUI_SYSTEM_STATE_OBJECT_ID } from '@mysten/sui.js/utils';\nimport { convertArgs, convertAddressArg, convertObjArg } from './util';\nimport type { SuiClient, SuiObjectRef } from '@mysten/sui.js/client';\nimport type { TransactionObjectArgument } from '@mysten/sui.js/transactions';\nimport type {\n TransactionExpiration,\n SharedObjectRef,\n} from '@mysten/sui.js/bcs';\nimport type { Keypair } from '@mysten/sui.js/cryptography';\nimport type {\n ObjectCallArg,\n TransactionType,\n SuiTxArg,\n SuiAddressArg,\n SuiObjectArg,\n SuiVecTxArg,\n} from 'src/types';\n\nexport class SuiTxBlock {\n public txBlock: TransactionBlock;\n\n constructor(transaction?: TransactionBlock) {\n this.txBlock = new TransactionBlock(transaction);\n }\n\n /* Directly wrap methods and properties of TransactionBlock */\n get gas() {\n return this.txBlock.gas;\n }\n get blockData() {\n return this.txBlock.blockData;\n }\n\n address(value: string) {\n return this.txBlock.pure(value, 'address');\n }\n pure(value: unknown, type?: string) {\n return this.txBlock.pure(value, type);\n }\n object(value: string | ObjectCallArg) {\n return this.txBlock.object(value);\n }\n objectRef(ref: SuiObjectRef) {\n return this.txBlock.objectRef(ref);\n }\n sharedObjectRef(ref: SharedObjectRef) {\n return this.txBlock.sharedObjectRef(ref);\n }\n setSender(sender: string) {\n return this.txBlock.setSender(sender);\n }\n setSenderIfNotSet(sender: string) {\n return this.txBlock.setSenderIfNotSet(sender);\n }\n setExpiration(expiration?: TransactionExpiration) {\n return this.txBlock.setExpiration(expiration);\n }\n setGasPrice(price: number | bigint) {\n return this.txBlock.setGasPrice(price);\n }\n setGasBudget(budget: number | bigint) {\n return this.txBlock.setGasBudget(budget);\n }\n setGasOwner(owner: string) {\n return this.txBlock.setGasOwner(owner);\n }\n setGasPayment(payments: SuiObjectRef[]) {\n return this.txBlock.setGasPayment(payments);\n }\n serialize() {\n return this.txBlock.serialize();\n }\n sign(params: {\n signer: Keypair;\n client?: SuiClient;\n onlyTransactionKind?: boolean;\n }) {\n return this.txBlock.sign(params);\n }\n build(\n params: {\n client?: SuiClient;\n onlyTransactionKind?: boolean;\n } = {}\n ) {\n return this.txBlock.build(params);\n }\n getDigest(params: { client?: SuiClient } = {}) {\n return this.txBlock.getDigest(params);\n }\n add(...args: TransactionType) {\n return this.txBlock.add(...args);\n }\n publish({\n modules,\n dependencies,\n }: {\n modules: number[][] | string[];\n dependencies: string[];\n }) {\n return this.txBlock.publish({ modules, dependencies });\n }\n upgrade({\n modules,\n dependencies,\n packageId,\n ticket,\n }: {\n modules: number[][] | string[];\n dependencies: string[];\n packageId: string;\n ticket: TransactionObjectArgument | string;\n }) {\n return this.txBlock.upgrade({ modules, dependencies, packageId, ticket });\n }\n makeMoveVec({\n objects,\n type,\n }: {\n objects: (TransactionObjectArgument | string)[];\n type?: string;\n }) {\n return this.txBlock.makeMoveVec({ objects, type });\n }\n\n /* Override methods of TransactionBlock */\n\n transferObjects(objects: SuiObjectArg[], address: SuiAddressArg) {\n return this.txBlock.transferObjects(\n objects.map((object) => convertObjArg(this.txBlock, object)),\n convertAddressArg(this.txBlock, address)\n );\n }\n\n splitCoins(coin: SuiObjectArg, amounts: SuiTxArg[]) {\n const res = this.txBlock.splitCoins(\n convertObjArg(this.txBlock, coin),\n convertArgs(this.txBlock, amounts)\n );\n return amounts.map((_, i) => res[i]);\n }\n\n mergeCoins(destination: SuiObjectArg, sources: SuiObjectArg[]) {\n const destinationObject = convertObjArg(this.txBlock, destination);\n const sourceObjects = sources.map((source) =>\n convertObjArg(this.txBlock, source)\n );\n return this.txBlock.mergeCoins(destinationObject, sourceObjects);\n }\n\n /**\n * @description Move call\n * @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`\n * @param args the arguments of the move call, such as `['0x1', '0x2']`\n * @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`\n */\n moveCall(\n target: string,\n args: (SuiTxArg | SuiVecTxArg)[] = [],\n typeArgs: string[] = []\n ) {\n // a regex for pattern `${string}::${string}::${string}`\n const regex =\n /(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/;\n const match = target.match(regex);\n if (match === null)\n throw new Error(\n 'Invalid target format. Expected `${string}::${string}::${string}`'\n );\n const convertedArgs = convertArgs(this.txBlock, args);\n return this.txBlock.moveCall({\n target: target as `${string}::${string}::${string}`,\n arguments: convertedArgs,\n typeArguments: typeArgs,\n });\n }\n\n /* Enhance methods of TransactionBlock */\n\n transferSuiToMany(recipients: SuiAddressArg[], amounts: SuiTxArg[]) {\n // require recipients.length === amounts.length\n if (recipients.length !== amounts.length) {\n throw new Error(\n 'transferSuiToMany: recipients.length !== amounts.length'\n );\n }\n const coins = this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, amounts)\n );\n const recipientObjects = recipients.map((recipient) =>\n convertAddressArg(this.txBlock, recipient)\n );\n recipientObjects.forEach((address, index) => {\n this.txBlock.transferObjects([coins[index]], address);\n });\n return this;\n }\n\n transferSui(address: SuiAddressArg, amount: SuiTxArg) {\n return this.transferSuiToMany([address], [amount]);\n }\n\n takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiTxArg) {\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const mergedCoin = coinObjects[0];\n if (coins.length > 1) {\n this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));\n }\n const [sendCoin] = this.txBlock.splitCoins(\n mergedCoin,\n convertArgs(this.txBlock, [amount])\n );\n return [sendCoin, mergedCoin];\n }\n\n splitSUIFromGas(amounts: SuiTxArg[]) {\n return this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, amounts)\n );\n }\n\n splitMultiCoins(coins: SuiObjectArg[], amounts: SuiTxArg[]) {\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const mergedCoin = coinObjects[0];\n if (coins.length > 1) {\n this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));\n }\n const splitedCoins = this.txBlock.splitCoins(\n mergedCoin,\n convertArgs(this.txBlock, amounts)\n );\n return { splitedCoins, mergedCoin };\n }\n\n transferCoinToMany(\n coins: SuiObjectArg[],\n sender: SuiAddressArg,\n recipients: SuiAddressArg[],\n amounts: SuiTxArg[]\n ) {\n // require recipients.length === amounts.length\n if (recipients.length !== amounts.length) {\n throw new Error(\n 'transferSuiToMany: recipients.length !== amounts.length'\n );\n }\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const { splitedCoins, mergedCoin } = this.splitMultiCoins(\n coinObjects,\n amounts\n );\n const recipientObjects = recipients.map((recipient) =>\n convertAddressArg(this.txBlock, recipient)\n );\n recipientObjects.forEach((address, index) => {\n this.txBlock.transferObjects([splitedCoins[index]], address);\n });\n this.txBlock.transferObjects(\n [mergedCoin],\n convertAddressArg(this.txBlock, sender)\n );\n return this;\n }\n\n transferCoin(\n coins: SuiObjectArg[],\n sender: SuiAddressArg,\n recipient: SuiAddressArg,\n amount: SuiTxArg\n ) {\n return this.transferCoinToMany(coins, sender, [recipient], [amount]);\n }\n\n stakeSui(amount: SuiTxArg, validatorAddr: SuiAddressArg) {\n const [stakeCoin] = this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, [amount])\n );\n return this.txBlock.moveCall({\n target: '0x3::sui_system::request_add_stake',\n arguments: convertArgs(this.txBlock, [\n SUI_SYSTEM_STATE_OBJECT_ID,\n stakeCoin,\n this.txBlock.pure(validatorAddr),\n ]),\n });\n }\n}\n","import {\n normalizeSuiObjectId,\n normalizeSuiAddress,\n isValidSuiObjectId,\n isValidSuiAddress,\n} from '@mysten/sui.js/utils';\nimport { Inputs } from '@mysten/sui.js/transactions';\nimport { isPureArg } from '@mysten/sui.js/bcs';\nimport { isSerializedBcs } from '@mysten/bcs';\nimport type {\n TransactionArgument,\n TransactionBlock,\n TransactionObjectArgument,\n} from '@mysten/sui.js/transactions';\nimport type {\n SuiInputTypes,\n SuiObjectArg,\n SuiAddressArg,\n SuiTxArg,\n SuiVecTxArg,\n} from 'src/types';\n\nexport const getDefaultSuiInputType = (\n value: SuiTxArg\n): SuiInputTypes | undefined => {\n if (typeof value === 'string' && isValidSuiObjectId(value)) {\n return 'object';\n } else if (typeof value === 'number' || typeof value === 'bigint') {\n return 'u64';\n } else if (typeof value === 'boolean') {\n return 'bool';\n } else {\n return undefined;\n }\n};\n\n/**\n * Since we know the elements in the array are the same type\n * If type is not provided, we will try to infer the type from the first element\n * By default,\n *\n * string is hex and its length equal to 32 =====> object id\n * number, bigint ====> u64\n * boolean =====> bool\n *\n * If type is provided, we will use the type to convert the array\n * @param args\n * @param type 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256' | 'signer' | 'object' | string\n */\nexport function makeVecParam(\n txBlock: TransactionBlock,\n args: SuiTxArg[],\n type?: SuiInputTypes\n): TransactionArgument {\n if (args.length === 0)\n throw new Error('Transaction builder error: Empty array is not allowed');\n // Using first element value as default type\n const defaultSuiType = getDefaultSuiInputType(args[0]);\n const VECTOR_REGEX = /^vector<(.+)>$/;\n const STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;\n\n type = type || defaultSuiType;\n\n if (type === 'object') {\n const objects = args.map((arg) =>\n typeof arg === 'string' && isValidSuiObjectId(arg)\n ? txBlock.object(normalizeSuiObjectId(arg))\n : convertObjArg(txBlock, arg as SuiObjectArg)\n );\n return txBlock.makeMoveVec({ objects });\n } else if (\n typeof type === 'string' &&\n !VECTOR_REGEX.test(type) &&\n !STRUCT_REGEX.test(type)\n ) {\n return txBlock.pure(args, `vector<${type}>`);\n } else {\n const objects = args.map((arg) =>\n convertObjArg(txBlock, arg as SuiObjectArg)\n );\n return txBlock.makeMoveVec({ objects, type });\n }\n}\n\n/**\n * Check whether it is an valid move vec input.\n *\n * @param arg The argument to check.\n * @returns boolean.\n */\nexport function isMoveVecArg(arg: SuiTxArg | SuiVecTxArg): arg is SuiVecTxArg {\n if (typeof arg === 'object' && 'vecType' in arg && 'value' in arg) {\n return true;\n } else if (Array.isArray(arg)) {\n return true;\n }\n return false;\n}\n\n/**\n * Convert any valid input into array of TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param args The array of argument to convert.\n * @returns The converted array of TransactionArgument.\n */\nexport function convertArgs(\n txBlock: TransactionBlock,\n args: (SuiTxArg | SuiVecTxArg)[]\n) {\n return args.map((arg) => {\n if (typeof arg === 'string' && isValidSuiObjectId(arg)) {\n return txBlock.object(normalizeSuiObjectId(arg));\n } else if (\n typeof arg == 'object' &&\n !isSerializedBcs(arg) &&\n !isPureArg(arg) &&\n !isMoveVecArg(arg)\n ) {\n return convertObjArg(txBlock, arg as SuiObjectArg);\n } else if (isMoveVecArg(arg)) {\n const vecType = 'vecType' in arg;\n return vecType\n ? makeVecParam(txBlock, arg.value, arg.vecType)\n : makeVecParam(txBlock, arg);\n } else if (isSerializedBcs(arg)) {\n return arg;\n } else {\n return txBlock.pure(arg);\n }\n });\n}\n\n/**\n * Convert any valid address input into a TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param arg The address argument to convert.\n * @returns The converted TransactionArgument.\n */\nexport function convertAddressArg(\n txBlock: TransactionBlock,\n arg: SuiAddressArg\n) {\n if (typeof arg === 'string' && isValidSuiAddress(arg)) {\n return txBlock.pure.address(normalizeSuiAddress(arg));\n } else if (\n typeof arg == 'object' &&\n !isSerializedBcs(arg) &&\n !isPureArg(arg)\n ) {\n return convertObjArg(txBlock, arg as SuiObjectArg);\n } else if (isPureArg(arg)) {\n return txBlock.pure(arg);\n } else {\n return arg;\n }\n}\n\n/**\n * Convert any valid object input into a TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param arg The object argument to convert.\n * @returns The converted TransactionArgument.\n */\nexport function convertObjArg(\n txb: TransactionBlock,\n arg: SuiObjectArg\n): TransactionObjectArgument {\n if (typeof arg === 'string') {\n return txb.object(arg);\n }\n\n if ('digest' in arg && 'version' in arg && 'objectId' in arg) {\n return txb.objectRef(arg);\n }\n\n if ('objectId' in arg && 'initialSharedVersion' in arg && 'mutable' in arg) {\n return txb.sharedObjectRef(arg);\n }\n\n if ('Object' in arg) {\n if ('ImmOrOwned' in arg.Object) {\n return txb.object(Inputs.ObjectRef(arg.Object.ImmOrOwned));\n } else if ('Shared' in arg.Object) {\n return txb.object(Inputs.SharedObjectRef(arg.Object.Shared));\n } else {\n throw new Error('Invalid argument type');\n }\n }\n\n if ('kind' in arg) {\n return arg;\n }\n\n throw new Error('Invalid argument type');\n}\n","import { SuiClient } from '@mysten/sui.js/client';\nimport { SuiOwnedObject, SuiSharedObject } from '../suiModel';\nimport { delay } from './util';\nimport type {\n SuiTransactionBlockResponseOptions,\n SuiTransactionBlockResponse,\n SuiObjectDataOptions,\n SuiObjectData,\n DryRunTransactionBlockResponse,\n} from '@mysten/sui.js/client';\n\n/**\n * Encapsulates all functions that interact with the sui sdk\n */\nexport class SuiInteractor {\n public readonly clients: SuiClient[];\n public currentClient: SuiClient;\n public readonly fullNodes: string[];\n public currentFullNode: string;\n\n constructor(fullNodeUrls: string[]) {\n if (fullNodeUrls.length === 0)\n throw new Error('fullNodeUrls must not be empty');\n this.fullNodes = fullNodeUrls;\n this.clients = fullNodeUrls.map((url) => new SuiClient({ url }));\n this.currentFullNode = fullNodeUrls[0];\n this.currentClient = this.clients[0];\n }\n\n switchToNextClient() {\n const currentClientIdx = this.clients.indexOf(this.currentClient);\n this.currentClient =\n this.clients[(currentClientIdx + 1) % this.clients.length];\n this.currentFullNode =\n this.fullNodes[(currentClientIdx + 1) % this.clients.length];\n }\n\n async sendTx(\n transactionBlock: Uint8Array | string,\n signature: string | string[]\n ): Promise<SuiTransactionBlockResponse> {\n const txResOptions: SuiTransactionBlockResponseOptions = {\n showEvents: true,\n showEffects: true,\n showObjectChanges: true,\n showBalanceChanges: true,\n };\n\n for (const clientIdx in this.clients) {\n try {\n return await this.clients[clientIdx].executeTransactionBlock({\n transactionBlock,\n signature,\n options: txResOptions,\n });\n } catch (err) {\n console.warn(\n `Failed to send transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n await delay(2000);\n }\n }\n throw new Error('Failed to send transaction with all fullnodes');\n }\n\n async dryRunTx(\n transactionBlock: Uint8Array\n ): Promise<DryRunTransactionBlockResponse> {\n for (const clientIdx in this.clients) {\n try {\n return await this.clients[clientIdx].dryRunTransactionBlock({\n transactionBlock,\n });\n } catch (err) {\n console.warn(\n `Failed to dry run transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n await delay(2000);\n }\n }\n throw new Error('Failed to dry run transaction with all fullnodes');\n }\n\n async getObjects(\n ids: string[],\n options?: SuiObjectDataOptions\n ): Promise<SuiObjectData[]> {\n const opts: SuiObjectDataOptions = options ?? {\n showContent: true,\n showDisplay: true,\n showType: true,\n showOwner: true,\n };\n\n for (const clientIdx in this.clients) {\n try {\n const objects = await this.clients[clientIdx].multiGetObjects({\n ids,\n options: opts,\n });\n const parsedObjects = objects\n .map((object) => {\n return object.data;\n })\n .filter((object) => object !== null && object !== undefined);\n return parsedObjects as SuiObjectData[];\n } catch (err) {\n await delay(2000);\n console.warn(\n `Failed to get objects with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n }\n }\n throw new Error('Failed to get objects with all fullnodes');\n }\n\n async getObject(id: string, options?: SuiObjectDataOptions) {\n const objects = await this.getObjects([id], options);\n return objects[0];\n }\n\n /**\n * @description Update objects in a batch\n * @param suiObjects\n */\n async updateObjects(suiObjects: (SuiOwnedObject | SuiSharedObject)[]) {\n const objectIds = suiObjects.map((obj) => obj.objectId);\n const objects = await this.getObjects(objectIds);\n for (const object of objects) {\n const suiObject = suiObjects.find(\n (obj) => obj.objectId === object?.objectId\n );\n if (suiObject instanceof SuiSharedObject) {\n if (\n object.owner &&\n typeof object.owner === 'object' &&\n 'Shared' in object.owner\n ) {\n suiObject.initialSharedVersion =\n object.owner.Shared.initial_shared_version;\n } else {\n suiObject.initialSharedVersion = undefined;\n }\n } else if (suiObject instanceof SuiOwnedObject) {\n suiObject.version = object?.version;\n suiObject.digest = object?.digest;\n }\n }\n }\n\n /**\n * @description Select coins that add up to the given amount.\n * @param addr the address of the owner\n * @param amount the amount that is needed for the coin\n * @param coinType the coin type, default is '0x2::SUI::SUI'\n */\n async selectCoins(\n addr: string,\n amount: number,\n coinType: string = '0x2::SUI::SUI'\n ) {\n const selectedCoins: {\n objectId: string;\n digest: string;\n version: string;\n }[] = [];\n let totalAmount = 0;\n let hasNext = true,\n nextCursor: string | null | undefined = null;\n while (hasNext && totalAmount < amount) {\n const coins = await this.currentClient.getCoins({\n owner: addr,\n coinType: coinType,\n cursor: nextCursor,\n });\n // Sort the coins by balance in descending order\n coins.data.sort((a, b) => parseInt(b.balance) - parseInt(a.balance));\n for (const coinData of coins.data) {\n selectedCoins.push({\n objectId: coinData.coinObjectId,\n digest: coinData.digest,\n version: coinData.version,\n });\n totalAmount = totalAmount + parseInt(coinData.balance);\n if (totalAmount >= amount) {\n break;\n }\n }\n\n nextCursor = coins.nextCursor;\n hasNext = coins.hasNextPage;\n }\n\n if (!selectedCoins.length) {\n throw new Error('No valid coins found for the transaction.');\n }\n return selectedCoins;\n }\n}\n","import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';\nimport type { CallArg } from '@mysten/sui.js/bcs';\n\nexport class SuiOwnedObject {\n public readonly objectId: string;\n public version?: string;\n public digest?: string;\n\n constructor(param: { objectId: string; version?: string; digest?: string }) {\n this.objectId = param.objectId;\n this.version = param.version;\n this.digest = param.digest;\n }\n\n /**\n * Check if the object is fully initialized.\n * So that when it's used as an input, it won't be necessary to fetch from fullnode again.\n * Which can save time when sending transactions.\n */\n isFullObject(): boolean {\n return !!this.version && !!this.digest;\n }\n\n asCallArg(): CallArg | string {\n if (!this.version || !this.digest) {\n return this.objectId;\n }\n return {\n Object: {\n ImmOrOwned: {\n objectId: this.objectId,\n version: this.version,\n digest: this.digest,\n },\n },\n };\n }\n\n /**\n * Update object version & digest based on the transaction response.\n * @param txResponse\n */\n updateFromTxResponse(txResponse: SuiTransactionBlockResponse) {\n const changes = txResponse.objectChanges;\n if (!changes) {\n throw new Error('Bad transaction response!');\n }\n for (const change of changes) {\n if (change.type === 'mutated' && change.objectId === this.objectId) {\n this.digest = change.digest;\n this.version = change.version;\n return;\n }\n }\n throw new Error('Could not find object in transaction response!');\n }\n}\n","import type { CallArg } from '@mysten/sui.js/bcs';\n\nexport class SuiSharedObject {\n public readonly objectId: string;\n public initialSharedVersion?: string;\n\n constructor(param: {\n objectId: string;\n initialSharedVersion?: string;\n mutable?: boolean;\n }) {\n this.objectId = param.objectId;\n this.initialSharedVersion = param.initialSharedVersion;\n }\n\n asCallArg(mutable: boolean = false): CallArg | string {\n if (!this.initialSharedVersion) {\n return this.objectId;\n }\n return {\n Object: {\n Shared: {\n objectId: this.objectId,\n initialSharedVersion: this.initialSharedVersion,\n mutable,\n },\n },\n };\n }\n}\n","export const delay = (ms: number) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n","import { MultiSigPublicKey } from '@mysten/sui.js/multisig';\nimport type { PublicKey } from '@mysten/sui.js/src/cryptography';\nimport { ed25519PublicKeyFromBase64 } from './publickey';\n\nexport type PublicKeyWeightPair = {\n publicKey: PublicKey;\n weight: number;\n};\n\nexport class MultiSigClient {\n public readonly pksWeightPairs: PublicKeyWeightPair[];\n public readonly threshold: number;\n public readonly multiSigPublicKey: MultiSigPublicKey;\n constructor(pks: PublicKeyWeightPair[], threshold: number) {\n this.pksWeightPairs = pks;\n this.threshold = threshold;\n this.multiSigPublicKey = MultiSigPublicKey.fromPublicKeys({\n threshold: this.threshold,\n publicKeys: this.pksWeightPairs,\n });\n }\n\n static fromRawEd25519PublicKeys(\n rawPublicKeys: string[],\n weights: number[],\n threshold: number\n ): MultiSigClient {\n const pks = rawPublicKeys.map((rawPublicKey, i) => {\n return {\n publicKey: ed25519PublicKeyFromBase64(rawPublicKey),\n weight: weights[i],\n };\n });\n return new MultiSigClient(pks, threshold);\n }\n\n multiSigAddress(): string {\n return this.multiSigPublicKey.toSuiAddress();\n }\n\n combinePartialSigs(sigs: string[]): string {\n return this.multiSigPublicKey.combinePartialSignatures(sigs);\n }\n}\n","import { PublicKey } from '@mysten/sui.js/cryptography';\nimport { Ed25519PublicKey } from '@mysten/sui.js/keypairs/ed25519';\nimport { fromB64 } from '@mysten/sui.js/utils';\n\nexport function ed25519PublicKeyFromBase64(rawPubkey: string): PublicKey {\n let bytes = fromB64(rawPubkey);\n // rawPubkeys should either be 32 bytes or 33 bytes (with the first byte being flag)\n if (bytes.length !== 32 && bytes.length !== 33) throw 'invalid pubkey length';\n bytes = bytes.length === 33 ? bytes.slice(1) : bytes;\n return new Ed25519PublicKey(bytes);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,iCAAd;AACA,wBAAc,wCADd;;;ACGA,IAAAA,iBAA+B;AAC/B,IAAAC,uBAAiC;;;ACJjC,IAAAC,kBAA+B;;;ACA/B,qBAA+B;AAOxB,IAAM,sBAAsB,CACjC,mBAAqC,CAAC,MACnC;AACH,QAAM;AAAA,IACJ,eAAe;AAAA,IACf,aAAa;AAAA,IACb,eAAe;AAAA,EACjB,IAAI;AACJ,SAAO,cAAc,YAAY,KAAK,aAAa,IAAI,CAAC,KAAK,YAAY;AAC3E;AAeO,IAAM,aAAa,CACxB,WACA,mBAAqC,CAAC,MACnC;AACH,QAAM,aAAa,oBAAoB,gBAAgB;A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AAM,gBAAe;AAAA,EAI1B,YAAY,KAA4B,WAAmB;AACzD,SAAK,iBAAiB;AACtB,SAAK,YAAY;AACjB,SAAK,oBAAoB,kCAAkB,eAAe;AAAA,MACxD,WAAW,KAAK;AAAA,MAChB,YAAY,KAAK;AAAA,IACnB,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,yBACL,eACA,SACA,WACgB;AAChB,UAAM,MAAM,cAAc,IAAI,CAAC,cAAc,MAAM;AACjD,aAAO;AAAA,QACL,WAAW,2BAA2B,YAAY;AAAA,QAClD,QAAQ,QAAQ,CAAC;AAAA,MACnB;AAAA,IACF,CAAC;AACD,WAAO,IAAI,gBAAe,KAAK,SAAS;AAAA,EAC1C;AAAA,EAEA,kBAA0B;AACxB,WAAO,KAAK,kBAAkB,aAAa;AAAA,EAC7C;AAAA,EAEA,mBAAmB,MAAwB;AACzC,WAAO,KAAK,kBAAkB,yBAAyB,IAAI;AAAA,EAC7D;AACF;","names":["import_client","import_transactions","import_ed25519","genMnemonic","import_transactions","import_utils","import_utils","import_bcs","import_ed25519","import_utils"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/suiKit.ts","../src/libs/suiAccountManager/index.ts","../src/libs/suiAccountManager/keypair.ts","../src/libs/suiAccountManager/util.ts","../src/libs/suiAccountManager/crypto.ts","../src/libs/suiTxBuilder/index.ts","../src/libs/suiTxBuilder/util.ts","../src/libs/suiInteractor/suiInteractor.ts","../src/libs/suiModel/suiOwnedObject.ts","../src/libs/suiModel/suiSharedObject.ts","../src/libs/suiInteractor/util.ts","../src/libs/multiSig/client.ts","../src/libs/multiSig/publickey.ts"],"sourcesContent":["export * from '@mysten/sui.js/utils';\nexport * from '@mysten/sui.js/transactions';\nexport { SuiKit } from './suiKit';\nexport { SuiAccountManager } from './libs/suiAccountManager';\nexport { SuiTxBlock } from './libs/suiTxBuilder';\nexport { MultiSigClient } from './libs/multiSig';\nexport type * from './types';\n","/**\n * @description This file is used to aggregate the tools that used to interact with SUI network.\n */\nimport { getFullnodeUrl } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { SuiAccountManager } from './libs/suiAccountManager';\nimport { SuiTxBlock } from './libs/suiTxBuilder';\nimport { SuiInteractor } from './libs/suiInteractor';\nimport type {\n SuiTransactionBlockResponse,\n DevInspectResults,\n SuiObjectDataOptions,\n DryRunTransactionBlockResponse,\n} from '@mysten/sui.js/client';\nimport type { SuiSharedObject, SuiOwnedObject } from './libs/suiModel';\nimport type {\n SuiKitParams,\n DerivePathParams,\n SuiTxArg,\n SuiVecTxArg,\n} from './types';\n\n/**\n * @class SuiKit\n * @description This class is used to aggregate the tools that used to interact with SUI network.\n */\nexport class SuiKit {\n public accountManager: SuiAccountManager;\n public suiInteractor: SuiInteractor;\n\n /**\n * Support the following ways to init the SuiToolkit:\n * 1. mnemonics\n * 2. secretKey (base64 or hex)\n * If none of them is provided, will generate a random mnemonics with 24 words.\n *\n * @param mnemonics, 12 or 24 mnemonics words, separated by space\n * @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored\n * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'\n * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type\n */\n constructor({\n mnemonics,\n secretKey,\n networkType,\n fullnodeUrls,\n }: SuiKitParams = {}) {\n // Init the account manager\n this.accountManager = new SuiAccountManager({ mnemonics, secretKey });\n // Init the sui interactor\n fullnodeUrls = fullnodeUrls || [getFullnodeUrl(networkType ?? 'mainnet')];\n this.suiInteractor = new SuiInteractor(fullnodeUrls);\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the keypair.\n * else:\n * it will generate signer from the mnemonic with the given derivePathParams.\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n getKeypair(derivePathParams?: DerivePathParams) {\n return this.accountManager.getKeyPair(derivePathParams);\n }\n\n /**\n * @description Switch the current account with the given derivePathParams\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n switchAccount(derivePathParams: DerivePathParams) {\n this.accountManager.switchAccount(derivePathParams);\n }\n\n /**\n * @description Get the address of the account for the given derivePathParams\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n getAddress(derivePathParams?: DerivePathParams) {\n return this.accountManager.getAddress(derivePathParams);\n }\n\n currentAddress() {\n return this.accountManager.currentAddress;\n }\n\n async getBalance(coinType?: string, derivePathParams?: DerivePathParams) {\n const owner = this.accountManager.getAddress(derivePathParams);\n return this.suiInteractor.currentClient.getBalance({ owner, coinType });\n }\n\n client() {\n return this.suiInteractor.currentClient;\n }\n\n async getObjects(objectIds: string[], options?: SuiObjectDataOptions) {\n return this.suiInteractor.getObjects(objectIds, options);\n }\n\n /**\n * @description Update objects in a batch\n * @param suiObjects\n */\n async updateObjects(suiObjects: (SuiSharedObject | SuiOwnedObject)[]) {\n return this.suiInteractor.updateObjects(suiObjects);\n }\n\n async signTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ) {\n if (tx instanceof SuiTxBlock) {\n tx.setSender(this.getAddress(derivePathParams));\n }\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n const txBytes =\n txBlock instanceof TransactionBlock\n ? await txBlock.build({ client: this.client() })\n : txBlock;\n const keyPair = this.getKeypair(derivePathParams);\n return await keyPair.signTransactionBlock(txBytes);\n }\n\n async signAndSendTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<SuiTransactionBlockResponse> {\n const { bytes, signature } = await this.signTxn(tx, derivePathParams);\n return this.suiInteractor.sendTx(bytes, signature);\n }\n\n async dryRunTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<DryRunTransactionBlockResponse> {\n if (tx instanceof SuiTxBlock) {\n tx.setSender(this.getAddress(derivePathParams));\n }\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n const txBytes =\n txBlock instanceof TransactionBlock\n ? await txBlock.build({ client: this.client() })\n : txBlock;\n return this.suiInteractor.dryRunTx(txBytes);\n }\n\n /**\n * Transfer the given amount of SUI to the recipient\n * @param recipient\n * @param amount\n * @param derivePathParams\n */\n async transferSui(\n recipient: string,\n amount: number,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferSui(recipient, amount);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Transfer to mutliple recipients\n * @param recipients the recipients addresses\n * @param amounts the amounts of SUI to transfer to each recipient, the length of amounts should be the same as the length of recipients\n * @param derivePathParams\n */\n async transferSuiToMany(\n recipients: string[],\n amounts: number[],\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferSuiToMany(recipients, amounts);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Transfer the given amounts of coin to multiple recipients\n * @param recipients the list of recipient address\n * @param amounts the amounts to transfer for each recipient\n * @param coinType any custom coin type but not SUI\n * @param derivePathParams the derive path params for the current signer\n */\n async transferCoinToMany(\n recipients: string[],\n amounts: number[],\n coinType: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n const owner = this.accountManager.getAddress(derivePathParams);\n const totalAmount = amounts.reduce((a, b) => a + b, 0);\n const coins = await this.suiInteractor.selectCoins(\n owner,\n totalAmount,\n coinType\n );\n tx.transferCoinToMany(\n coins.map((c) => c.objectId),\n owner,\n recipients,\n amounts\n );\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n async transferCoin(\n recipient: string,\n amount: number,\n coinType: string,\n derivePathParams?: DerivePathParams\n ) {\n return this.transferCoinToMany(\n [recipient],\n [amount],\n coinType,\n derivePathParams\n );\n }\n\n async transferObjects(\n objects: string[],\n recipient: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferObjects(objects, recipient);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n async moveCall(callParams: {\n target: string;\n arguments?: (SuiTxArg | SuiVecTxArg)[];\n typeArguments?: string[];\n derivePathParams?: DerivePathParams;\n }) {\n const {\n target,\n arguments: args = [],\n typeArguments = [],\n derivePathParams,\n } = callParams;\n const tx = new SuiTxBlock();\n tx.moveCall(target, args, typeArguments);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount\n * @param amount\n * @param coinType\n * @param owner\n */\n async selectCoinsWithAmount(\n amount: number,\n coinType: string,\n owner?: string\n ) {\n owner = owner || this.accountManager.currentAddress;\n const coins = await this.suiInteractor.selectCoins(owner, amount, coinType);\n return coins.map((c) => c.objectId);\n }\n\n /**\n * stake the given amount of SUI to the validator\n * @param amount the amount of SUI to stake\n * @param validatorAddr the validator address\n * @param derivePathParams the derive path params for the current signer\n */\n async stakeSui(\n amount: number,\n validatorAddr: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.stakeSui(amount, validatorAddr);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.\n * Since the transaction is not submitted, its gas cost is not charged.\n * @param tx the transaction to execute\n * @param derivePathParams the derive path params\n * @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.\n */\n async inspectTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<DevInspectResults> {\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n return this.suiInteractor.currentClient.devInspectTransactionBlock({\n transactionBlock: txBlock,\n sender: this.getAddress(derivePathParams),\n });\n }\n}\n","import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport { getKeyPair } from './keypair';\nimport { hexOrBase64ToUint8Array, normalizePrivateKey } from './util';\nimport { generateMnemonic } from './crypto';\nimport type { AccountMangerParams, DerivePathParams } from 'src/types';\nimport {\n SUI_PRIVATE_KEY_PREFIX,\n decodeSuiPrivateKey,\n} from '@mysten/sui.js/cryptography';\n\nexport class SuiAccountManager {\n private mnemonics: string;\n private secretKey: string;\n public currentKeyPair: Ed25519Keypair;\n public currentAddress: string;\n\n /**\n * Support the following ways to init the SuiToolkit:\n * 1. mnemonics\n * 2. secretKey (base64 or hex)\n * If none of them is provided, will generate a random mnemonics with 24 words.\n *\n * @param mnemonics, 12 or 24 mnemonics words, separated by space\n * @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored\n */\n constructor({ mnemonics, secretKey }: AccountMangerParams = {}) {\n // If the mnemonics or secretKey is provided, use it\n // Otherwise, generate a random mnemonics with 24 words\n this.mnemonics = mnemonics || '';\n this.secretKey = secretKey || '';\n if (!this.mnemonics && !this.secretKey) {\n this.mnemonics = generateMnemonic(24);\n }\n\n // Init the current account\n this.currentKeyPair = this.secretKey\n ? this.parseSecretKey(this.secretKey)\n : getKeyPair(this.mnemonics);\n this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();\n }\n\n /**\n * Check if the secretKey starts with bench32 format\n */\n parseSecretKey(secretKey: string) {\n if (secretKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {\n const { secretKey: uint8ArraySecretKey } = decodeSuiPrivateKey(secretKey);\n return Ed25519Keypair.fromSecretKey(\n normalizePrivateKey(uint8ArraySecretKey)\n );\n }\n\n return Ed25519Keypair.fromSecretKey(\n normalizePrivateKey(hexOrBase64ToUint8Array(secretKey))\n );\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.\n * else:\n * it will generate keyPair from the mnemonic with the given derivePathParams.\n */\n getKeyPair(derivePathParams?: DerivePathParams) {\n if (!derivePathParams || !this.mnemonics) return this.currentKeyPair;\n return getKeyPair(this.mnemonics, derivePathParams);\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the currentAddress.\n * else:\n * it will generate address from the mnemonic with the given derivePathParams.\n */\n getAddress(derivePathParams?: DerivePathParams) {\n if (!derivePathParams || !this.mnemonics) return this.currentAddress;\n return getKeyPair(this.mnemonics, derivePathParams)\n .getPublicKey()\n .toSuiAddress();\n }\n\n /**\n * Switch the current account with the given derivePathParams.\n * This is only useful when the mnemonics is provided. For secretKey mode, it will always use the same account.\n */\n switchAccount(derivePathParams: DerivePathParams) {\n if (this.mnemonics) {\n this.currentKeyPair = getKeyPair(this.mnemonics, derivePathParams);\n this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();\n }\n }\n}\n","import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport type { DerivePathParams } from 'src/types';\n\n/**\n * @description Get ed25519 derive path for SUI\n * @param derivePathParams\n */\nexport const getDerivePathForSUI = (\n derivePathParams: DerivePathParams = {}\n) => {\n const {\n accountIndex = 0,\n isExternal = false,\n addressIndex = 0,\n } = derivePathParams;\n return `m/44'/784'/${accountIndex}'/${isExternal ? 1 : 0}'/${addressIndex}'`;\n};\n\n/**\n * the format is m/44'/784'/accountIndex'/${isExternal ? 1 : 0}'/addressIndex'\n *\n * accountIndex is the index of the account, default is 0.\n *\n * isExternal is the type of the address, default is false. Usually, the external address is used to receive coins. The internal address is used to change coins.\n *\n * addressIndex is the index of the address, default is 0. It's used to generate multiple addresses for one account.\n *\n * @description Get keypair from mnemonics and derive path\n * @param mnemonics\n * @param derivePathParams\n */\nexport const getKeyPair = (\n mnemonics: string,\n derivePathParams: DerivePathParams = {}\n) => {\n const derivePath = getDerivePathForSUI(derivePathParams);\n return Ed25519Keypair.deriveKeypair(mnemonics, derivePath);\n};\n","import { fromB64 } from '@mysten/sui.js/utils';\n\n/**\n * @description This regular expression matches any string that contains only hexadecimal digits (0-9, A-F, a-f).\n * @param str\n */\nexport const isHex = (str: string) =>\n /^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(str);\n\n/**\n * @description This regular expression matches any string that contains only base64 digits (0-9, A-Z, a-z, +, /, =).\n * Note that the \"=\" signs at the end are optional padding characters that may be present in some base64 encoded strings.\n * @param str\n */\nexport const isBase64 = (str: string) => /^[a-zA-Z0-9+/]+={0,2}$/g.test(str);\n\n/**\n * Convert a hex string to Uint8Array\n * @param hexStr\n */\nexport const fromHEX = (hexStr: string): Uint8Array => {\n if (!hexStr) {\n throw new Error('cannot parse empty string to Uint8Array');\n }\n const intArr = hexStr\n .replace('0x', '')\n .match(/.{1,2}/g)\n ?.map((byte) => parseInt(byte, 16));\n\n if (!intArr || intArr.length === 0) {\n throw new Error(`Unable to parse HEX: ${hexStr}`);\n }\n return Uint8Array.from(intArr);\n};\n\n/**\n * @description Convert a hex or base64 string to Uint8Array\n */\nexport const hexOrBase64ToUint8Array = (str: string): Uint8Array => {\n if (isHex(str)) {\n return fromHEX(str);\n } else if (isBase64(str)) {\n return fromB64(str);\n } else {\n throw new Error('The string is not a valid hex or base64 string.');\n }\n};\n\nconst PRIVATE_KEY_SIZE = 32;\nconst LEGACY_PRIVATE_KEY_SIZE = 64;\n/**\n * normalize a private key\n * A private key is a 32-byte array.\n * But there are two different formats for private keys:\n * 1. A 32-byte array\n * 2. A 64-byte array with the first 32 bytes being the private key and the last 32 bytes being the public key\n * 3. A 33-byte array with the first byte being 0x00 (sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning)\n */\nexport const normalizePrivateKey = (key: Uint8Array): Uint8Array => {\n if (key.length === LEGACY_PRIVATE_KEY_SIZE) {\n // This is a legacy secret key, we need to strip the public key bytes and only read the first 32 bytes\n key = key.slice(0, PRIVATE_KEY_SIZE);\n } else if (key.length === PRIVATE_KEY_SIZE + 1 && key[0] === 0) {\n // sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning\n return key.slice(1);\n } else if (key.length === PRIVATE_KEY_SIZE) {\n return key;\n }\n throw new Error('invalid secret key');\n};\n","import { generateMnemonic as genMnemonic } from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\n\nexport const generateMnemonic = (numberOfWords: 12 | 24 = 24) => {\n const strength = numberOfWords === 12 ? 128 : 256;\n return genMnemonic(wordlist, strength);\n};\n","import { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { SUI_SYSTEM_STATE_OBJECT_ID } from '@mysten/sui.js/utils';\nimport { convertArgs, convertAddressArg, convertObjArg } from './util';\nimport type { SuiClient, SuiObjectRef } from '@mysten/sui.js/client';\nimport type { TransactionObjectArgument } from '@mysten/sui.js/transactions';\nimport type {\n TransactionExpiration,\n SharedObjectRef,\n} from '@mysten/sui.js/bcs';\nimport type { Keypair } from '@mysten/sui.js/cryptography';\nimport type {\n ObjectCallArg,\n TransactionType,\n SuiTxArg,\n SuiAddressArg,\n SuiObjectArg,\n SuiVecTxArg,\n} from 'src/types';\n\nexport class SuiTxBlock {\n public txBlock: TransactionBlock;\n\n constructor(transaction?: TransactionBlock) {\n this.txBlock = new TransactionBlock(transaction);\n }\n\n /* Directly wrap methods and properties of TransactionBlock */\n get gas() {\n return this.txBlock.gas;\n }\n get blockData() {\n return this.txBlock.blockData;\n }\n\n address(value: string) {\n return this.txBlock.pure(value, 'address');\n }\n pure(value: unknown, type?: string) {\n return this.txBlock.pure(value, type);\n }\n object(value: string | ObjectCallArg) {\n return this.txBlock.object(value);\n }\n objectRef(ref: SuiObjectRef) {\n return this.txBlock.objectRef(ref);\n }\n sharedObjectRef(ref: SharedObjectRef) {\n return this.txBlock.sharedObjectRef(ref);\n }\n setSender(sender: string) {\n return this.txBlock.setSender(sender);\n }\n setSenderIfNotSet(sender: string) {\n return this.txBlock.setSenderIfNotSet(sender);\n }\n setExpiration(expiration?: TransactionExpiration) {\n return this.txBlock.setExpiration(expiration);\n }\n setGasPrice(price: number | bigint) {\n return this.txBlock.setGasPrice(price);\n }\n setGasBudget(budget: number | bigint) {\n return this.txBlock.setGasBudget(budget);\n }\n setGasOwner(owner: string) {\n return this.txBlock.setGasOwner(owner);\n }\n setGasPayment(payments: SuiObjectRef[]) {\n return this.txBlock.setGasPayment(payments);\n }\n serialize() {\n return this.txBlock.serialize();\n }\n sign(params: {\n signer: Keypair;\n client?: SuiClient;\n onlyTransactionKind?: boolean;\n }) {\n return this.txBlock.sign(params);\n }\n build(\n params: {\n client?: SuiClient;\n onlyTransactionKind?: boolean;\n } = {}\n ) {\n return this.txBlock.build(params);\n }\n getDigest(params: { client?: SuiClient } = {}) {\n return this.txBlock.getDigest(params);\n }\n add(...args: TransactionType) {\n return this.txBlock.add(...args);\n }\n publish({\n modules,\n dependencies,\n }: {\n modules: number[][] | string[];\n dependencies: string[];\n }) {\n return this.txBlock.publish({ modules, dependencies });\n }\n upgrade({\n modules,\n dependencies,\n packageId,\n ticket,\n }: {\n modules: number[][] | string[];\n dependencies: string[];\n packageId: string;\n ticket: TransactionObjectArgument | string;\n }) {\n return this.txBlock.upgrade({ modules, dependencies, packageId, ticket });\n }\n makeMoveVec({\n objects,\n type,\n }: {\n objects: (TransactionObjectArgument | string)[];\n type?: string;\n }) {\n return this.txBlock.makeMoveVec({ objects, type });\n }\n\n /* Override methods of TransactionBlock */\n\n transferObjects(objects: SuiObjectArg[], address: SuiAddressArg) {\n return this.txBlock.transferObjects(\n objects.map((object) => convertObjArg(this.txBlock, object)),\n convertAddressArg(this.txBlock, address)\n );\n }\n\n splitCoins(coin: SuiObjectArg, amounts: SuiTxArg[]) {\n const res = this.txBlock.splitCoins(\n convertObjArg(this.txBlock, coin),\n convertArgs(this.txBlock, amounts)\n );\n return amounts.map((_, i) => res[i]);\n }\n\n mergeCoins(destination: SuiObjectArg, sources: SuiObjectArg[]) {\n const destinationObject = convertObjArg(this.txBlock, destination);\n const sourceObjects = sources.map((source) =>\n convertObjArg(this.txBlock, source)\n );\n return this.txBlock.mergeCoins(destinationObject, sourceObjects);\n }\n\n /**\n * @description Move call\n * @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`\n * @param args the arguments of the move call, such as `['0x1', '0x2']`\n * @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`\n */\n moveCall(\n target: string,\n args: (SuiTxArg | SuiVecTxArg)[] = [],\n typeArgs: string[] = []\n ) {\n // a regex for pattern `${string}::${string}::${string}`\n const regex =\n /(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/;\n const match = target.match(regex);\n if (match === null)\n throw new Error(\n 'Invalid target format. Expected `${string}::${string}::${string}`'\n );\n const convertedArgs = convertArgs(this.txBlock, args);\n return this.txBlock.moveCall({\n target: target as `${string}::${string}::${string}`,\n arguments: convertedArgs,\n typeArguments: typeArgs,\n });\n }\n\n /* Enhance methods of TransactionBlock */\n\n transferSuiToMany(recipients: SuiAddressArg[], amounts: SuiTxArg[]) {\n // require recipients.length === amounts.length\n if (recipients.length !== amounts.length) {\n throw new Error(\n 'transferSuiToMany: recipients.length !== amounts.length'\n );\n }\n const coins = this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, amounts)\n );\n const recipientObjects = recipients.map((recipient) =>\n convertAddressArg(this.txBlock, recipient)\n );\n recipientObjects.forEach((address, index) => {\n this.txBlock.transferObjects([coins[index]], address);\n });\n return this;\n }\n\n transferSui(address: SuiAddressArg, amount: SuiTxArg) {\n return this.transferSuiToMany([address], [amount]);\n }\n\n takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiTxArg) {\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const mergedCoin = coinObjects[0];\n if (coins.length > 1) {\n this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));\n }\n const [sendCoin] = this.txBlock.splitCoins(\n mergedCoin,\n convertArgs(this.txBlock, [amount])\n );\n return [sendCoin, mergedCoin];\n }\n\n splitSUIFromGas(amounts: SuiTxArg[]) {\n return this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, amounts)\n );\n }\n\n splitMultiCoins(coins: SuiObjectArg[], amounts: SuiTxArg[]) {\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const mergedCoin = coinObjects[0];\n if (coins.length > 1) {\n this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));\n }\n const splitedCoins = this.txBlock.splitCoins(\n mergedCoin,\n convertArgs(this.txBlock, amounts)\n );\n return { splitedCoins, mergedCoin };\n }\n\n transferCoinToMany(\n coins: SuiObjectArg[],\n sender: SuiAddressArg,\n recipients: SuiAddressArg[],\n amounts: SuiTxArg[]\n ) {\n // require recipients.length === amounts.length\n if (recipients.length !== amounts.length) {\n throw new Error(\n 'transferSuiToMany: recipients.length !== amounts.length'\n );\n }\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const { splitedCoins, mergedCoin } = this.splitMultiCoins(\n coinObjects,\n amounts\n );\n const recipientObjects = recipients.map((recipient) =>\n convertAddressArg(this.txBlock, recipient)\n );\n recipientObjects.forEach((address, index) => {\n this.txBlock.transferObjects([splitedCoins[index]], address);\n });\n this.txBlock.transferObjects(\n [mergedCoin],\n convertAddressArg(this.txBlock, sender)\n );\n return this;\n }\n\n transferCoin(\n coins: SuiObjectArg[],\n sender: SuiAddressArg,\n recipient: SuiAddressArg,\n amount: SuiTxArg\n ) {\n return this.transferCoinToMany(coins, sender, [recipient], [amount]);\n }\n\n stakeSui(amount: SuiTxArg, validatorAddr: SuiAddressArg) {\n const [stakeCoin] = this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, [amount])\n );\n return this.txBlock.moveCall({\n target: '0x3::sui_system::request_add_stake',\n arguments: convertArgs(this.txBlock, [\n SUI_SYSTEM_STATE_OBJECT_ID,\n stakeCoin,\n this.txBlock.pure(validatorAddr),\n ]),\n });\n }\n}\n","import {\n normalizeSuiObjectId,\n normalizeSuiAddress,\n isValidSuiObjectId,\n isValidSuiAddress,\n} from '@mysten/sui.js/utils';\nimport { Inputs } from '@mysten/sui.js/transactions';\nimport { isPureArg } from '@mysten/sui.js/bcs';\nimport { isSerializedBcs } from '@mysten/bcs';\nimport type {\n TransactionArgument,\n TransactionBlock,\n TransactionObjectArgument,\n} from '@mysten/sui.js/transactions';\nimport type {\n SuiInputTypes,\n SuiObjectArg,\n SuiAddressArg,\n SuiTxArg,\n SuiVecTxArg,\n} from 'src/types';\n\nexport const getDefaultSuiInputType = (\n value: SuiTxArg\n): SuiInputTypes | undefined => {\n if (typeof value === 'string' && isValidSuiObjectId(value)) {\n return 'object';\n } else if (typeof value === 'number' || typeof value === 'bigint') {\n return 'u64';\n } else if (typeof value === 'boolean') {\n return 'bool';\n } else {\n return undefined;\n }\n};\n\n/**\n * Since we know the elements in the array are the same type\n * If type is not provided, we will try to infer the type from the first element\n * By default,\n *\n * string is hex and its length equal to 32 =====> object id\n * number, bigint ====> u64\n * boolean =====> bool\n *\n * If type is provided, we will use the type to convert the array\n * @param args\n * @param type 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256' | 'signer' | 'object' | string\n */\nexport function makeVecParam(\n txBlock: TransactionBlock,\n args: SuiTxArg[],\n type?: SuiInputTypes\n): TransactionArgument {\n if (args.length === 0)\n throw new Error('Transaction builder error: Empty array is not allowed');\n // Using first element value as default type\n const defaultSuiType = getDefaultSuiInputType(args[0]);\n const VECTOR_REGEX = /^vector<(.+)>$/;\n const STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;\n\n type = type || defaultSuiType;\n\n if (type === 'object') {\n const objects = args.map((arg) =>\n typeof arg === 'string' && isValidSuiObjectId(arg)\n ? txBlock.object(normalizeSuiObjectId(arg))\n : convertObjArg(txBlock, arg as SuiObjectArg)\n );\n return txBlock.makeMoveVec({ objects });\n } else if (\n typeof type === 'string' &&\n !VECTOR_REGEX.test(type) &&\n !STRUCT_REGEX.test(type)\n ) {\n return txBlock.pure(args, `vector<${type}>`);\n } else {\n const objects = args.map((arg) =>\n convertObjArg(txBlock, arg as SuiObjectArg)\n );\n return txBlock.makeMoveVec({ objects, type });\n }\n}\n\n/**\n * Check whether it is an valid move vec input.\n *\n * @param arg The argument to check.\n * @returns boolean.\n */\nexport function isMoveVecArg(arg: SuiTxArg | SuiVecTxArg): arg is SuiVecTxArg {\n if (typeof arg === 'object' && 'vecType' in arg && 'value' in arg) {\n return true;\n } else if (Array.isArray(arg)) {\n return true;\n }\n return false;\n}\n\n/**\n * Convert any valid input into array of TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param args The array of argument to convert.\n * @returns The converted array of TransactionArgument.\n */\nexport function convertArgs(\n txBlock: TransactionBlock,\n args: (SuiTxArg | SuiVecTxArg)[]\n) {\n return args.map((arg) => {\n if (typeof arg === 'string' && isValidSuiObjectId(arg)) {\n return txBlock.object(normalizeSuiObjectId(arg));\n } else if (\n typeof arg == 'object' &&\n !isSerializedBcs(arg) &&\n !isPureArg(arg) &&\n !isMoveVecArg(arg)\n ) {\n return convertObjArg(txBlock, arg as SuiObjectArg);\n } else if (isMoveVecArg(arg)) {\n const vecType = 'vecType' in arg;\n return vecType\n ? makeVecParam(txBlock, arg.value, arg.vecType)\n : makeVecParam(txBlock, arg);\n } else if (isSerializedBcs(arg)) {\n return arg;\n } else {\n return txBlock.pure(arg);\n }\n });\n}\n\n/**\n * Convert any valid address input into a TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param arg The address argument to convert.\n * @returns The converted TransactionArgument.\n */\nexport function convertAddressArg(\n txBlock: TransactionBlock,\n arg: SuiAddressArg\n) {\n if (typeof arg === 'string' && isValidSuiAddress(arg)) {\n return txBlock.pure.address(normalizeSuiAddress(arg));\n } else if (\n typeof arg == 'object' &&\n !isSerializedBcs(arg) &&\n !isPureArg(arg)\n ) {\n return convertObjArg(txBlock, arg as SuiObjectArg);\n } else if (isPureArg(arg)) {\n return txBlock.pure(arg);\n } else {\n return arg;\n }\n}\n\n/**\n * Convert any valid object input into a TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param arg The object argument to convert.\n * @returns The converted TransactionArgument.\n */\nexport function convertObjArg(\n txb: TransactionBlock,\n arg: SuiObjectArg\n): TransactionObjectArgument {\n if (typeof arg === 'string') {\n return txb.object(arg);\n }\n\n if ('digest' in arg && 'version' in arg && 'objectId' in arg) {\n return txb.objectRef(arg);\n }\n\n if ('objectId' in arg && 'initialSharedVersion' in arg && 'mutable' in arg) {\n return txb.sharedObjectRef(arg);\n }\n\n if ('Object' in arg) {\n if ('ImmOrOwned' in arg.Object) {\n return txb.object(Inputs.ObjectRef(arg.Object.ImmOrOwned));\n } else if ('Shared' in arg.Object) {\n return txb.object(Inputs.SharedObjectRef(arg.Object.Shared));\n } else {\n throw new Error('Invalid argument type');\n }\n }\n\n if ('kind' in arg) {\n return arg;\n }\n\n throw new Error('Invalid argument type');\n}\n","import { SuiClient } from '@mysten/sui.js/client';\nimport { SuiOwnedObject, SuiSharedObject } from '../suiModel';\nimport { delay } from './util';\nimport type {\n SuiTransactionBlockResponseOptions,\n SuiTransactionBlockResponse,\n SuiObjectDataOptions,\n SuiObjectData,\n DryRunTransactionBlockResponse,\n} from '@mysten/sui.js/client';\n\n/**\n * Encapsulates all functions that interact with the sui sdk\n */\nexport class SuiInteractor {\n public readonly clients: SuiClient[];\n public currentClient: SuiClient;\n public readonly fullNodes: string[];\n public currentFullNode: string;\n\n constructor(fullNodeUrls: string[]) {\n if (fullNodeUrls.length === 0)\n throw new Error('fullNodeUrls must not be empty');\n this.fullNodes = fullNodeUrls;\n this.clients = fullNodeUrls.map((url) => new SuiClient({ url }));\n this.currentFullNode = fullNodeUrls[0];\n this.currentClient = this.clients[0];\n }\n\n switchToNextClient() {\n const currentClientIdx = this.clients.indexOf(this.currentClient);\n this.currentClient =\n this.clients[(currentClientIdx + 1) % this.clients.length];\n this.currentFullNode =\n this.fullNodes[(currentClientIdx + 1) % this.clients.length];\n }\n\n async sendTx(\n transactionBlock: Uint8Array | string,\n signature: string | string[]\n ): Promise<SuiTransactionBlockResponse> {\n const txResOptions: SuiTransactionBlockResponseOptions = {\n showEvents: true,\n showEffects: true,\n showObjectChanges: true,\n showBalanceChanges: true,\n };\n\n for (const clientIdx in this.clients) {\n try {\n return await this.clients[clientIdx].executeTransactionBlock({\n transactionBlock,\n signature,\n options: txResOptions,\n });\n } catch (err) {\n console.warn(\n `Failed to send transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n await delay(2000);\n }\n }\n throw new Error('Failed to send transaction with all fullnodes');\n }\n\n async dryRunTx(\n transactionBlock: Uint8Array\n ): Promise<DryRunTransactionBlockResponse> {\n for (const clientIdx in this.clients) {\n try {\n return await this.clients[clientIdx].dryRunTransactionBlock({\n transactionBlock,\n });\n } catch (err) {\n console.warn(\n `Failed to dry run transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n await delay(2000);\n }\n }\n throw new Error('Failed to dry run transaction with all fullnodes');\n }\n\n async getObjects(\n ids: string[],\n options?: SuiObjectDataOptions\n ): Promise<SuiObjectData[]> {\n const opts: SuiObjectDataOptions = options ?? {\n showContent: true,\n showDisplay: true,\n showType: true,\n showOwner: true,\n };\n\n for (const clientIdx in this.clients) {\n try {\n const objects = await this.clients[clientIdx].multiGetObjects({\n ids,\n options: opts,\n });\n const parsedObjects = objects\n .map((object) => {\n return object.data;\n })\n .filter((object) => object !== null && object !== undefined);\n return parsedObjects as SuiObjectData[];\n } catch (err) {\n await delay(2000);\n console.warn(\n `Failed to get objects with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n }\n }\n throw new Error('Failed to get objects with all fullnodes');\n }\n\n async getObject(id: string, options?: SuiObjectDataOptions) {\n const objects = await this.getObjects([id], options);\n return objects[0];\n }\n\n /**\n * @description Update objects in a batch\n * @param suiObjects\n */\n async updateObjects(suiObjects: (SuiOwnedObject | SuiSharedObject)[]) {\n const objectIds = suiObjects.map((obj) => obj.objectId);\n const objects = await this.getObjects(objectIds);\n for (const object of objects) {\n const suiObject = suiObjects.find(\n (obj) => obj.objectId === object?.objectId\n );\n if (suiObject instanceof SuiSharedObject) {\n if (\n object.owner &&\n typeof object.owner === 'object' &&\n 'Shared' in object.owner\n ) {\n suiObject.initialSharedVersion =\n object.owner.Shared.initial_shared_version;\n } else {\n suiObject.initialSharedVersion = undefined;\n }\n } else if (suiObject instanceof SuiOwnedObject) {\n suiObject.version = object?.version;\n suiObject.digest = object?.digest;\n }\n }\n }\n\n /**\n * @description Select coins that add up to the given amount.\n * @param addr the address of the owner\n * @param amount the amount that is needed for the coin\n * @param coinType the coin type, default is '0x2::SUI::SUI'\n */\n async selectCoins(\n addr: string,\n amount: number,\n coinType: string = '0x2::SUI::SUI'\n ) {\n const selectedCoins: {\n objectId: string;\n digest: string;\n version: string;\n }[] = [];\n let totalAmount = 0;\n let hasNext = true,\n nextCursor: string | null | undefined = null;\n while (hasNext && totalAmount < amount) {\n const coins = await this.currentClient.getCoins({\n owner: addr,\n coinType: coinType,\n cursor: nextCursor,\n });\n // Sort the coins by balance in descending order\n coins.data.sort((a, b) => parseInt(b.balance) - parseInt(a.balance));\n for (const coinData of coins.data) {\n selectedCoins.push({\n objectId: coinData.coinObjectId,\n digest: coinData.digest,\n version: coinData.version,\n });\n totalAmount = totalAmount + parseInt(coinData.balance);\n if (totalAmount >= amount) {\n break;\n }\n }\n\n nextCursor = coins.nextCursor;\n hasNext = coins.hasNextPage;\n }\n\n if (!selectedCoins.length) {\n throw new Error('No valid coins found for the transaction.');\n }\n return selectedCoins;\n }\n}\n","import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';\nimport type { CallArg } from '@mysten/sui.js/bcs';\n\nexport class SuiOwnedObject {\n public readonly objectId: string;\n public version?: string;\n public digest?: string;\n\n constructor(param: { objectId: string; version?: string; digest?: string }) {\n this.objectId = param.objectId;\n this.version = param.version;\n this.digest = param.digest;\n }\n\n /**\n * Check if the object is fully initialized.\n * So that when it's used as an input, it won't be necessary to fetch from fullnode again.\n * Which can save time when sending transactions.\n */\n isFullObject(): boolean {\n return !!this.version && !!this.digest;\n }\n\n asCallArg(): CallArg | string {\n if (!this.version || !this.digest) {\n return this.objectId;\n }\n return {\n Object: {\n ImmOrOwned: {\n objectId: this.objectId,\n version: this.version,\n digest: this.digest,\n },\n },\n };\n }\n\n /**\n * Update object version & digest based on the transaction response.\n * @param txResponse\n */\n updateFromTxResponse(txResponse: SuiTransactionBlockResponse) {\n const changes = txResponse.objectChanges;\n if (!changes) {\n throw new Error('Bad transaction response!');\n }\n for (const change of changes) {\n if (change.type === 'mutated' && change.objectId === this.objectId) {\n this.digest = change.digest;\n this.version = change.version;\n return;\n }\n }\n throw new Error('Could not find object in transaction response!');\n }\n}\n","import type { CallArg } from '@mysten/sui.js/bcs';\n\nexport class SuiSharedObject {\n public readonly objectId: string;\n public initialSharedVersion?: string;\n\n constructor(param: {\n objectId: string;\n initialSharedVersion?: string;\n mutable?: boolean;\n }) {\n this.objectId = param.objectId;\n this.initialSharedVersion = param.initialSharedVersion;\n }\n\n asCallArg(mutable: boolean = false): CallArg | string {\n if (!this.initialSharedVersion) {\n return this.objectId;\n }\n return {\n Object: {\n Shared: {\n objectId: this.objectId,\n initialSharedVersion: this.initialSharedVersion,\n mutable,\n },\n },\n };\n }\n}\n","export const delay = (ms: number) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n","import { MultiSigPublicKey } from '@mysten/sui.js/multisig';\nimport type { PublicKey } from '@mysten/sui.js/src/cryptography';\nimport { ed25519PublicKeyFromBase64 } from './publickey';\n\nexport type PublicKeyWeightPair = {\n publicKey: PublicKey;\n weight: number;\n};\n\nexport class MultiSigClient {\n public readonly pksWeightPairs: PublicKeyWeightPair[];\n public readonly threshold: number;\n public readonly multiSigPublicKey: MultiSigPublicKey;\n constructor(pks: PublicKeyWeightPair[], threshold: number) {\n this.pksWeightPairs = pks;\n this.threshold = threshold;\n this.multiSigPublicKey = MultiSigPublicKey.fromPublicKeys({\n threshold: this.threshold,\n publicKeys: this.pksWeightPairs,\n });\n }\n\n static fromRawEd25519PublicKeys(\n rawPublicKeys: string[],\n weights: number[],\n threshold: number\n ): MultiSigClient {\n const pks = rawPublicKeys.map((rawPublicKey, i) => {\n return {\n publicKey: ed25519PublicKeyFromBase64(rawPublicKey),\n weight: weights[i],\n };\n });\n return new MultiSigClient(pks, threshold);\n }\n\n multiSigAddress(): string {\n return this.multiSigPublicKey.toSuiAddress();\n }\n\n combinePartialSigs(sigs: string[]): string {\n return this.multiSigPublicKey.combinePartialSignatures(sigs);\n }\n}\n","import { PublicKey } from '@mysten/sui.js/cryptography';\nimport { Ed25519PublicKey } from '@mysten/sui.js/keypairs/ed25519';\nimport { fromB64 } from '@mysten/sui.js/utils';\n\nexport function ed25519PublicKeyFromBase64(rawPubkey: string): PublicKey {\n let bytes = fromB64(rawPubkey);\n // rawPubkeys should either be 32 bytes or 33 bytes (with the first byte being flag)\n if (bytes.length !== 32 && bytes.length !== 33) throw 'invalid pubkey length';\n bytes = bytes.length === 33 ? bytes.slice(1) : bytes;\n return new Ed25519PublicKey(bytes);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAc,iCAAd;AACA,wBAAc,wCADd;;;ACGA,IAAAA,iBAA+B;AAC/B,IAAAC,uBAAiC;;;ACJjC,IAAAC,kBAA+B;;;ACA/B,qBAA+B;AAOxB,IAAM,sBAAsB,CACjC,mBAAqC,CAAC,MACnC;AACH,QAAM;AAAA,IACJ,eAAe;AAAA,IACf,aAAa;AAAA,IACb,eAAe;AAAA,EACjB,IAAI;AACJ,SAAO,cAAc,YAAY,KAAK,aAAa,IAAI,CAAC,KAAK,YAAY;AAC3E;AAeO,IAAM,aAAa,CACxB,WACA,mBAAqC,CAAC,MACnC;AACH,QAAM,aAAa,oBAAoB,gBAAgB;AACvD,SAAO,8BAAe,cAAc,WAAW,UAAU;AAC3D;;;ACrCA,mBAAwB;AAMjB,IAAM,QAAQ,CAAC,QACpB,kCAAkC,KAAK,GAAG;AAOrC,IAAM,WAAW,CAAC,QAAgB,0BAA0B,K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MAAM,WAAW,KAAK,MAAM,MAAM,CAAC,IAAI;AAC/C,SAAO,IAAI,iCAAiB,KAAK;AACnC;;;ADDO,IAAM,iBAAN,MAAM,gBAAe;AAAA,EAI1B,YAAY,KAA4B,WAAmB;AACzD,SAAK,iBAAiB;AACtB,SAAK,YAAY;AACjB,SAAK,oBAAoB,kCAAkB,eAAe;AAAA,MACxD,WAAW,KAAK;AAAA,MAChB,YAAY,KAAK;AAAA,IACnB,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,yBACL,eACA,SACA,WACgB;AAChB,UAAM,MAAM,cAAc,IAAI,CAAC,cAAc,MAAM;AACjD,aAAO;AAAA,QACL,WAAW,2BAA2B,YAAY;AAAA,QAClD,QAAQ,QAAQ,CAAC;AAAA,MACnB;AAAA,IACF,CAAC;AACD,WAAO,IAAI,gBAAe,KAAK,SAAS;AAAA,EAC1C;AAAA,EAEA,kBAA0B;AACxB,WAAO,KAAK,kBAAkB,aAAa;AAAA,EAC7C;AAAA,EAEA,mBAAmB,MAAwB;AACzC,WAAO,KAAK,kBAAkB,yBAAyB,IAAI;AAAA,EAC7D;AACF;","names":["import_client","import_transactions","import_ed25519","genMnemonic","import_transactions","import_utils","import_utils","import_bcs","import_ed25519","import_utils"]}
|
package/dist/index.mjs
CHANGED
|
@@ -69,6 +69,10 @@ var generateMnemonic = (numberOfWords = 24) => {
|
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
// src/libs/suiAccountManager/index.ts
|
|
72
|
+
import {
|
|
73
|
+
SUI_PRIVATE_KEY_PREFIX,
|
|
74
|
+
decodeSuiPrivateKey
|
|
75
|
+
} from "@mysten/sui.js/cryptography";
|
|
72
76
|
var SuiAccountManager = class {
|
|
73
77
|
/**
|
|
74
78
|
* Support the following ways to init the SuiToolkit:
|
|
@@ -77,7 +81,7 @@ var SuiAccountManager = class {
|
|
|
77
81
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
78
82
|
*
|
|
79
83
|
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
80
|
-
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
|
|
84
|
+
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored
|
|
81
85
|
*/
|
|
82
86
|
constructor({ mnemonics, secretKey } = {}) {
|
|
83
87
|
this.mnemonics = mnemonics || "";
|
|
@@ -85,11 +89,23 @@ var SuiAccountManager = class {
|
|
|
85
89
|
if (!this.mnemonics && !this.secretKey) {
|
|
86
90
|
this.mnemonics = generateMnemonic(24);
|
|
87
91
|
}
|
|
88
|
-
this.currentKeyPair = this.secretKey ?
|
|
89
|
-
normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey))
|
|
90
|
-
) : getKeyPair(this.mnemonics);
|
|
92
|
+
this.currentKeyPair = this.secretKey ? this.parseSecretKey(this.secretKey) : getKeyPair(this.mnemonics);
|
|
91
93
|
this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();
|
|
92
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if the secretKey starts with bench32 format
|
|
97
|
+
*/
|
|
98
|
+
parseSecretKey(secretKey) {
|
|
99
|
+
if (secretKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {
|
|
100
|
+
const { secretKey: uint8ArraySecretKey } = decodeSuiPrivateKey(secretKey);
|
|
101
|
+
return Ed25519Keypair2.fromSecretKey(
|
|
102
|
+
normalizePrivateKey(uint8ArraySecretKey)
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return Ed25519Keypair2.fromSecretKey(
|
|
106
|
+
normalizePrivateKey(hexOrBase64ToUint8Array(secretKey))
|
|
107
|
+
);
|
|
108
|
+
}
|
|
93
109
|
/**
|
|
94
110
|
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.
|
|
95
111
|
* else:
|
|
@@ -676,7 +692,7 @@ var SuiKit = class {
|
|
|
676
692
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
677
693
|
*
|
|
678
694
|
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
679
|
-
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
|
|
695
|
+
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored
|
|
680
696
|
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'
|
|
681
697
|
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
|
|
682
698
|
*/
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/suiKit.ts","../src/libs/suiAccountManager/index.ts","../src/libs/suiAccountManager/keypair.ts","../src/libs/suiAccountManager/util.ts","../src/libs/suiAccountManager/crypto.ts","../src/libs/suiTxBuilder/index.ts","../src/libs/suiTxBuilder/util.ts","../src/libs/suiInteractor/suiInteractor.ts","../src/libs/suiModel/suiOwnedObject.ts","../src/libs/suiModel/suiSharedObject.ts","../src/libs/suiInteractor/util.ts","../src/libs/multiSig/client.ts","../src/libs/multiSig/publickey.ts"],"sourcesContent":["export * from '@mysten/sui.js/utils';\nexport * from '@mysten/sui.js/transactions';\nexport { SuiKit } from './suiKit';\nexport { SuiAccountManager } from './libs/suiAccountManager';\nexport { SuiTxBlock } from './libs/suiTxBuilder';\nexport { MultiSigClient } from './libs/multiSig';\nexport type * from './types';\n","/**\n * @description This file is used to aggregate the tools that used to interact with SUI network.\n */\nimport { getFullnodeUrl } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { SuiAccountManager } from './libs/suiAccountManager';\nimport { SuiTxBlock } from './libs/suiTxBuilder';\nimport { SuiInteractor } from './libs/suiInteractor';\nimport type {\n SuiTransactionBlockResponse,\n DevInspectResults,\n SuiObjectDataOptions,\n DryRunTransactionBlockResponse,\n} from '@mysten/sui.js/client';\nimport type { SuiSharedObject, SuiOwnedObject } from './libs/suiModel';\nimport type {\n SuiKitParams,\n DerivePathParams,\n SuiTxArg,\n SuiVecTxArg,\n} from './types';\n\n/**\n * @class SuiKit\n * @description This class is used to aggregate the tools that used to interact with SUI network.\n */\nexport class SuiKit {\n public accountManager: SuiAccountManager;\n public suiInteractor: SuiInteractor;\n\n /**\n * Support the following ways to init the SuiToolkit:\n * 1. mnemonics\n * 2. secretKey (base64 or hex)\n * If none of them is provided, will generate a random mnemonics with 24 words.\n *\n * @param mnemonics, 12 or 24 mnemonics words, separated by space\n * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored\n * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'\n * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type\n */\n constructor({\n mnemonics,\n secretKey,\n networkType,\n fullnodeUrls,\n }: SuiKitParams = {}) {\n // Init the account manager\n this.accountManager = new SuiAccountManager({ mnemonics, secretKey });\n // Init the sui interactor\n fullnodeUrls = fullnodeUrls || [getFullnodeUrl(networkType ?? 'mainnet')];\n this.suiInteractor = new SuiInteractor(fullnodeUrls);\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the keypair.\n * else:\n * it will generate signer from the mnemonic with the given derivePathParams.\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n getKeypair(derivePathParams?: DerivePathParams) {\n return this.accountManager.getKeyPair(derivePathParams);\n }\n\n /**\n * @description Switch the current account with the given derivePathParams\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n switchAccount(derivePathParams: DerivePathParams) {\n this.accountManager.switchAccount(derivePathParams);\n }\n\n /**\n * @description Get the address of the account for the given derivePathParams\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n getAddress(derivePathParams?: DerivePathParams) {\n return this.accountManager.getAddress(derivePathParams);\n }\n\n currentAddress() {\n return this.accountManager.currentAddress;\n }\n\n async getBalance(coinType?: string, derivePathParams?: DerivePathParams) {\n const owner = this.accountManager.getAddress(derivePathParams);\n return this.suiInteractor.currentClient.getBalance({ owner, coinType });\n }\n\n client() {\n return this.suiInteractor.currentClient;\n }\n\n async getObjects(objectIds: string[], options?: SuiObjectDataOptions) {\n return this.suiInteractor.getObjects(objectIds, options);\n }\n\n /**\n * @description Update objects in a batch\n * @param suiObjects\n */\n async updateObjects(suiObjects: (SuiSharedObject | SuiOwnedObject)[]) {\n return this.suiInteractor.updateObjects(suiObjects);\n }\n\n async signTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ) {\n if (tx instanceof SuiTxBlock) {\n tx.setSender(this.getAddress(derivePathParams));\n }\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n const txBytes =\n txBlock instanceof TransactionBlock\n ? await txBlock.build({ client: this.client() })\n : txBlock;\n const keyPair = this.getKeypair(derivePathParams);\n return await keyPair.signTransactionBlock(txBytes);\n }\n\n async signAndSendTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<SuiTransactionBlockResponse> {\n const { bytes, signature } = await this.signTxn(tx, derivePathParams);\n return this.suiInteractor.sendTx(bytes, signature);\n }\n\n async dryRunTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<DryRunTransactionBlockResponse> {\n if (tx instanceof SuiTxBlock) {\n tx.setSender(this.getAddress(derivePathParams));\n }\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n const txBytes =\n txBlock instanceof TransactionBlock\n ? await txBlock.build({ client: this.client() })\n : txBlock;\n return this.suiInteractor.dryRunTx(txBytes);\n }\n\n /**\n * Transfer the given amount of SUI to the recipient\n * @param recipient\n * @param amount\n * @param derivePathParams\n */\n async transferSui(\n recipient: string,\n amount: number,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferSui(recipient, amount);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Transfer to mutliple recipients\n * @param recipients the recipients addresses\n * @param amounts the amounts of SUI to transfer to each recipient, the length of amounts should be the same as the length of recipients\n * @param derivePathParams\n */\n async transferSuiToMany(\n recipients: string[],\n amounts: number[],\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferSuiToMany(recipients, amounts);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Transfer the given amounts of coin to multiple recipients\n * @param recipients the list of recipient address\n * @param amounts the amounts to transfer for each recipient\n * @param coinType any custom coin type but not SUI\n * @param derivePathParams the derive path params for the current signer\n */\n async transferCoinToMany(\n recipients: string[],\n amounts: number[],\n coinType: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n const owner = this.accountManager.getAddress(derivePathParams);\n const totalAmount = amounts.reduce((a, b) => a + b, 0);\n const coins = await this.suiInteractor.selectCoins(\n owner,\n totalAmount,\n coinType\n );\n tx.transferCoinToMany(\n coins.map((c) => c.objectId),\n owner,\n recipients,\n amounts\n );\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n async transferCoin(\n recipient: string,\n amount: number,\n coinType: string,\n derivePathParams?: DerivePathParams\n ) {\n return this.transferCoinToMany(\n [recipient],\n [amount],\n coinType,\n derivePathParams\n );\n }\n\n async transferObjects(\n objects: string[],\n recipient: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferObjects(objects, recipient);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n async moveCall(callParams: {\n target: string;\n arguments?: (SuiTxArg | SuiVecTxArg)[];\n typeArguments?: string[];\n derivePathParams?: DerivePathParams;\n }) {\n const {\n target,\n arguments: args = [],\n typeArguments = [],\n derivePathParams,\n } = callParams;\n const tx = new SuiTxBlock();\n tx.moveCall(target, args, typeArguments);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount\n * @param amount\n * @param coinType\n * @param owner\n */\n async selectCoinsWithAmount(\n amount: number,\n coinType: string,\n owner?: string\n ) {\n owner = owner || this.accountManager.currentAddress;\n const coins = await this.suiInteractor.selectCoins(owner, amount, coinType);\n return coins.map((c) => c.objectId);\n }\n\n /**\n * stake the given amount of SUI to the validator\n * @param amount the amount of SUI to stake\n * @param validatorAddr the validator address\n * @param derivePathParams the derive path params for the current signer\n */\n async stakeSui(\n amount: number,\n validatorAddr: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.stakeSui(amount, validatorAddr);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.\n * Since the transaction is not submitted, its gas cost is not charged.\n * @param tx the transaction to execute\n * @param derivePathParams the derive path params\n * @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.\n */\n async inspectTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<DevInspectResults> {\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n return this.suiInteractor.currentClient.devInspectTransactionBlock({\n transactionBlock: txBlock,\n sender: this.getAddress(derivePathParams),\n });\n }\n}\n","import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport { getKeyPair } from './keypair';\nimport { hexOrBase64ToUint8Array, normalizePrivateKey } from './util';\nimport { generateMnemonic } from './crypto';\nimport type { AccountMangerParams, DerivePathParams } from 'src/types';\n\nexport class SuiAccountManager {\n private mnemonics: string;\n private secretKey: string;\n public currentKeyPair: Ed25519Keypair;\n public currentAddress: string;\n\n /**\n * Support the following ways to init the SuiToolkit:\n * 1. mnemonics\n * 2. secretKey (base64 or hex)\n * If none of them is provided, will generate a random mnemonics with 24 words.\n *\n * @param mnemonics, 12 or 24 mnemonics words, separated by space\n * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored\n */\n constructor({ mnemonics, secretKey }: AccountMangerParams = {}) {\n // If the mnemonics or secretKey is provided, use it\n // Otherwise, generate a random mnemonics with 24 words\n this.mnemonics = mnemonics || '';\n this.secretKey = secretKey || '';\n if (!this.mnemonics && !this.secretKey) {\n this.mnemonics = generateMnemonic(24);\n }\n\n // Init the current account\n this.currentKeyPair = this.secretKey\n ? Ed25519Keypair.fromSecretKey(\n normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey))\n )\n : getKeyPair(this.mnemonics);\n this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.\n * else:\n * it will generate keyPair from the mnemonic with the given derivePathParams.\n */\n getKeyPair(derivePathParams?: DerivePathParams) {\n if (!derivePathParams || !this.mnemonics) return this.currentKeyPair;\n return getKeyPair(this.mnemonics, derivePathParams);\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the currentAddress.\n * else:\n * it will generate address from the mnemonic with the given derivePathParams.\n */\n getAddress(derivePathParams?: DerivePathParams) {\n if (!derivePathParams || !this.mnemonics) return this.currentAddress;\n return getKeyPair(this.mnemonics, derivePathParams)\n .getPublicKey()\n .toSuiAddress();\n }\n\n /**\n * Switch the current account with the given derivePathParams.\n * This is only useful when the mnemonics is provided. For secretKey mode, it will always use the same account.\n */\n switchAccount(derivePathParams: DerivePathParams) {\n if (this.mnemonics) {\n this.currentKeyPair = getKeyPair(this.mnemonics, derivePathParams);\n this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();\n }\n }\n}\n","import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport type { DerivePathParams } from 'src/types';\n\n/**\n * @description Get ed25519 derive path for SUI\n * @param derivePathParams\n */\nexport const getDerivePathForSUI = (\n derivePathParams: DerivePathParams = {}\n) => {\n const {\n accountIndex = 0,\n isExternal = false,\n addressIndex = 0,\n } = derivePathParams;\n return `m/44'/784'/${accountIndex}'/${isExternal ? 1 : 0}'/${addressIndex}'`;\n};\n\n/**\n * the format is m/44'/784'/accountIndex'/${isExternal ? 1 : 0}'/addressIndex'\n *\n * accountIndex is the index of the account, default is 0.\n *\n * isExternal is the type of the address, default is false. Usually, the external address is used to receive coins. The internal address is used to change coins.\n *\n * addressIndex is the index of the address, default is 0. It's used to generate multiple addresses for one account.\n *\n * @description Get keypair from mnemonics and derive path\n * @param mnemonics\n * @param derivePathParams\n */\nexport const getKeyPair = (\n mnemonics: string,\n derivePathParams: DerivePathParams = {}\n) => {\n const derivePath = getDerivePathForSUI(derivePathParams);\n return Ed25519Keypair.deriveKeypair(mnemonics, derivePath);\n};\n","import { fromB64 } from '@mysten/sui.js/utils';\n\n/**\n * @description This regular expression matches any string that contains only hexadecimal digits (0-9, A-F, a-f).\n * @param str\n */\nexport const isHex = (str: string) =>\n /^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(str);\n\n/**\n * @description This regular expression matches any string that contains only base64 digits (0-9, A-Z, a-z, +, /, =).\n * Note that the \"=\" signs at the end are optional padding characters that may be present in some base64 encoded strings.\n * @param str\n */\nexport const isBase64 = (str: string) => /^[a-zA-Z0-9+/]+={0,2}$/g.test(str);\n\n/**\n * Convert a hex string to Uint8Array\n * @param hexStr\n */\nexport const fromHEX = (hexStr: string): Uint8Array => {\n if (!hexStr) {\n throw new Error('cannot parse empty string to Uint8Array');\n }\n const intArr = hexStr\n .replace('0x', '')\n .match(/.{1,2}/g)\n ?.map((byte) => parseInt(byte, 16));\n\n if (!intArr || intArr.length === 0) {\n throw new Error(`Unable to parse HEX: ${hexStr}`);\n }\n return Uint8Array.from(intArr);\n};\n\n/**\n * @description Convert a hex or base64 string to Uint8Array\n */\nexport const hexOrBase64ToUint8Array = (str: string): Uint8Array => {\n if (isHex(str)) {\n return fromHEX(str);\n } else if (isBase64(str)) {\n return fromB64(str);\n } else {\n throw new Error('The string is not a valid hex or base64 string.');\n }\n};\n\nconst PRIVATE_KEY_SIZE = 32;\nconst LEGACY_PRIVATE_KEY_SIZE = 64;\n/**\n * normalize a private key\n * A private key is a 32-byte array.\n * But there are two different formats for private keys:\n * 1. A 32-byte array\n * 2. A 64-byte array with the first 32 bytes being the private key and the last 32 bytes being the public key\n * 3. A 33-byte array with the first byte being 0x00 (sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning)\n */\nexport const normalizePrivateKey = (key: Uint8Array): Uint8Array => {\n if (key.length === LEGACY_PRIVATE_KEY_SIZE) {\n // This is a legacy secret key, we need to strip the public key bytes and only read the first 32 bytes\n key = key.slice(0, PRIVATE_KEY_SIZE);\n } else if (key.length === PRIVATE_KEY_SIZE + 1 && key[0] === 0) {\n // sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning\n return key.slice(1);\n } else if (key.length === PRIVATE_KEY_SIZE) {\n return key;\n }\n throw new Error('invalid secret key');\n};\n","import { generateMnemonic as genMnemonic } from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\n\nexport const generateMnemonic = (numberOfWords: 12 | 24 = 24) => {\n const strength = numberOfWords === 12 ? 128 : 256;\n return genMnemonic(wordlist, strength);\n};\n","import { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { SUI_SYSTEM_STATE_OBJECT_ID } from '@mysten/sui.js/utils';\nimport { convertArgs, convertAddressArg, convertObjArg } from './util';\nimport type { SuiClient, SuiObjectRef } from '@mysten/sui.js/client';\nimport type { TransactionObjectArgument } from '@mysten/sui.js/transactions';\nimport type {\n TransactionExpiration,\n SharedObjectRef,\n} from '@mysten/sui.js/bcs';\nimport type { Keypair } from '@mysten/sui.js/cryptography';\nimport type {\n ObjectCallArg,\n TransactionType,\n SuiTxArg,\n SuiAddressArg,\n SuiObjectArg,\n SuiVecTxArg,\n} from 'src/types';\n\nexport class SuiTxBlock {\n public txBlock: TransactionBlock;\n\n constructor(transaction?: TransactionBlock) {\n this.txBlock = new TransactionBlock(transaction);\n }\n\n /* Directly wrap methods and properties of TransactionBlock */\n get gas() {\n return this.txBlock.gas;\n }\n get blockData() {\n return this.txBlock.blockData;\n }\n\n address(value: string) {\n return this.txBlock.pure(value, 'address');\n }\n pure(value: unknown, type?: string) {\n return this.txBlock.pure(value, type);\n }\n object(value: string | ObjectCallArg) {\n return this.txBlock.object(value);\n }\n objectRef(ref: SuiObjectRef) {\n return this.txBlock.objectRef(ref);\n }\n sharedObjectRef(ref: SharedObjectRef) {\n return this.txBlock.sharedObjectRef(ref);\n }\n setSender(sender: string) {\n return this.txBlock.setSender(sender);\n }\n setSenderIfNotSet(sender: string) {\n return this.txBlock.setSenderIfNotSet(sender);\n }\n setExpiration(expiration?: TransactionExpiration) {\n return this.txBlock.setExpiration(expiration);\n }\n setGasPrice(price: number | bigint) {\n return this.txBlock.setGasPrice(price);\n }\n setGasBudget(budget: number | bigint) {\n return this.txBlock.setGasBudget(budget);\n }\n setGasOwner(owner: string) {\n return this.txBlock.setGasOwner(owner);\n }\n setGasPayment(payments: SuiObjectRef[]) {\n return this.txBlock.setGasPayment(payments);\n }\n serialize() {\n return this.txBlock.serialize();\n }\n sign(params: {\n signer: Keypair;\n client?: SuiClient;\n onlyTransactionKind?: boolean;\n }) {\n return this.txBlock.sign(params);\n }\n build(\n params: {\n client?: SuiClient;\n onlyTransactionKind?: boolean;\n } = {}\n ) {\n return this.txBlock.build(params);\n }\n getDigest(params: { client?: SuiClient } = {}) {\n return this.txBlock.getDigest(params);\n }\n add(...args: TransactionType) {\n return this.txBlock.add(...args);\n }\n publish({\n modules,\n dependencies,\n }: {\n modules: number[][] | string[];\n dependencies: string[];\n }) {\n return this.txBlock.publish({ modules, dependencies });\n }\n upgrade({\n modules,\n dependencies,\n packageId,\n ticket,\n }: {\n modules: number[][] | string[];\n dependencies: string[];\n packageId: string;\n ticket: TransactionObjectArgument | string;\n }) {\n return this.txBlock.upgrade({ modules, dependencies, packageId, ticket });\n }\n makeMoveVec({\n objects,\n type,\n }: {\n objects: (TransactionObjectArgument | string)[];\n type?: string;\n }) {\n return this.txBlock.makeMoveVec({ objects, type });\n }\n\n /* Override methods of TransactionBlock */\n\n transferObjects(objects: SuiObjectArg[], address: SuiAddressArg) {\n return this.txBlock.transferObjects(\n objects.map((object) => convertObjArg(this.txBlock, object)),\n convertAddressArg(this.txBlock, address)\n );\n }\n\n splitCoins(coin: SuiObjectArg, amounts: SuiTxArg[]) {\n const res = this.txBlock.splitCoins(\n convertObjArg(this.txBlock, coin),\n convertArgs(this.txBlock, amounts)\n );\n return amounts.map((_, i) => res[i]);\n }\n\n mergeCoins(destination: SuiObjectArg, sources: SuiObjectArg[]) {\n const destinationObject = convertObjArg(this.txBlock, destination);\n const sourceObjects = sources.map((source) =>\n convertObjArg(this.txBlock, source)\n );\n return this.txBlock.mergeCoins(destinationObject, sourceObjects);\n }\n\n /**\n * @description Move call\n * @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`\n * @param args the arguments of the move call, such as `['0x1', '0x2']`\n * @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`\n */\n moveCall(\n target: string,\n args: (SuiTxArg | SuiVecTxArg)[] = [],\n typeArgs: string[] = []\n ) {\n // a regex for pattern `${string}::${string}::${string}`\n const regex =\n /(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/;\n const match = target.match(regex);\n if (match === null)\n throw new Error(\n 'Invalid target format. Expected `${string}::${string}::${string}`'\n );\n const convertedArgs = convertArgs(this.txBlock, args);\n return this.txBlock.moveCall({\n target: target as `${string}::${string}::${string}`,\n arguments: convertedArgs,\n typeArguments: typeArgs,\n });\n }\n\n /* Enhance methods of TransactionBlock */\n\n transferSuiToMany(recipients: SuiAddressArg[], amounts: SuiTxArg[]) {\n // require recipients.length === amounts.length\n if (recipients.length !== amounts.length) {\n throw new Error(\n 'transferSuiToMany: recipients.length !== amounts.length'\n );\n }\n const coins = this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, amounts)\n );\n const recipientObjects = recipients.map((recipient) =>\n convertAddressArg(this.txBlock, recipient)\n );\n recipientObjects.forEach((address, index) => {\n this.txBlock.transferObjects([coins[index]], address);\n });\n return this;\n }\n\n transferSui(address: SuiAddressArg, amount: SuiTxArg) {\n return this.transferSuiToMany([address], [amount]);\n }\n\n takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiTxArg) {\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const mergedCoin = coinObjects[0];\n if (coins.length > 1) {\n this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));\n }\n const [sendCoin] = this.txBlock.splitCoins(\n mergedCoin,\n convertArgs(this.txBlock, [amount])\n );\n return [sendCoin, mergedCoin];\n }\n\n splitSUIFromGas(amounts: SuiTxArg[]) {\n return this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, amounts)\n );\n }\n\n splitMultiCoins(coins: SuiObjectArg[], amounts: SuiTxArg[]) {\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const mergedCoin = coinObjects[0];\n if (coins.length > 1) {\n this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));\n }\n const splitedCoins = this.txBlock.splitCoins(\n mergedCoin,\n convertArgs(this.txBlock, amounts)\n );\n return { splitedCoins, mergedCoin };\n }\n\n transferCoinToMany(\n coins: SuiObjectArg[],\n sender: SuiAddressArg,\n recipients: SuiAddressArg[],\n amounts: SuiTxArg[]\n ) {\n // require recipients.length === amounts.length\n if (recipients.length !== amounts.length) {\n throw new Error(\n 'transferSuiToMany: recipients.length !== amounts.length'\n );\n }\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const { splitedCoins, mergedCoin } = this.splitMultiCoins(\n coinObjects,\n amounts\n );\n const recipientObjects = recipients.map((recipient) =>\n convertAddressArg(this.txBlock, recipient)\n );\n recipientObjects.forEach((address, index) => {\n this.txBlock.transferObjects([splitedCoins[index]], address);\n });\n this.txBlock.transferObjects(\n [mergedCoin],\n convertAddressArg(this.txBlock, sender)\n );\n return this;\n }\n\n transferCoin(\n coins: SuiObjectArg[],\n sender: SuiAddressArg,\n recipient: SuiAddressArg,\n amount: SuiTxArg\n ) {\n return this.transferCoinToMany(coins, sender, [recipient], [amount]);\n }\n\n stakeSui(amount: SuiTxArg, validatorAddr: SuiAddressArg) {\n const [stakeCoin] = this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, [amount])\n );\n return this.txBlock.moveCall({\n target: '0x3::sui_system::request_add_stake',\n arguments: convertArgs(this.txBlock, [\n SUI_SYSTEM_STATE_OBJECT_ID,\n stakeCoin,\n this.txBlock.pure(validatorAddr),\n ]),\n });\n }\n}\n","import {\n normalizeSuiObjectId,\n normalizeSuiAddress,\n isValidSuiObjectId,\n isValidSuiAddress,\n} from '@mysten/sui.js/utils';\nimport { Inputs } from '@mysten/sui.js/transactions';\nimport { isPureArg } from '@mysten/sui.js/bcs';\nimport { isSerializedBcs } from '@mysten/bcs';\nimport type {\n TransactionArgument,\n TransactionBlock,\n TransactionObjectArgument,\n} from '@mysten/sui.js/transactions';\nimport type {\n SuiInputTypes,\n SuiObjectArg,\n SuiAddressArg,\n SuiTxArg,\n SuiVecTxArg,\n} from 'src/types';\n\nexport const getDefaultSuiInputType = (\n value: SuiTxArg\n): SuiInputTypes | undefined => {\n if (typeof value === 'string' && isValidSuiObjectId(value)) {\n return 'object';\n } else if (typeof value === 'number' || typeof value === 'bigint') {\n return 'u64';\n } else if (typeof value === 'boolean') {\n return 'bool';\n } else {\n return undefined;\n }\n};\n\n/**\n * Since we know the elements in the array are the same type\n * If type is not provided, we will try to infer the type from the first element\n * By default,\n *\n * string is hex and its length equal to 32 =====> object id\n * number, bigint ====> u64\n * boolean =====> bool\n *\n * If type is provided, we will use the type to convert the array\n * @param args\n * @param type 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256' | 'signer' | 'object' | string\n */\nexport function makeVecParam(\n txBlock: TransactionBlock,\n args: SuiTxArg[],\n type?: SuiInputTypes\n): TransactionArgument {\n if (args.length === 0)\n throw new Error('Transaction builder error: Empty array is not allowed');\n // Using first element value as default type\n const defaultSuiType = getDefaultSuiInputType(args[0]);\n const VECTOR_REGEX = /^vector<(.+)>$/;\n const STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;\n\n type = type || defaultSuiType;\n\n if (type === 'object') {\n const objects = args.map((arg) =>\n typeof arg === 'string' && isValidSuiObjectId(arg)\n ? txBlock.object(normalizeSuiObjectId(arg))\n : convertObjArg(txBlock, arg as SuiObjectArg)\n );\n return txBlock.makeMoveVec({ objects });\n } else if (\n typeof type === 'string' &&\n !VECTOR_REGEX.test(type) &&\n !STRUCT_REGEX.test(type)\n ) {\n return txBlock.pure(args, `vector<${type}>`);\n } else {\n const objects = args.map((arg) =>\n convertObjArg(txBlock, arg as SuiObjectArg)\n );\n return txBlock.makeMoveVec({ objects, type });\n }\n}\n\n/**\n * Check whether it is an valid move vec input.\n *\n * @param arg The argument to check.\n * @returns boolean.\n */\nexport function isMoveVecArg(arg: SuiTxArg | SuiVecTxArg): arg is SuiVecTxArg {\n if (typeof arg === 'object' && 'vecType' in arg && 'value' in arg) {\n return true;\n } else if (Array.isArray(arg)) {\n return true;\n }\n return false;\n}\n\n/**\n * Convert any valid input into array of TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param args The array of argument to convert.\n * @returns The converted array of TransactionArgument.\n */\nexport function convertArgs(\n txBlock: TransactionBlock,\n args: (SuiTxArg | SuiVecTxArg)[]\n) {\n return args.map((arg) => {\n if (typeof arg === 'string' && isValidSuiObjectId(arg)) {\n return txBlock.object(normalizeSuiObjectId(arg));\n } else if (\n typeof arg == 'object' &&\n !isSerializedBcs(arg) &&\n !isPureArg(arg) &&\n !isMoveVecArg(arg)\n ) {\n return convertObjArg(txBlock, arg as SuiObjectArg);\n } else if (isMoveVecArg(arg)) {\n const vecType = 'vecType' in arg;\n return vecType\n ? makeVecParam(txBlock, arg.value, arg.vecType)\n : makeVecParam(txBlock, arg);\n } else if (isSerializedBcs(arg)) {\n return arg;\n } else {\n return txBlock.pure(arg);\n }\n });\n}\n\n/**\n * Convert any valid address input into a TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param arg The address argument to convert.\n * @returns The converted TransactionArgument.\n */\nexport function convertAddressArg(\n txBlock: TransactionBlock,\n arg: SuiAddressArg\n) {\n if (typeof arg === 'string' && isValidSuiAddress(arg)) {\n return txBlock.pure.address(normalizeSuiAddress(arg));\n } else if (\n typeof arg == 'object' &&\n !isSerializedBcs(arg) &&\n !isPureArg(arg)\n ) {\n return convertObjArg(txBlock, arg as SuiObjectArg);\n } else if (isPureArg(arg)) {\n return txBlock.pure(arg);\n } else {\n return arg;\n }\n}\n\n/**\n * Convert any valid object input into a TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param arg The object argument to convert.\n * @returns The converted TransactionArgument.\n */\nexport function convertObjArg(\n txb: TransactionBlock,\n arg: SuiObjectArg\n): TransactionObjectArgument {\n if (typeof arg === 'string') {\n return txb.object(arg);\n }\n\n if ('digest' in arg && 'version' in arg && 'objectId' in arg) {\n return txb.objectRef(arg);\n }\n\n if ('objectId' in arg && 'initialSharedVersion' in arg && 'mutable' in arg) {\n return txb.sharedObjectRef(arg);\n }\n\n if ('Object' in arg) {\n if ('ImmOrOwned' in arg.Object) {\n return txb.object(Inputs.ObjectRef(arg.Object.ImmOrOwned));\n } else if ('Shared' in arg.Object) {\n return txb.object(Inputs.SharedObjectRef(arg.Object.Shared));\n } else {\n throw new Error('Invalid argument type');\n }\n }\n\n if ('kind' in arg) {\n return arg;\n }\n\n throw new Error('Invalid argument type');\n}\n","import { SuiClient } from '@mysten/sui.js/client';\nimport { SuiOwnedObject, SuiSharedObject } from '../suiModel';\nimport { delay } from './util';\nimport type {\n SuiTransactionBlockResponseOptions,\n SuiTransactionBlockResponse,\n SuiObjectDataOptions,\n SuiObjectData,\n DryRunTransactionBlockResponse,\n} from '@mysten/sui.js/client';\n\n/**\n * Encapsulates all functions that interact with the sui sdk\n */\nexport class SuiInteractor {\n public readonly clients: SuiClient[];\n public currentClient: SuiClient;\n public readonly fullNodes: string[];\n public currentFullNode: string;\n\n constructor(fullNodeUrls: string[]) {\n if (fullNodeUrls.length === 0)\n throw new Error('fullNodeUrls must not be empty');\n this.fullNodes = fullNodeUrls;\n this.clients = fullNodeUrls.map((url) => new SuiClient({ url }));\n this.currentFullNode = fullNodeUrls[0];\n this.currentClient = this.clients[0];\n }\n\n switchToNextClient() {\n const currentClientIdx = this.clients.indexOf(this.currentClient);\n this.currentClient =\n this.clients[(currentClientIdx + 1) % this.clients.length];\n this.currentFullNode =\n this.fullNodes[(currentClientIdx + 1) % this.clients.length];\n }\n\n async sendTx(\n transactionBlock: Uint8Array | string,\n signature: string | string[]\n ): Promise<SuiTransactionBlockResponse> {\n const txResOptions: SuiTransactionBlockResponseOptions = {\n showEvents: true,\n showEffects: true,\n showObjectChanges: true,\n showBalanceChanges: true,\n };\n\n for (const clientIdx in this.clients) {\n try {\n return await this.clients[clientIdx].executeTransactionBlock({\n transactionBlock,\n signature,\n options: txResOptions,\n });\n } catch (err) {\n console.warn(\n `Failed to send transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n await delay(2000);\n }\n }\n throw new Error('Failed to send transaction with all fullnodes');\n }\n\n async dryRunTx(\n transactionBlock: Uint8Array\n ): Promise<DryRunTransactionBlockResponse> {\n for (const clientIdx in this.clients) {\n try {\n return await this.clients[clientIdx].dryRunTransactionBlock({\n transactionBlock,\n });\n } catch (err) {\n console.warn(\n `Failed to dry run transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n await delay(2000);\n }\n }\n throw new Error('Failed to dry run transaction with all fullnodes');\n }\n\n async getObjects(\n ids: string[],\n options?: SuiObjectDataOptions\n ): Promise<SuiObjectData[]> {\n const opts: SuiObjectDataOptions = options ?? {\n showContent: true,\n showDisplay: true,\n showType: true,\n showOwner: true,\n };\n\n for (const clientIdx in this.clients) {\n try {\n const objects = await this.clients[clientIdx].multiGetObjects({\n ids,\n options: opts,\n });\n const parsedObjects = objects\n .map((object) => {\n return object.data;\n })\n .filter((object) => object !== null && object !== undefined);\n return parsedObjects as SuiObjectData[];\n } catch (err) {\n await delay(2000);\n console.warn(\n `Failed to get objects with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n }\n }\n throw new Error('Failed to get objects with all fullnodes');\n }\n\n async getObject(id: string, options?: SuiObjectDataOptions) {\n const objects = await this.getObjects([id], options);\n return objects[0];\n }\n\n /**\n * @description Update objects in a batch\n * @param suiObjects\n */\n async updateObjects(suiObjects: (SuiOwnedObject | SuiSharedObject)[]) {\n const objectIds = suiObjects.map((obj) => obj.objectId);\n const objects = await this.getObjects(objectIds);\n for (const object of objects) {\n const suiObject = suiObjects.find(\n (obj) => obj.objectId === object?.objectId\n );\n if (suiObject instanceof SuiSharedObject) {\n if (\n object.owner &&\n typeof object.owner === 'object' &&\n 'Shared' in object.owner\n ) {\n suiObject.initialSharedVersion =\n object.owner.Shared.initial_shared_version;\n } else {\n suiObject.initialSharedVersion = undefined;\n }\n } else if (suiObject instanceof SuiOwnedObject) {\n suiObject.version = object?.version;\n suiObject.digest = object?.digest;\n }\n }\n }\n\n /**\n * @description Select coins that add up to the given amount.\n * @param addr the address of the owner\n * @param amount the amount that is needed for the coin\n * @param coinType the coin type, default is '0x2::SUI::SUI'\n */\n async selectCoins(\n addr: string,\n amount: number,\n coinType: string = '0x2::SUI::SUI'\n ) {\n const selectedCoins: {\n objectId: string;\n digest: string;\n version: string;\n }[] = [];\n let totalAmount = 0;\n let hasNext = true,\n nextCursor: string | null | undefined = null;\n while (hasNext && totalAmount < amount) {\n const coins = await this.currentClient.getCoins({\n owner: addr,\n coinType: coinType,\n cursor: nextCursor,\n });\n // Sort the coins by balance in descending order\n coins.data.sort((a, b) => parseInt(b.balance) - parseInt(a.balance));\n for (const coinData of coins.data) {\n selectedCoins.push({\n objectId: coinData.coinObjectId,\n digest: coinData.digest,\n version: coinData.version,\n });\n totalAmount = totalAmount + parseInt(coinData.balance);\n if (totalAmount >= amount) {\n break;\n }\n }\n\n nextCursor = coins.nextCursor;\n hasNext = coins.hasNextPage;\n }\n\n if (!selectedCoins.length) {\n throw new Error('No valid coins found for the transaction.');\n }\n return selectedCoins;\n }\n}\n","import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';\nimport type { CallArg } from '@mysten/sui.js/bcs';\n\nexport class SuiOwnedObject {\n public readonly objectId: string;\n public version?: string;\n public digest?: string;\n\n constructor(param: { objectId: string; version?: string; digest?: string }) {\n this.objectId = param.objectId;\n this.version = param.version;\n this.digest = param.digest;\n }\n\n /**\n * Check if the object is fully initialized.\n * So that when it's used as an input, it won't be necessary to fetch from fullnode again.\n * Which can save time when sending transactions.\n */\n isFullObject(): boolean {\n return !!this.version && !!this.digest;\n }\n\n asCallArg(): CallArg | string {\n if (!this.version || !this.digest) {\n return this.objectId;\n }\n return {\n Object: {\n ImmOrOwned: {\n objectId: this.objectId,\n version: this.version,\n digest: this.digest,\n },\n },\n };\n }\n\n /**\n * Update object version & digest based on the transaction response.\n * @param txResponse\n */\n updateFromTxResponse(txResponse: SuiTransactionBlockResponse) {\n const changes = txResponse.objectChanges;\n if (!changes) {\n throw new Error('Bad transaction response!');\n }\n for (const change of changes) {\n if (change.type === 'mutated' && change.objectId === this.objectId) {\n this.digest = change.digest;\n this.version = change.version;\n return;\n }\n }\n throw new Error('Could not find object in transaction response!');\n }\n}\n","import type { CallArg } from '@mysten/sui.js/bcs';\n\nexport class SuiSharedObject {\n public readonly objectId: string;\n public initialSharedVersion?: string;\n\n constructor(param: {\n objectId: string;\n initialSharedVersion?: string;\n mutable?: boolean;\n }) {\n this.objectId = param.objectId;\n this.initialSharedVersion = param.initialSharedVersion;\n }\n\n asCallArg(mutable: boolean = false): CallArg | string {\n if (!this.initialSharedVersion) {\n return this.objectId;\n }\n return {\n Object: {\n Shared: {\n objectId: this.objectId,\n initialSharedVersion: this.initialSharedVersion,\n mutable,\n },\n },\n };\n }\n}\n","export const delay = (ms: number) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n","import { MultiSigPublicKey } from '@mysten/sui.js/multisig';\nimport type { PublicKey } from '@mysten/sui.js/src/cryptography';\nimport { ed25519PublicKeyFromBase64 } from './publickey';\n\nexport type PublicKeyWeightPair = {\n publicKey: PublicKey;\n weight: number;\n};\n\nexport class MultiSigClient {\n public readonly pksWeightPairs: PublicKeyWeightPair[];\n public readonly threshold: number;\n public readonly multiSigPublicKey: MultiSigPublicKey;\n constructor(pks: PublicKeyWeightPair[], threshold: number) {\n this.pksWeightPairs = pks;\n this.threshold = threshold;\n this.multiSigPublicKey = MultiSigPublicKey.fromPublicKeys({\n threshold: this.threshold,\n publicKeys: this.pksWeightPairs,\n });\n }\n\n static fromRawEd25519PublicKeys(\n rawPublicKeys: string[],\n weights: number[],\n threshold: number\n ): MultiSigClient {\n const pks = rawPublicKeys.map((rawPublicKey, i) => {\n return {\n publicKey: ed25519PublicKeyFromBase64(rawPublicKey),\n weight: weights[i],\n };\n });\n return new MultiSigClient(pks, threshold);\n }\n\n multiSigAddress(): string {\n return this.multiSigPublicKey.toSuiAddress();\n }\n\n combinePartialSigs(sigs: string[]): string {\n return this.multiSigPublicKey.combinePartialSignatures(sigs);\n }\n}\n","import { PublicKey } from '@mysten/sui.js/cryptography';\nimport { Ed25519PublicKey } from '@mysten/sui.js/keypairs/ed25519';\nimport { fromB64 } from '@mysten/sui.js/utils';\n\nexport function ed25519PublicKeyFromBase64(rawPubkey: string): PublicKey {\n let bytes = fromB64(rawPubkey);\n // rawPubkeys should either be 32 bytes or 33 bytes (with the first byte being flag)\n if (bytes.length !== 32 && bytes.length !== 33) throw 'invalid pubkey length';\n bytes = bytes.length === 33 ? bytes.slice(1) : bytes;\n return new Ed25519PublicKey(bytes);\n}\n"],"mappings":";AAAA,cAAc;AACd,cAAc;;;ACEd,SAAS,sBAAsB;AAC/B,SAAS,o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AAc,2BAA2B;AAAA,MACjE,kBAAkB;AAAA,MAClB,QAAQ,KAAK,WAAW,gBAAgB;AAAA,IAC1C,CAAC;AAAA,EACH;AACF;;;AWxSA,SAAS,yBAAyB;;;ACClC,SAAS,wBAAwB;AACjC,SAAS,WAAAC,gBAAe;AAEjB,SAAS,2BAA2B,WAA8B;AACvE,MAAI,QAAQA,SAAQ,SAAS;AAE7B,MAAI,MAAM,WAAW,MAAM,MAAM,WAAW;AAAI,UAAM;AACtD,UAAQ,MAAM,WAAW,KAAK,MAAM,MAAM,CAAC,IAAI;AAC/C,SAAO,IAAI,iBAAiB,KAAK;AACnC;;;ADDO,IAAM,iBAAN,MAAM,gBAAe;AAAA,EAI1B,YAAY,KAA4B,WAAmB;AACzD,SAAK,iBAAiB;AACtB,SAAK,YAAY;AACjB,SAAK,oBAAoB,kBAAkB,eAAe;AAAA,MACxD,WAAW,KAAK;AAAA,MAChB,YAAY,KAAK;AAAA,IACnB,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,yBACL,eACA,SACA,WACgB;AAChB,UAAM,MAAM,cAAc,IAAI,CAAC,cAAc,MAAM;AACjD,aAAO;AAAA,QACL,WAAW,2BAA2B,YAAY;AAAA,QAClD,QAAQ,QAAQ,CAAC;AAAA,MACnB;AAAA,IACF,CAAC;AACD,WAAO,IAAI,gBAAe,KAAK,SAAS;AAAA,EAC1C;AAAA,EAEA,kBAA0B;AACxB,WAAO,KAAK,kBAAkB,aAAa;AAAA,EAC7C;AAAA,EAEA,mBAAmB,MAAwB;AACzC,WAAO,KAAK,kBAAkB,yBAAyB,IAAI;AAAA,EAC7D;AACF;","names":["TransactionBlock","Ed25519Keypair","Ed25519Keypair","TransactionBlock","fromB64"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/suiKit.ts","../src/libs/suiAccountManager/index.ts","../src/libs/suiAccountManager/keypair.ts","../src/libs/suiAccountManager/util.ts","../src/libs/suiAccountManager/crypto.ts","../src/libs/suiTxBuilder/index.ts","../src/libs/suiTxBuilder/util.ts","../src/libs/suiInteractor/suiInteractor.ts","../src/libs/suiModel/suiOwnedObject.ts","../src/libs/suiModel/suiSharedObject.ts","../src/libs/suiInteractor/util.ts","../src/libs/multiSig/client.ts","../src/libs/multiSig/publickey.ts"],"sourcesContent":["export * from '@mysten/sui.js/utils';\nexport * from '@mysten/sui.js/transactions';\nexport { SuiKit } from './suiKit';\nexport { SuiAccountManager } from './libs/suiAccountManager';\nexport { SuiTxBlock } from './libs/suiTxBuilder';\nexport { MultiSigClient } from './libs/multiSig';\nexport type * from './types';\n","/**\n * @description This file is used to aggregate the tools that used to interact with SUI network.\n */\nimport { getFullnodeUrl } from '@mysten/sui.js/client';\nimport { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { SuiAccountManager } from './libs/suiAccountManager';\nimport { SuiTxBlock } from './libs/suiTxBuilder';\nimport { SuiInteractor } from './libs/suiInteractor';\nimport type {\n SuiTransactionBlockResponse,\n DevInspectResults,\n SuiObjectDataOptions,\n DryRunTransactionBlockResponse,\n} from '@mysten/sui.js/client';\nimport type { SuiSharedObject, SuiOwnedObject } from './libs/suiModel';\nimport type {\n SuiKitParams,\n DerivePathParams,\n SuiTxArg,\n SuiVecTxArg,\n} from './types';\n\n/**\n * @class SuiKit\n * @description This class is used to aggregate the tools that used to interact with SUI network.\n */\nexport class SuiKit {\n public accountManager: SuiAccountManager;\n public suiInteractor: SuiInteractor;\n\n /**\n * Support the following ways to init the SuiToolkit:\n * 1. mnemonics\n * 2. secretKey (base64 or hex)\n * If none of them is provided, will generate a random mnemonics with 24 words.\n *\n * @param mnemonics, 12 or 24 mnemonics words, separated by space\n * @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored\n * @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'\n * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type\n */\n constructor({\n mnemonics,\n secretKey,\n networkType,\n fullnodeUrls,\n }: SuiKitParams = {}) {\n // Init the account manager\n this.accountManager = new SuiAccountManager({ mnemonics, secretKey });\n // Init the sui interactor\n fullnodeUrls = fullnodeUrls || [getFullnodeUrl(networkType ?? 'mainnet')];\n this.suiInteractor = new SuiInteractor(fullnodeUrls);\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the keypair.\n * else:\n * it will generate signer from the mnemonic with the given derivePathParams.\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n getKeypair(derivePathParams?: DerivePathParams) {\n return this.accountManager.getKeyPair(derivePathParams);\n }\n\n /**\n * @description Switch the current account with the given derivePathParams\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n switchAccount(derivePathParams: DerivePathParams) {\n this.accountManager.switchAccount(derivePathParams);\n }\n\n /**\n * @description Get the address of the account for the given derivePathParams\n * @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard\n */\n getAddress(derivePathParams?: DerivePathParams) {\n return this.accountManager.getAddress(derivePathParams);\n }\n\n currentAddress() {\n return this.accountManager.currentAddress;\n }\n\n async getBalance(coinType?: string, derivePathParams?: DerivePathParams) {\n const owner = this.accountManager.getAddress(derivePathParams);\n return this.suiInteractor.currentClient.getBalance({ owner, coinType });\n }\n\n client() {\n return this.suiInteractor.currentClient;\n }\n\n async getObjects(objectIds: string[], options?: SuiObjectDataOptions) {\n return this.suiInteractor.getObjects(objectIds, options);\n }\n\n /**\n * @description Update objects in a batch\n * @param suiObjects\n */\n async updateObjects(suiObjects: (SuiSharedObject | SuiOwnedObject)[]) {\n return this.suiInteractor.updateObjects(suiObjects);\n }\n\n async signTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ) {\n if (tx instanceof SuiTxBlock) {\n tx.setSender(this.getAddress(derivePathParams));\n }\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n const txBytes =\n txBlock instanceof TransactionBlock\n ? await txBlock.build({ client: this.client() })\n : txBlock;\n const keyPair = this.getKeypair(derivePathParams);\n return await keyPair.signTransactionBlock(txBytes);\n }\n\n async signAndSendTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<SuiTransactionBlockResponse> {\n const { bytes, signature } = await this.signTxn(tx, derivePathParams);\n return this.suiInteractor.sendTx(bytes, signature);\n }\n\n async dryRunTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<DryRunTransactionBlockResponse> {\n if (tx instanceof SuiTxBlock) {\n tx.setSender(this.getAddress(derivePathParams));\n }\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n const txBytes =\n txBlock instanceof TransactionBlock\n ? await txBlock.build({ client: this.client() })\n : txBlock;\n return this.suiInteractor.dryRunTx(txBytes);\n }\n\n /**\n * Transfer the given amount of SUI to the recipient\n * @param recipient\n * @param amount\n * @param derivePathParams\n */\n async transferSui(\n recipient: string,\n amount: number,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferSui(recipient, amount);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Transfer to mutliple recipients\n * @param recipients the recipients addresses\n * @param amounts the amounts of SUI to transfer to each recipient, the length of amounts should be the same as the length of recipients\n * @param derivePathParams\n */\n async transferSuiToMany(\n recipients: string[],\n amounts: number[],\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferSuiToMany(recipients, amounts);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Transfer the given amounts of coin to multiple recipients\n * @param recipients the list of recipient address\n * @param amounts the amounts to transfer for each recipient\n * @param coinType any custom coin type but not SUI\n * @param derivePathParams the derive path params for the current signer\n */\n async transferCoinToMany(\n recipients: string[],\n amounts: number[],\n coinType: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n const owner = this.accountManager.getAddress(derivePathParams);\n const totalAmount = amounts.reduce((a, b) => a + b, 0);\n const coins = await this.suiInteractor.selectCoins(\n owner,\n totalAmount,\n coinType\n );\n tx.transferCoinToMany(\n coins.map((c) => c.objectId),\n owner,\n recipients,\n amounts\n );\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n async transferCoin(\n recipient: string,\n amount: number,\n coinType: string,\n derivePathParams?: DerivePathParams\n ) {\n return this.transferCoinToMany(\n [recipient],\n [amount],\n coinType,\n derivePathParams\n );\n }\n\n async transferObjects(\n objects: string[],\n recipient: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.transferObjects(objects, recipient);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n async moveCall(callParams: {\n target: string;\n arguments?: (SuiTxArg | SuiVecTxArg)[];\n typeArguments?: string[];\n derivePathParams?: DerivePathParams;\n }) {\n const {\n target,\n arguments: args = [],\n typeArguments = [],\n derivePathParams,\n } = callParams;\n const tx = new SuiTxBlock();\n tx.moveCall(target, args, typeArguments);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount\n * @param amount\n * @param coinType\n * @param owner\n */\n async selectCoinsWithAmount(\n amount: number,\n coinType: string,\n owner?: string\n ) {\n owner = owner || this.accountManager.currentAddress;\n const coins = await this.suiInteractor.selectCoins(owner, amount, coinType);\n return coins.map((c) => c.objectId);\n }\n\n /**\n * stake the given amount of SUI to the validator\n * @param amount the amount of SUI to stake\n * @param validatorAddr the validator address\n * @param derivePathParams the derive path params for the current signer\n */\n async stakeSui(\n amount: number,\n validatorAddr: string,\n derivePathParams?: DerivePathParams\n ) {\n const tx = new SuiTxBlock();\n tx.stakeSui(amount, validatorAddr);\n return this.signAndSendTxn(tx, derivePathParams);\n }\n\n /**\n * Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.\n * Since the transaction is not submitted, its gas cost is not charged.\n * @param tx the transaction to execute\n * @param derivePathParams the derive path params\n * @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.\n */\n async inspectTxn(\n tx: Uint8Array | TransactionBlock | SuiTxBlock,\n derivePathParams?: DerivePathParams\n ): Promise<DevInspectResults> {\n const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;\n return this.suiInteractor.currentClient.devInspectTransactionBlock({\n transactionBlock: txBlock,\n sender: this.getAddress(derivePathParams),\n });\n }\n}\n","import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport { getKeyPair } from './keypair';\nimport { hexOrBase64ToUint8Array, normalizePrivateKey } from './util';\nimport { generateMnemonic } from './crypto';\nimport type { AccountMangerParams, DerivePathParams } from 'src/types';\nimport {\n SUI_PRIVATE_KEY_PREFIX,\n decodeSuiPrivateKey,\n} from '@mysten/sui.js/cryptography';\n\nexport class SuiAccountManager {\n private mnemonics: string;\n private secretKey: string;\n public currentKeyPair: Ed25519Keypair;\n public currentAddress: string;\n\n /**\n * Support the following ways to init the SuiToolkit:\n * 1. mnemonics\n * 2. secretKey (base64 or hex)\n * If none of them is provided, will generate a random mnemonics with 24 words.\n *\n * @param mnemonics, 12 or 24 mnemonics words, separated by space\n * @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored\n */\n constructor({ mnemonics, secretKey }: AccountMangerParams = {}) {\n // If the mnemonics or secretKey is provided, use it\n // Otherwise, generate a random mnemonics with 24 words\n this.mnemonics = mnemonics || '';\n this.secretKey = secretKey || '';\n if (!this.mnemonics && !this.secretKey) {\n this.mnemonics = generateMnemonic(24);\n }\n\n // Init the current account\n this.currentKeyPair = this.secretKey\n ? this.parseSecretKey(this.secretKey)\n : getKeyPair(this.mnemonics);\n this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();\n }\n\n /**\n * Check if the secretKey starts with bench32 format\n */\n parseSecretKey(secretKey: string) {\n if (secretKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {\n const { secretKey: uint8ArraySecretKey } = decodeSuiPrivateKey(secretKey);\n return Ed25519Keypair.fromSecretKey(\n normalizePrivateKey(uint8ArraySecretKey)\n );\n }\n\n return Ed25519Keypair.fromSecretKey(\n normalizePrivateKey(hexOrBase64ToUint8Array(secretKey))\n );\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.\n * else:\n * it will generate keyPair from the mnemonic with the given derivePathParams.\n */\n getKeyPair(derivePathParams?: DerivePathParams) {\n if (!derivePathParams || !this.mnemonics) return this.currentKeyPair;\n return getKeyPair(this.mnemonics, derivePathParams);\n }\n\n /**\n * if derivePathParams is not provided or mnemonics is empty, it will return the currentAddress.\n * else:\n * it will generate address from the mnemonic with the given derivePathParams.\n */\n getAddress(derivePathParams?: DerivePathParams) {\n if (!derivePathParams || !this.mnemonics) return this.currentAddress;\n return getKeyPair(this.mnemonics, derivePathParams)\n .getPublicKey()\n .toSuiAddress();\n }\n\n /**\n * Switch the current account with the given derivePathParams.\n * This is only useful when the mnemonics is provided. For secretKey mode, it will always use the same account.\n */\n switchAccount(derivePathParams: DerivePathParams) {\n if (this.mnemonics) {\n this.currentKeyPair = getKeyPair(this.mnemonics, derivePathParams);\n this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();\n }\n }\n}\n","import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519';\nimport type { DerivePathParams } from 'src/types';\n\n/**\n * @description Get ed25519 derive path for SUI\n * @param derivePathParams\n */\nexport const getDerivePathForSUI = (\n derivePathParams: DerivePathParams = {}\n) => {\n const {\n accountIndex = 0,\n isExternal = false,\n addressIndex = 0,\n } = derivePathParams;\n return `m/44'/784'/${accountIndex}'/${isExternal ? 1 : 0}'/${addressIndex}'`;\n};\n\n/**\n * the format is m/44'/784'/accountIndex'/${isExternal ? 1 : 0}'/addressIndex'\n *\n * accountIndex is the index of the account, default is 0.\n *\n * isExternal is the type of the address, default is false. Usually, the external address is used to receive coins. The internal address is used to change coins.\n *\n * addressIndex is the index of the address, default is 0. It's used to generate multiple addresses for one account.\n *\n * @description Get keypair from mnemonics and derive path\n * @param mnemonics\n * @param derivePathParams\n */\nexport const getKeyPair = (\n mnemonics: string,\n derivePathParams: DerivePathParams = {}\n) => {\n const derivePath = getDerivePathForSUI(derivePathParams);\n return Ed25519Keypair.deriveKeypair(mnemonics, derivePath);\n};\n","import { fromB64 } from '@mysten/sui.js/utils';\n\n/**\n * @description This regular expression matches any string that contains only hexadecimal digits (0-9, A-F, a-f).\n * @param str\n */\nexport const isHex = (str: string) =>\n /^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(str);\n\n/**\n * @description This regular expression matches any string that contains only base64 digits (0-9, A-Z, a-z, +, /, =).\n * Note that the \"=\" signs at the end are optional padding characters that may be present in some base64 encoded strings.\n * @param str\n */\nexport const isBase64 = (str: string) => /^[a-zA-Z0-9+/]+={0,2}$/g.test(str);\n\n/**\n * Convert a hex string to Uint8Array\n * @param hexStr\n */\nexport const fromHEX = (hexStr: string): Uint8Array => {\n if (!hexStr) {\n throw new Error('cannot parse empty string to Uint8Array');\n }\n const intArr = hexStr\n .replace('0x', '')\n .match(/.{1,2}/g)\n ?.map((byte) => parseInt(byte, 16));\n\n if (!intArr || intArr.length === 0) {\n throw new Error(`Unable to parse HEX: ${hexStr}`);\n }\n return Uint8Array.from(intArr);\n};\n\n/**\n * @description Convert a hex or base64 string to Uint8Array\n */\nexport const hexOrBase64ToUint8Array = (str: string): Uint8Array => {\n if (isHex(str)) {\n return fromHEX(str);\n } else if (isBase64(str)) {\n return fromB64(str);\n } else {\n throw new Error('The string is not a valid hex or base64 string.');\n }\n};\n\nconst PRIVATE_KEY_SIZE = 32;\nconst LEGACY_PRIVATE_KEY_SIZE = 64;\n/**\n * normalize a private key\n * A private key is a 32-byte array.\n * But there are two different formats for private keys:\n * 1. A 32-byte array\n * 2. A 64-byte array with the first 32 bytes being the private key and the last 32 bytes being the public key\n * 3. A 33-byte array with the first byte being 0x00 (sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning)\n */\nexport const normalizePrivateKey = (key: Uint8Array): Uint8Array => {\n if (key.length === LEGACY_PRIVATE_KEY_SIZE) {\n // This is a legacy secret key, we need to strip the public key bytes and only read the first 32 bytes\n key = key.slice(0, PRIVATE_KEY_SIZE);\n } else if (key.length === PRIVATE_KEY_SIZE + 1 && key[0] === 0) {\n // sui.keystore key is a Base64 string with scheme flag 0x00 at the beginning\n return key.slice(1);\n } else if (key.length === PRIVATE_KEY_SIZE) {\n return key;\n }\n throw new Error('invalid secret key');\n};\n","import { generateMnemonic as genMnemonic } from '@scure/bip39';\nimport { wordlist } from '@scure/bip39/wordlists/english';\n\nexport const generateMnemonic = (numberOfWords: 12 | 24 = 24) => {\n const strength = numberOfWords === 12 ? 128 : 256;\n return genMnemonic(wordlist, strength);\n};\n","import { TransactionBlock } from '@mysten/sui.js/transactions';\nimport { SUI_SYSTEM_STATE_OBJECT_ID } from '@mysten/sui.js/utils';\nimport { convertArgs, convertAddressArg, convertObjArg } from './util';\nimport type { SuiClient, SuiObjectRef } from '@mysten/sui.js/client';\nimport type { TransactionObjectArgument } from '@mysten/sui.js/transactions';\nimport type {\n TransactionExpiration,\n SharedObjectRef,\n} from '@mysten/sui.js/bcs';\nimport type { Keypair } from '@mysten/sui.js/cryptography';\nimport type {\n ObjectCallArg,\n TransactionType,\n SuiTxArg,\n SuiAddressArg,\n SuiObjectArg,\n SuiVecTxArg,\n} from 'src/types';\n\nexport class SuiTxBlock {\n public txBlock: TransactionBlock;\n\n constructor(transaction?: TransactionBlock) {\n this.txBlock = new TransactionBlock(transaction);\n }\n\n /* Directly wrap methods and properties of TransactionBlock */\n get gas() {\n return this.txBlock.gas;\n }\n get blockData() {\n return this.txBlock.blockData;\n }\n\n address(value: string) {\n return this.txBlock.pure(value, 'address');\n }\n pure(value: unknown, type?: string) {\n return this.txBlock.pure(value, type);\n }\n object(value: string | ObjectCallArg) {\n return this.txBlock.object(value);\n }\n objectRef(ref: SuiObjectRef) {\n return this.txBlock.objectRef(ref);\n }\n sharedObjectRef(ref: SharedObjectRef) {\n return this.txBlock.sharedObjectRef(ref);\n }\n setSender(sender: string) {\n return this.txBlock.setSender(sender);\n }\n setSenderIfNotSet(sender: string) {\n return this.txBlock.setSenderIfNotSet(sender);\n }\n setExpiration(expiration?: TransactionExpiration) {\n return this.txBlock.setExpiration(expiration);\n }\n setGasPrice(price: number | bigint) {\n return this.txBlock.setGasPrice(price);\n }\n setGasBudget(budget: number | bigint) {\n return this.txBlock.setGasBudget(budget);\n }\n setGasOwner(owner: string) {\n return this.txBlock.setGasOwner(owner);\n }\n setGasPayment(payments: SuiObjectRef[]) {\n return this.txBlock.setGasPayment(payments);\n }\n serialize() {\n return this.txBlock.serialize();\n }\n sign(params: {\n signer: Keypair;\n client?: SuiClient;\n onlyTransactionKind?: boolean;\n }) {\n return this.txBlock.sign(params);\n }\n build(\n params: {\n client?: SuiClient;\n onlyTransactionKind?: boolean;\n } = {}\n ) {\n return this.txBlock.build(params);\n }\n getDigest(params: { client?: SuiClient } = {}) {\n return this.txBlock.getDigest(params);\n }\n add(...args: TransactionType) {\n return this.txBlock.add(...args);\n }\n publish({\n modules,\n dependencies,\n }: {\n modules: number[][] | string[];\n dependencies: string[];\n }) {\n return this.txBlock.publish({ modules, dependencies });\n }\n upgrade({\n modules,\n dependencies,\n packageId,\n ticket,\n }: {\n modules: number[][] | string[];\n dependencies: string[];\n packageId: string;\n ticket: TransactionObjectArgument | string;\n }) {\n return this.txBlock.upgrade({ modules, dependencies, packageId, ticket });\n }\n makeMoveVec({\n objects,\n type,\n }: {\n objects: (TransactionObjectArgument | string)[];\n type?: string;\n }) {\n return this.txBlock.makeMoveVec({ objects, type });\n }\n\n /* Override methods of TransactionBlock */\n\n transferObjects(objects: SuiObjectArg[], address: SuiAddressArg) {\n return this.txBlock.transferObjects(\n objects.map((object) => convertObjArg(this.txBlock, object)),\n convertAddressArg(this.txBlock, address)\n );\n }\n\n splitCoins(coin: SuiObjectArg, amounts: SuiTxArg[]) {\n const res = this.txBlock.splitCoins(\n convertObjArg(this.txBlock, coin),\n convertArgs(this.txBlock, amounts)\n );\n return amounts.map((_, i) => res[i]);\n }\n\n mergeCoins(destination: SuiObjectArg, sources: SuiObjectArg[]) {\n const destinationObject = convertObjArg(this.txBlock, destination);\n const sourceObjects = sources.map((source) =>\n convertObjArg(this.txBlock, source)\n );\n return this.txBlock.mergeCoins(destinationObject, sourceObjects);\n }\n\n /**\n * @description Move call\n * @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`\n * @param args the arguments of the move call, such as `['0x1', '0x2']`\n * @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`\n */\n moveCall(\n target: string,\n args: (SuiTxArg | SuiVecTxArg)[] = [],\n typeArgs: string[] = []\n ) {\n // a regex for pattern `${string}::${string}::${string}`\n const regex =\n /(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/;\n const match = target.match(regex);\n if (match === null)\n throw new Error(\n 'Invalid target format. Expected `${string}::${string}::${string}`'\n );\n const convertedArgs = convertArgs(this.txBlock, args);\n return this.txBlock.moveCall({\n target: target as `${string}::${string}::${string}`,\n arguments: convertedArgs,\n typeArguments: typeArgs,\n });\n }\n\n /* Enhance methods of TransactionBlock */\n\n transferSuiToMany(recipients: SuiAddressArg[], amounts: SuiTxArg[]) {\n // require recipients.length === amounts.length\n if (recipients.length !== amounts.length) {\n throw new Error(\n 'transferSuiToMany: recipients.length !== amounts.length'\n );\n }\n const coins = this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, amounts)\n );\n const recipientObjects = recipients.map((recipient) =>\n convertAddressArg(this.txBlock, recipient)\n );\n recipientObjects.forEach((address, index) => {\n this.txBlock.transferObjects([coins[index]], address);\n });\n return this;\n }\n\n transferSui(address: SuiAddressArg, amount: SuiTxArg) {\n return this.transferSuiToMany([address], [amount]);\n }\n\n takeAmountFromCoins(coins: SuiObjectArg[], amount: SuiTxArg) {\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const mergedCoin = coinObjects[0];\n if (coins.length > 1) {\n this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));\n }\n const [sendCoin] = this.txBlock.splitCoins(\n mergedCoin,\n convertArgs(this.txBlock, [amount])\n );\n return [sendCoin, mergedCoin];\n }\n\n splitSUIFromGas(amounts: SuiTxArg[]) {\n return this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, amounts)\n );\n }\n\n splitMultiCoins(coins: SuiObjectArg[], amounts: SuiTxArg[]) {\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const mergedCoin = coinObjects[0];\n if (coins.length > 1) {\n this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));\n }\n const splitedCoins = this.txBlock.splitCoins(\n mergedCoin,\n convertArgs(this.txBlock, amounts)\n );\n return { splitedCoins, mergedCoin };\n }\n\n transferCoinToMany(\n coins: SuiObjectArg[],\n sender: SuiAddressArg,\n recipients: SuiAddressArg[],\n amounts: SuiTxArg[]\n ) {\n // require recipients.length === amounts.length\n if (recipients.length !== amounts.length) {\n throw new Error(\n 'transferSuiToMany: recipients.length !== amounts.length'\n );\n }\n const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));\n const { splitedCoins, mergedCoin } = this.splitMultiCoins(\n coinObjects,\n amounts\n );\n const recipientObjects = recipients.map((recipient) =>\n convertAddressArg(this.txBlock, recipient)\n );\n recipientObjects.forEach((address, index) => {\n this.txBlock.transferObjects([splitedCoins[index]], address);\n });\n this.txBlock.transferObjects(\n [mergedCoin],\n convertAddressArg(this.txBlock, sender)\n );\n return this;\n }\n\n transferCoin(\n coins: SuiObjectArg[],\n sender: SuiAddressArg,\n recipient: SuiAddressArg,\n amount: SuiTxArg\n ) {\n return this.transferCoinToMany(coins, sender, [recipient], [amount]);\n }\n\n stakeSui(amount: SuiTxArg, validatorAddr: SuiAddressArg) {\n const [stakeCoin] = this.txBlock.splitCoins(\n this.txBlock.gas,\n convertArgs(this.txBlock, [amount])\n );\n return this.txBlock.moveCall({\n target: '0x3::sui_system::request_add_stake',\n arguments: convertArgs(this.txBlock, [\n SUI_SYSTEM_STATE_OBJECT_ID,\n stakeCoin,\n this.txBlock.pure(validatorAddr),\n ]),\n });\n }\n}\n","import {\n normalizeSuiObjectId,\n normalizeSuiAddress,\n isValidSuiObjectId,\n isValidSuiAddress,\n} from '@mysten/sui.js/utils';\nimport { Inputs } from '@mysten/sui.js/transactions';\nimport { isPureArg } from '@mysten/sui.js/bcs';\nimport { isSerializedBcs } from '@mysten/bcs';\nimport type {\n TransactionArgument,\n TransactionBlock,\n TransactionObjectArgument,\n} from '@mysten/sui.js/transactions';\nimport type {\n SuiInputTypes,\n SuiObjectArg,\n SuiAddressArg,\n SuiTxArg,\n SuiVecTxArg,\n} from 'src/types';\n\nexport const getDefaultSuiInputType = (\n value: SuiTxArg\n): SuiInputTypes | undefined => {\n if (typeof value === 'string' && isValidSuiObjectId(value)) {\n return 'object';\n } else if (typeof value === 'number' || typeof value === 'bigint') {\n return 'u64';\n } else if (typeof value === 'boolean') {\n return 'bool';\n } else {\n return undefined;\n }\n};\n\n/**\n * Since we know the elements in the array are the same type\n * If type is not provided, we will try to infer the type from the first element\n * By default,\n *\n * string is hex and its length equal to 32 =====> object id\n * number, bigint ====> u64\n * boolean =====> bool\n *\n * If type is provided, we will use the type to convert the array\n * @param args\n * @param type 'address' | 'bool' | 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'u256' | 'signer' | 'object' | string\n */\nexport function makeVecParam(\n txBlock: TransactionBlock,\n args: SuiTxArg[],\n type?: SuiInputTypes\n): TransactionArgument {\n if (args.length === 0)\n throw new Error('Transaction builder error: Empty array is not allowed');\n // Using first element value as default type\n const defaultSuiType = getDefaultSuiInputType(args[0]);\n const VECTOR_REGEX = /^vector<(.+)>$/;\n const STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;\n\n type = type || defaultSuiType;\n\n if (type === 'object') {\n const objects = args.map((arg) =>\n typeof arg === 'string' && isValidSuiObjectId(arg)\n ? txBlock.object(normalizeSuiObjectId(arg))\n : convertObjArg(txBlock, arg as SuiObjectArg)\n );\n return txBlock.makeMoveVec({ objects });\n } else if (\n typeof type === 'string' &&\n !VECTOR_REGEX.test(type) &&\n !STRUCT_REGEX.test(type)\n ) {\n return txBlock.pure(args, `vector<${type}>`);\n } else {\n const objects = args.map((arg) =>\n convertObjArg(txBlock, arg as SuiObjectArg)\n );\n return txBlock.makeMoveVec({ objects, type });\n }\n}\n\n/**\n * Check whether it is an valid move vec input.\n *\n * @param arg The argument to check.\n * @returns boolean.\n */\nexport function isMoveVecArg(arg: SuiTxArg | SuiVecTxArg): arg is SuiVecTxArg {\n if (typeof arg === 'object' && 'vecType' in arg && 'value' in arg) {\n return true;\n } else if (Array.isArray(arg)) {\n return true;\n }\n return false;\n}\n\n/**\n * Convert any valid input into array of TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param args The array of argument to convert.\n * @returns The converted array of TransactionArgument.\n */\nexport function convertArgs(\n txBlock: TransactionBlock,\n args: (SuiTxArg | SuiVecTxArg)[]\n) {\n return args.map((arg) => {\n if (typeof arg === 'string' && isValidSuiObjectId(arg)) {\n return txBlock.object(normalizeSuiObjectId(arg));\n } else if (\n typeof arg == 'object' &&\n !isSerializedBcs(arg) &&\n !isPureArg(arg) &&\n !isMoveVecArg(arg)\n ) {\n return convertObjArg(txBlock, arg as SuiObjectArg);\n } else if (isMoveVecArg(arg)) {\n const vecType = 'vecType' in arg;\n return vecType\n ? makeVecParam(txBlock, arg.value, arg.vecType)\n : makeVecParam(txBlock, arg);\n } else if (isSerializedBcs(arg)) {\n return arg;\n } else {\n return txBlock.pure(arg);\n }\n });\n}\n\n/**\n * Convert any valid address input into a TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param arg The address argument to convert.\n * @returns The converted TransactionArgument.\n */\nexport function convertAddressArg(\n txBlock: TransactionBlock,\n arg: SuiAddressArg\n) {\n if (typeof arg === 'string' && isValidSuiAddress(arg)) {\n return txBlock.pure.address(normalizeSuiAddress(arg));\n } else if (\n typeof arg == 'object' &&\n !isSerializedBcs(arg) &&\n !isPureArg(arg)\n ) {\n return convertObjArg(txBlock, arg as SuiObjectArg);\n } else if (isPureArg(arg)) {\n return txBlock.pure(arg);\n } else {\n return arg;\n }\n}\n\n/**\n * Convert any valid object input into a TransactionArgument.\n *\n * @param txb The Transaction Block\n * @param arg The object argument to convert.\n * @returns The converted TransactionArgument.\n */\nexport function convertObjArg(\n txb: TransactionBlock,\n arg: SuiObjectArg\n): TransactionObjectArgument {\n if (typeof arg === 'string') {\n return txb.object(arg);\n }\n\n if ('digest' in arg && 'version' in arg && 'objectId' in arg) {\n return txb.objectRef(arg);\n }\n\n if ('objectId' in arg && 'initialSharedVersion' in arg && 'mutable' in arg) {\n return txb.sharedObjectRef(arg);\n }\n\n if ('Object' in arg) {\n if ('ImmOrOwned' in arg.Object) {\n return txb.object(Inputs.ObjectRef(arg.Object.ImmOrOwned));\n } else if ('Shared' in arg.Object) {\n return txb.object(Inputs.SharedObjectRef(arg.Object.Shared));\n } else {\n throw new Error('Invalid argument type');\n }\n }\n\n if ('kind' in arg) {\n return arg;\n }\n\n throw new Error('Invalid argument type');\n}\n","import { SuiClient } from '@mysten/sui.js/client';\nimport { SuiOwnedObject, SuiSharedObject } from '../suiModel';\nimport { delay } from './util';\nimport type {\n SuiTransactionBlockResponseOptions,\n SuiTransactionBlockResponse,\n SuiObjectDataOptions,\n SuiObjectData,\n DryRunTransactionBlockResponse,\n} from '@mysten/sui.js/client';\n\n/**\n * Encapsulates all functions that interact with the sui sdk\n */\nexport class SuiInteractor {\n public readonly clients: SuiClient[];\n public currentClient: SuiClient;\n public readonly fullNodes: string[];\n public currentFullNode: string;\n\n constructor(fullNodeUrls: string[]) {\n if (fullNodeUrls.length === 0)\n throw new Error('fullNodeUrls must not be empty');\n this.fullNodes = fullNodeUrls;\n this.clients = fullNodeUrls.map((url) => new SuiClient({ url }));\n this.currentFullNode = fullNodeUrls[0];\n this.currentClient = this.clients[0];\n }\n\n switchToNextClient() {\n const currentClientIdx = this.clients.indexOf(this.currentClient);\n this.currentClient =\n this.clients[(currentClientIdx + 1) % this.clients.length];\n this.currentFullNode =\n this.fullNodes[(currentClientIdx + 1) % this.clients.length];\n }\n\n async sendTx(\n transactionBlock: Uint8Array | string,\n signature: string | string[]\n ): Promise<SuiTransactionBlockResponse> {\n const txResOptions: SuiTransactionBlockResponseOptions = {\n showEvents: true,\n showEffects: true,\n showObjectChanges: true,\n showBalanceChanges: true,\n };\n\n for (const clientIdx in this.clients) {\n try {\n return await this.clients[clientIdx].executeTransactionBlock({\n transactionBlock,\n signature,\n options: txResOptions,\n });\n } catch (err) {\n console.warn(\n `Failed to send transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n await delay(2000);\n }\n }\n throw new Error('Failed to send transaction with all fullnodes');\n }\n\n async dryRunTx(\n transactionBlock: Uint8Array\n ): Promise<DryRunTransactionBlockResponse> {\n for (const clientIdx in this.clients) {\n try {\n return await this.clients[clientIdx].dryRunTransactionBlock({\n transactionBlock,\n });\n } catch (err) {\n console.warn(\n `Failed to dry run transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n await delay(2000);\n }\n }\n throw new Error('Failed to dry run transaction with all fullnodes');\n }\n\n async getObjects(\n ids: string[],\n options?: SuiObjectDataOptions\n ): Promise<SuiObjectData[]> {\n const opts: SuiObjectDataOptions = options ?? {\n showContent: true,\n showDisplay: true,\n showType: true,\n showOwner: true,\n };\n\n for (const clientIdx in this.clients) {\n try {\n const objects = await this.clients[clientIdx].multiGetObjects({\n ids,\n options: opts,\n });\n const parsedObjects = objects\n .map((object) => {\n return object.data;\n })\n .filter((object) => object !== null && object !== undefined);\n return parsedObjects as SuiObjectData[];\n } catch (err) {\n await delay(2000);\n console.warn(\n `Failed to get objects with fullnode ${this.fullNodes[clientIdx]}: ${err}`\n );\n }\n }\n throw new Error('Failed to get objects with all fullnodes');\n }\n\n async getObject(id: string, options?: SuiObjectDataOptions) {\n const objects = await this.getObjects([id], options);\n return objects[0];\n }\n\n /**\n * @description Update objects in a batch\n * @param suiObjects\n */\n async updateObjects(suiObjects: (SuiOwnedObject | SuiSharedObject)[]) {\n const objectIds = suiObjects.map((obj) => obj.objectId);\n const objects = await this.getObjects(objectIds);\n for (const object of objects) {\n const suiObject = suiObjects.find(\n (obj) => obj.objectId === object?.objectId\n );\n if (suiObject instanceof SuiSharedObject) {\n if (\n object.owner &&\n typeof object.owner === 'object' &&\n 'Shared' in object.owner\n ) {\n suiObject.initialSharedVersion =\n object.owner.Shared.initial_shared_version;\n } else {\n suiObject.initialSharedVersion = undefined;\n }\n } else if (suiObject instanceof SuiOwnedObject) {\n suiObject.version = object?.version;\n suiObject.digest = object?.digest;\n }\n }\n }\n\n /**\n * @description Select coins that add up to the given amount.\n * @param addr the address of the owner\n * @param amount the amount that is needed for the coin\n * @param coinType the coin type, default is '0x2::SUI::SUI'\n */\n async selectCoins(\n addr: string,\n amount: number,\n coinType: string = '0x2::SUI::SUI'\n ) {\n const selectedCoins: {\n objectId: string;\n digest: string;\n version: string;\n }[] = [];\n let totalAmount = 0;\n let hasNext = true,\n nextCursor: string | null | undefined = null;\n while (hasNext && totalAmount < amount) {\n const coins = await this.currentClient.getCoins({\n owner: addr,\n coinType: coinType,\n cursor: nextCursor,\n });\n // Sort the coins by balance in descending order\n coins.data.sort((a, b) => parseInt(b.balance) - parseInt(a.balance));\n for (const coinData of coins.data) {\n selectedCoins.push({\n objectId: coinData.coinObjectId,\n digest: coinData.digest,\n version: coinData.version,\n });\n totalAmount = totalAmount + parseInt(coinData.balance);\n if (totalAmount >= amount) {\n break;\n }\n }\n\n nextCursor = coins.nextCursor;\n hasNext = coins.hasNextPage;\n }\n\n if (!selectedCoins.length) {\n throw new Error('No valid coins found for the transaction.');\n }\n return selectedCoins;\n }\n}\n","import type { SuiTransactionBlockResponse } from '@mysten/sui.js/client';\nimport type { CallArg } from '@mysten/sui.js/bcs';\n\nexport class SuiOwnedObject {\n public readonly objectId: string;\n public version?: string;\n public digest?: string;\n\n constructor(param: { objectId: string; version?: string; digest?: string }) {\n this.objectId = param.objectId;\n this.version = param.version;\n this.digest = param.digest;\n }\n\n /**\n * Check if the object is fully initialized.\n * So that when it's used as an input, it won't be necessary to fetch from fullnode again.\n * Which can save time when sending transactions.\n */\n isFullObject(): boolean {\n return !!this.version && !!this.digest;\n }\n\n asCallArg(): CallArg | string {\n if (!this.version || !this.digest) {\n return this.objectId;\n }\n return {\n Object: {\n ImmOrOwned: {\n objectId: this.objectId,\n version: this.version,\n digest: this.digest,\n },\n },\n };\n }\n\n /**\n * Update object version & digest based on the transaction response.\n * @param txResponse\n */\n updateFromTxResponse(txResponse: SuiTransactionBlockResponse) {\n const changes = txResponse.objectChanges;\n if (!changes) {\n throw new Error('Bad transaction response!');\n }\n for (const change of changes) {\n if (change.type === 'mutated' && change.objectId === this.objectId) {\n this.digest = change.digest;\n this.version = change.version;\n return;\n }\n }\n throw new Error('Could not find object in transaction response!');\n }\n}\n","import type { CallArg } from '@mysten/sui.js/bcs';\n\nexport class SuiSharedObject {\n public readonly objectId: string;\n public initialSharedVersion?: string;\n\n constructor(param: {\n objectId: string;\n initialSharedVersion?: string;\n mutable?: boolean;\n }) {\n this.objectId = param.objectId;\n this.initialSharedVersion = param.initialSharedVersion;\n }\n\n asCallArg(mutable: boolean = false): CallArg | string {\n if (!this.initialSharedVersion) {\n return this.objectId;\n }\n return {\n Object: {\n Shared: {\n objectId: this.objectId,\n initialSharedVersion: this.initialSharedVersion,\n mutable,\n },\n },\n };\n }\n}\n","export const delay = (ms: number) =>\n new Promise((resolve) => setTimeout(resolve, ms));\n","import { MultiSigPublicKey } from '@mysten/sui.js/multisig';\nimport type { PublicKey } from '@mysten/sui.js/src/cryptography';\nimport { ed25519PublicKeyFromBase64 } from './publickey';\n\nexport type PublicKeyWeightPair = {\n publicKey: PublicKey;\n weight: number;\n};\n\nexport class MultiSigClient {\n public readonly pksWeightPairs: PublicKeyWeightPair[];\n public readonly threshold: number;\n public readonly multiSigPublicKey: MultiSigPublicKey;\n constructor(pks: PublicKeyWeightPair[], threshold: number) {\n this.pksWeightPairs = pks;\n this.threshold = threshold;\n this.multiSigPublicKey = MultiSigPublicKey.fromPublicKeys({\n threshold: this.threshold,\n publicKeys: this.pksWeightPairs,\n });\n }\n\n static fromRawEd25519PublicKeys(\n rawPublicKeys: string[],\n weights: number[],\n threshold: number\n ): MultiSigClient {\n const pks = rawPublicKeys.map((rawPublicKey, i) => {\n return {\n publicKey: ed25519PublicKeyFromBase64(rawPublicKey),\n weight: weights[i],\n };\n });\n return new MultiSigClient(pks, threshold);\n }\n\n multiSigAddress(): string {\n return this.multiSigPublicKey.toSuiAddress();\n }\n\n combinePartialSigs(sigs: string[]): string {\n return this.multiSigPublicKey.combinePartialSignatures(sigs);\n }\n}\n","import { PublicKey } from '@mysten/sui.js/cryptography';\nimport { Ed25519PublicKey } from '@mysten/sui.js/keypairs/ed25519';\nimport { fromB64 } from '@mysten/sui.js/utils';\n\nexport function ed25519PublicKeyFromBase64(rawPubkey: string): PublicKey {\n let bytes = fromB64(rawPubkey);\n // rawPubkeys should either be 32 bytes or 33 bytes (with the first byte being flag)\n if (bytes.length !== 32 && bytes.length !== 33) throw 'invalid pubkey length';\n bytes = bytes.length === 33 ? bytes.slice(1) : bytes;\n return new Ed25519PublicKey(bytes);\n}\n"],"mappings":";AAAA,cAAc;AACd,cAAc;;;ACEd,SAAS,sBAAsB;AAC/B,SAAS,oBAAAA,yBAAwB;;;ACJjC,SAAS,kBAAAC,uBAAsB;;;ACA/B,SAAS,sBAAsB;AAOxB,IAAM,sBAAsB,CACjC,mBAAqC,CAAC,MACnC;AACH,QAAM;AAAA,IACJ,eAAe;AAAA,IACf,aAAa;AAAA,IACb,eAAe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;AAAA,EASA,MAAM,WACJ,IACA,kBAC4B;AAC5B,UAAM,UAAU,cAAc,aAAa,GAAG,UAAU;AACxD,WAAO,KAAK,cAAc,cAAc,2BAA2B;AAAA,MACjE,kBAAkB;AAAA,MAClB,QAAQ,KAAK,WAAW,gBAAgB;AAAA,IAC1C,CAAC;AAAA,EACH;AACF;;;AWxSA,SAAS,yBAAyB;;;ACClC,SAAS,wBAAwB;AACjC,SAAS,WAAAC,gBAAe;AAEjB,SAAS,2BAA2B,WAA8B;AACvE,MAAI,QAAQA,SAAQ,SAAS;AAE7B,MAAI,MAAM,WAAW,MAAM,MAAM,WAAW;AAAI,UAAM;AACtD,UAAQ,MAAM,WAAW,KAAK,MAAM,MAAM,CAAC,IAAI;AAC/C,SAAO,IAAI,iBAAiB,KAAK;AACnC;;;ADDO,IAAM,iBAAN,MAAM,gBAAe;AAAA,EAI1B,YAAY,KAA4B,WAAmB;AACzD,SAAK,iBAAiB;AACtB,SAAK,YAAY;AACjB,SAAK,oBAAoB,kBAAkB,eAAe;AAAA,MACxD,WAAW,KAAK;AAAA,MAChB,YAAY,KAAK;AAAA,IACnB,CAAC;AAAA,EACH;AAAA,EAEA,OAAO,yBACL,eACA,SACA,WACgB;AAChB,UAAM,MAAM,cAAc,IAAI,CAAC,cAAc,MAAM;AACjD,aAAO;AAAA,QACL,WAAW,2BAA2B,YAAY;AAAA,QAClD,QAAQ,QAAQ,CAAC;AAAA,MACnB;AAAA,IACF,CAAC;AACD,WAAO,IAAI,gBAAe,KAAK,SAAS;AAAA,EAC1C;AAAA,EAEA,kBAA0B;AACxB,WAAO,KAAK,kBAAkB,aAAa;AAAA,EAC7C;AAAA,EAEA,mBAAmB,MAAwB;AACzC,WAAO,KAAK,kBAAkB,yBAAyB,IAAI;AAAA,EAC7D;AACF;","names":["TransactionBlock","Ed25519Keypair","Ed25519Keypair","TransactionBlock","fromB64"]}
|
|
@@ -12,9 +12,13 @@ export declare class SuiAccountManager {
|
|
|
12
12
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
13
13
|
*
|
|
14
14
|
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
15
|
-
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
|
|
15
|
+
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored
|
|
16
16
|
*/
|
|
17
17
|
constructor({ mnemonics, secretKey }?: AccountMangerParams);
|
|
18
|
+
/**
|
|
19
|
+
* Check if the secretKey starts with bench32 format
|
|
20
|
+
*/
|
|
21
|
+
parseSecretKey(secretKey: string): Ed25519Keypair;
|
|
18
22
|
/**
|
|
19
23
|
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.
|
|
20
24
|
* else:
|
|
@@ -13,26 +13,25 @@ export declare class SuiTxBlock {
|
|
|
13
13
|
inputs: ({
|
|
14
14
|
index: number;
|
|
15
15
|
kind: "Input";
|
|
16
|
-
type?: "object" | undefined;
|
|
17
16
|
value?: any;
|
|
17
|
+
type?: "object" | undefined;
|
|
18
18
|
} | {
|
|
19
|
-
type: "pure";
|
|
20
19
|
index: number;
|
|
21
20
|
kind: "Input";
|
|
21
|
+
type: "pure";
|
|
22
22
|
value?: any;
|
|
23
23
|
})[];
|
|
24
24
|
transactions: ({
|
|
25
|
-
typeArguments: string[];
|
|
26
25
|
kind: "MoveCall";
|
|
27
26
|
arguments: ({
|
|
28
27
|
index: number;
|
|
29
28
|
kind: "Input";
|
|
30
|
-
type?: "object" | undefined;
|
|
31
29
|
value?: any;
|
|
30
|
+
type?: "object" | undefined;
|
|
32
31
|
} | {
|
|
33
|
-
type: "pure";
|
|
34
32
|
index: number;
|
|
35
33
|
kind: "Input";
|
|
34
|
+
type: "pure";
|
|
36
35
|
value?: any;
|
|
37
36
|
} | {
|
|
38
37
|
kind: "GasCoin";
|
|
@@ -45,16 +44,17 @@ export declare class SuiTxBlock {
|
|
|
45
44
|
kind: "NestedResult";
|
|
46
45
|
})[];
|
|
47
46
|
target: `${string}::${string}::${string}`;
|
|
47
|
+
typeArguments: string[];
|
|
48
48
|
} | {
|
|
49
49
|
address: {
|
|
50
50
|
index: number;
|
|
51
51
|
kind: "Input";
|
|
52
|
-
type?: "object" | undefined;
|
|
53
52
|
value?: any;
|
|
53
|
+
type?: "object" | undefined;
|
|
54
54
|
} | {
|
|
55
|
-
type: "pure";
|
|
56
55
|
index: number;
|
|
57
56
|
kind: "Input";
|
|
57
|
+
type: "pure";
|
|
58
58
|
value?: any;
|
|
59
59
|
} | {
|
|
60
60
|
kind: "GasCoin";
|
|
@@ -70,12 +70,12 @@ export declare class SuiTxBlock {
|
|
|
70
70
|
objects: ({
|
|
71
71
|
index: number;
|
|
72
72
|
kind: "Input";
|
|
73
|
-
type?: "object" | undefined;
|
|
74
73
|
value?: any;
|
|
74
|
+
type?: "object" | undefined;
|
|
75
75
|
} | {
|
|
76
|
-
type: "pure";
|
|
77
76
|
index: number;
|
|
78
77
|
kind: "Input";
|
|
78
|
+
type: "pure";
|
|
79
79
|
value?: any;
|
|
80
80
|
} | {
|
|
81
81
|
kind: "GasCoin";
|
|
@@ -92,12 +92,12 @@ export declare class SuiTxBlock {
|
|
|
92
92
|
coin: {
|
|
93
93
|
index: number;
|
|
94
94
|
kind: "Input";
|
|
95
|
-
type?: "object" | undefined;
|
|
96
95
|
value?: any;
|
|
96
|
+
type?: "object" | undefined;
|
|
97
97
|
} | {
|
|
98
|
-
type: "pure";
|
|
99
98
|
index: number;
|
|
100
99
|
kind: "Input";
|
|
100
|
+
type: "pure";
|
|
101
101
|
value?: any;
|
|
102
102
|
} | {
|
|
103
103
|
kind: "GasCoin";
|
|
@@ -112,12 +112,12 @@ export declare class SuiTxBlock {
|
|
|
112
112
|
amounts: ({
|
|
113
113
|
index: number;
|
|
114
114
|
kind: "Input";
|
|
115
|
-
type?: "object" | undefined;
|
|
116
115
|
value?: any;
|
|
116
|
+
type?: "object" | undefined;
|
|
117
117
|
} | {
|
|
118
|
-
type: "pure";
|
|
119
118
|
index: number;
|
|
120
119
|
kind: "Input";
|
|
120
|
+
type: "pure";
|
|
121
121
|
value?: any;
|
|
122
122
|
} | {
|
|
123
123
|
kind: "GasCoin";
|
|
@@ -134,12 +134,12 @@ export declare class SuiTxBlock {
|
|
|
134
134
|
destination: {
|
|
135
135
|
index: number;
|
|
136
136
|
kind: "Input";
|
|
137
|
-
type?: "object" | undefined;
|
|
138
137
|
value?: any;
|
|
138
|
+
type?: "object" | undefined;
|
|
139
139
|
} | {
|
|
140
|
-
type: "pure";
|
|
141
140
|
index: number;
|
|
142
141
|
kind: "Input";
|
|
142
|
+
type: "pure";
|
|
143
143
|
value?: any;
|
|
144
144
|
} | {
|
|
145
145
|
kind: "GasCoin";
|
|
@@ -154,12 +154,12 @@ export declare class SuiTxBlock {
|
|
|
154
154
|
sources: ({
|
|
155
155
|
index: number;
|
|
156
156
|
kind: "Input";
|
|
157
|
-
type?: "object" | undefined;
|
|
158
157
|
value?: any;
|
|
158
|
+
type?: "object" | undefined;
|
|
159
159
|
} | {
|
|
160
|
-
type: "pure";
|
|
161
160
|
index: number;
|
|
162
161
|
kind: "Input";
|
|
162
|
+
type: "pure";
|
|
163
163
|
value?: any;
|
|
164
164
|
} | {
|
|
165
165
|
kind: "GasCoin";
|
|
@@ -172,21 +172,23 @@ export declare class SuiTxBlock {
|
|
|
172
172
|
kind: "NestedResult";
|
|
173
173
|
})[];
|
|
174
174
|
} | {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
175
|
+
kind: "Publish";
|
|
176
|
+
modules: number[][];
|
|
177
|
+
dependencies: string[];
|
|
178
|
+
} | {
|
|
179
|
+
kind: "Upgrade";
|
|
180
|
+
modules: number[][];
|
|
181
|
+
dependencies: string[];
|
|
182
|
+
packageId: string;
|
|
183
|
+
ticket: {
|
|
182
184
|
index: number;
|
|
183
185
|
kind: "Input";
|
|
184
|
-
type?: "object" | undefined;
|
|
185
186
|
value?: any;
|
|
187
|
+
type?: "object" | undefined;
|
|
186
188
|
} | {
|
|
187
|
-
type: "pure";
|
|
188
189
|
index: number;
|
|
189
190
|
kind: "Input";
|
|
191
|
+
type: "pure";
|
|
190
192
|
value?: any;
|
|
191
193
|
} | {
|
|
192
194
|
kind: "GasCoin";
|
|
@@ -197,25 +199,23 @@ export declare class SuiTxBlock {
|
|
|
197
199
|
index: number;
|
|
198
200
|
resultIndex: number;
|
|
199
201
|
kind: "NestedResult";
|
|
200
|
-
}
|
|
201
|
-
} | {
|
|
202
|
-
kind: "Publish";
|
|
203
|
-
modules: number[][];
|
|
204
|
-
dependencies: string[];
|
|
202
|
+
};
|
|
205
203
|
} | {
|
|
206
|
-
kind: "
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
204
|
+
kind: "MakeMoveVec";
|
|
205
|
+
type: {
|
|
206
|
+
Some: import("@mysten/sui.js/bcs").TypeTag;
|
|
207
|
+
} | {
|
|
208
|
+
None: true | null;
|
|
209
|
+
};
|
|
210
|
+
objects: ({
|
|
211
211
|
index: number;
|
|
212
212
|
kind: "Input";
|
|
213
|
-
type?: "object" | undefined;
|
|
214
213
|
value?: any;
|
|
214
|
+
type?: "object" | undefined;
|
|
215
215
|
} | {
|
|
216
|
-
type: "pure";
|
|
217
216
|
index: number;
|
|
218
217
|
kind: "Input";
|
|
218
|
+
type: "pure";
|
|
219
219
|
value?: any;
|
|
220
220
|
} | {
|
|
221
221
|
kind: "GasCoin";
|
|
@@ -226,15 +226,15 @@ export declare class SuiTxBlock {
|
|
|
226
226
|
index: number;
|
|
227
227
|
resultIndex: number;
|
|
228
228
|
kind: "NestedResult";
|
|
229
|
-
};
|
|
229
|
+
})[];
|
|
230
230
|
})[];
|
|
231
231
|
gasConfig: {
|
|
232
|
-
owner?: string | undefined;
|
|
233
232
|
payment?: {
|
|
234
233
|
digest: string;
|
|
235
234
|
objectId: string;
|
|
236
235
|
version: string | number | bigint;
|
|
237
236
|
}[] | undefined;
|
|
237
|
+
owner?: string | undefined;
|
|
238
238
|
price?: string | number | bigint | undefined;
|
|
239
239
|
budget?: string | number | bigint | undefined;
|
|
240
240
|
};
|
|
@@ -248,43 +248,28 @@ export declare class SuiTxBlock {
|
|
|
248
248
|
address(value: string): {
|
|
249
249
|
index: number;
|
|
250
250
|
kind: "Input";
|
|
251
|
-
type?: "object" | undefined;
|
|
252
251
|
value?: any;
|
|
253
|
-
} | {
|
|
254
|
-
type: "pure";
|
|
255
|
-
index: number;
|
|
256
|
-
kind: "Input";
|
|
257
|
-
value?: any;
|
|
258
|
-
};
|
|
259
|
-
pure(value: unknown, type?: string): {
|
|
260
|
-
index: number;
|
|
261
|
-
kind: "Input";
|
|
262
252
|
type?: "object" | undefined;
|
|
263
|
-
value?: any;
|
|
264
253
|
} | {
|
|
265
|
-
type: "pure";
|
|
266
254
|
index: number;
|
|
267
255
|
kind: "Input";
|
|
256
|
+
type: "pure";
|
|
268
257
|
value?: any;
|
|
269
258
|
};
|
|
270
|
-
|
|
259
|
+
pure(value: unknown, type?: string): {
|
|
271
260
|
index: number;
|
|
272
261
|
kind: "Input";
|
|
273
|
-
type?: "object" | undefined;
|
|
274
262
|
value?: any;
|
|
275
|
-
};
|
|
276
|
-
objectRef(ref: SuiObjectRef): {
|
|
277
|
-
index: number;
|
|
278
|
-
kind: "Input";
|
|
279
263
|
type?: "object" | undefined;
|
|
280
|
-
|
|
281
|
-
};
|
|
282
|
-
sharedObjectRef(ref: SharedObjectRef): {
|
|
264
|
+
} | {
|
|
283
265
|
index: number;
|
|
284
266
|
kind: "Input";
|
|
285
|
-
type
|
|
267
|
+
type: "pure";
|
|
286
268
|
value?: any;
|
|
287
269
|
};
|
|
270
|
+
object(value: string | ObjectCallArg): TransactionObjectArgument;
|
|
271
|
+
objectRef(ref: SuiObjectRef): TransactionObjectArgument;
|
|
272
|
+
sharedObjectRef(ref: SharedObjectRef): TransactionObjectArgument;
|
|
288
273
|
setSender(sender: string): void;
|
|
289
274
|
setSenderIfNotSet(sender: string): void;
|
|
290
275
|
setExpiration(expiration?: TransactionExpiration): void;
|
|
@@ -30,9 +30,9 @@ export declare function isMoveVecArg(arg: SuiTxArg | SuiVecTxArg): arg is SuiVec
|
|
|
30
30
|
* @returns The converted array of TransactionArgument.
|
|
31
31
|
*/
|
|
32
32
|
export declare function convertArgs(txBlock: TransactionBlock, args: (SuiTxArg | SuiVecTxArg)[]): ({
|
|
33
|
-
type: "pure";
|
|
34
33
|
index: number;
|
|
35
34
|
kind: "Input";
|
|
35
|
+
type: "pure";
|
|
36
36
|
value?: any;
|
|
37
37
|
} | TransactionObjectArgument | import("@mysten/bcs").SerializedBcs<unknown, unknown>)[];
|
|
38
38
|
/**
|
|
@@ -43,9 +43,9 @@ export declare function convertArgs(txBlock: TransactionBlock, args: (SuiTxArg |
|
|
|
43
43
|
* @returns The converted TransactionArgument.
|
|
44
44
|
*/
|
|
45
45
|
export declare function convertAddressArg(txBlock: TransactionBlock, arg: SuiAddressArg): TransactionObjectArgument | {
|
|
46
|
-
type: "pure";
|
|
47
46
|
index: number;
|
|
48
47
|
kind: "Input";
|
|
48
|
+
type: "pure";
|
|
49
49
|
value?: any;
|
|
50
50
|
} | import("@mysten/bcs").SerializedBcs<unknown, unknown>;
|
|
51
51
|
/**
|
package/dist/suiKit.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class SuiKit {
|
|
|
19
19
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
20
20
|
*
|
|
21
21
|
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
22
|
-
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
|
|
22
|
+
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored
|
|
23
23
|
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'
|
|
24
24
|
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
|
|
25
25
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "Tookit for interacting with SUI network",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -38,17 +38,18 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@mysten/bcs": "^0.8.1",
|
|
41
|
-
"@mysten/sui.js": "^0.
|
|
41
|
+
"@mysten/sui.js": "^0.52.0",
|
|
42
42
|
"@noble/curves": "^1.2.0",
|
|
43
43
|
"@noble/hashes": "^1.3.2",
|
|
44
44
|
"@scure/bip39": "^1.2.1",
|
|
45
45
|
"assert": "^2.1.0",
|
|
46
|
+
"bech32": "^2.0.0",
|
|
46
47
|
"superstruct": "^1.0.3",
|
|
47
48
|
"ts-retry-promise": "^0.7.1",
|
|
48
49
|
"tweetnacl": "^1.0.3"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"@mysten/sui.js": "^0.
|
|
52
|
+
"@mysten/sui.js": "^0.52.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
55
|
"@commitlint/cli": "^18.0.0",
|
|
@@ -3,6 +3,10 @@ import { getKeyPair } from './keypair';
|
|
|
3
3
|
import { hexOrBase64ToUint8Array, normalizePrivateKey } from './util';
|
|
4
4
|
import { generateMnemonic } from './crypto';
|
|
5
5
|
import type { AccountMangerParams, DerivePathParams } from 'src/types';
|
|
6
|
+
import {
|
|
7
|
+
SUI_PRIVATE_KEY_PREFIX,
|
|
8
|
+
decodeSuiPrivateKey,
|
|
9
|
+
} from '@mysten/sui.js/cryptography';
|
|
6
10
|
|
|
7
11
|
export class SuiAccountManager {
|
|
8
12
|
private mnemonics: string;
|
|
@@ -17,7 +21,7 @@ export class SuiAccountManager {
|
|
|
17
21
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
18
22
|
*
|
|
19
23
|
* @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
|
|
24
|
+
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored
|
|
21
25
|
*/
|
|
22
26
|
constructor({ mnemonics, secretKey }: AccountMangerParams = {}) {
|
|
23
27
|
// If the mnemonics or secretKey is provided, use it
|
|
@@ -30,13 +34,27 @@ export class SuiAccountManager {
|
|
|
30
34
|
|
|
31
35
|
// Init the current account
|
|
32
36
|
this.currentKeyPair = this.secretKey
|
|
33
|
-
?
|
|
34
|
-
normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey))
|
|
35
|
-
)
|
|
37
|
+
? this.parseSecretKey(this.secretKey)
|
|
36
38
|
: getKeyPair(this.mnemonics);
|
|
37
39
|
this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Check if the secretKey starts with bench32 format
|
|
44
|
+
*/
|
|
45
|
+
parseSecretKey(secretKey: string) {
|
|
46
|
+
if (secretKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) {
|
|
47
|
+
const { secretKey: uint8ArraySecretKey } = decodeSuiPrivateKey(secretKey);
|
|
48
|
+
return Ed25519Keypair.fromSecretKey(
|
|
49
|
+
normalizePrivateKey(uint8ArraySecretKey)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return Ed25519Keypair.fromSecretKey(
|
|
54
|
+
normalizePrivateKey(hexOrBase64ToUint8Array(secretKey))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
40
58
|
/**
|
|
41
59
|
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.
|
|
42
60
|
* else:
|
package/src/suiKit.ts
CHANGED
|
@@ -35,7 +35,7 @@ export class SuiKit {
|
|
|
35
35
|
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
36
36
|
*
|
|
37
37
|
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
38
|
-
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored
|
|
38
|
+
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored
|
|
39
39
|
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'
|
|
40
40
|
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type
|
|
41
41
|
*/
|