@scallop-io/sui-kit 1.3.3 → 1.3.4
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 +29 -981
- package/dist/index.mjs +15 -961
- package/dist/libs/suiTxBuilder/index.d.ts +2 -14
- package/package.json +4 -4
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,983 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
SuiAccountManager: () => SuiAccountManager,
|
|
26
|
-
SuiInteractor: () => SuiInteractor,
|
|
27
|
-
SuiKit: () => SuiKit,
|
|
28
|
-
SuiTxBlock: () => SuiTxBlock
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('@mysten/sui/utils');
|
|
4
|
+
var transactions = require('@mysten/sui/transactions');
|
|
5
|
+
var client = require('@mysten/sui/client');
|
|
6
|
+
var ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
7
|
+
var bip39 = require('@scure/bip39');
|
|
8
|
+
var english = require('@scure/bip39/wordlists/english');
|
|
9
|
+
var cryptography = require('@mysten/sui/cryptography');
|
|
10
|
+
var bcs = require('@mysten/bcs');
|
|
11
|
+
var multisig = require('@mysten/sui/multisig');
|
|
12
|
+
|
|
13
|
+
var $=(r={})=>{let{accountIndex:t=0,isExternal:e=!1,addressIndex:i=0}=r;return `m/44'/784'/${t}'/${e?1:0}'/${i}'`},b=(r,t={})=>{let e=$(t);return ed25519.Ed25519Keypair.deriveKeypair(r,e)};var N=r=>/^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(r),F=r=>/^[a-zA-Z0-9+/]+={0,2}$/g.test(r),G=r=>{if(!r)throw new Error("cannot parse empty string to Uint8Array");let t=r.replace("0x","").match(/.{1,2}/g)?.map(e=>parseInt(e,16));if(!t||t.length===0)throw new Error(`Unable to parse HEX: ${r}`);return Uint8Array.from(t)},k=r=>{if(N(r))return G(r);if(F(r))return utils.fromB64(r);throw new Error("The string is not a valid hex or base64 string.")},j=32,z=64,T=r=>{if(r.length===z)r=r.slice(0,j);else {if(r.length===j+1&&r[0]===0)return r.slice(1);if(r.length===j)return r}throw new Error("invalid secret key")};var w=(r=24)=>bip39.generateMnemonic(english.wordlist,r===12?128:256);var S=class{constructor({mnemonics:t,secretKey:e}={}){this.mnemonics=t||"",this.secretKey=e||"",!this.mnemonics&&!this.secretKey&&(this.mnemonics=w(24)),this.currentKeyPair=this.secretKey?this.parseSecretKey(this.secretKey):b(this.mnemonics),this.currentAddress=this.currentKeyPair.getPublicKey().toSuiAddress();}parseSecretKey(t){if(t.startsWith(cryptography.SUI_PRIVATE_KEY_PREFIX)){let{secretKey:e}=cryptography.decodeSuiPrivateKey(t);return ed25519.Ed25519Keypair.fromSecretKey(T(e))}return ed25519.Ed25519Keypair.fromSecretKey(T(k(t)))}getKeyPair(t){return !t||!this.mnemonics?this.currentKeyPair:b(this.mnemonics,t)}getAddress(t){return !t||!this.mnemonics?this.currentAddress:b(this.mnemonics,t).getPublicKey().toSuiAddress()}switchAccount(t){this.mnemonics&&(this.currentKeyPair=b(this.mnemonics,t),this.currentAddress=this.currentKeyPair.getPublicKey().toSuiAddress());}};var et=r=>typeof r=="string"&&utils.isValidSuiObjectId(r)?"object":typeof r=="number"||typeof r=="bigint"?"u64":typeof r=="boolean"?"bool":void 0;function R(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="string"&&!utils.isValidSuiAddress(r)&&!isNaN(Number(r))}function rt(r){return typeof r=="object"&&"vecType"in r&&"value"in r?!0:!!Array.isArray(r)}function it(r){return typeof r=="object"&&"digest"in r&&"version"in r&&"objectId"in r}function nt(r){return typeof r=="object"&&"objectId"in r&&"initialSharedVersion"in r&&"mutable"in r}function I(r,t,e){if(t.length===0)throw new Error("Transaction builder error: Empty array is not allowed");let i=et(t[0]),n=/^vector<(.+)>$/,s=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;if(e=e||i,e==="object"){let o=t.map(a=>typeof a=="string"&&utils.isValidSuiObjectId(a)?r.object(utils.normalizeSuiObjectId(a)):l(r,a));return r.makeMoveVec({elements:o})}else if(typeof e=="string"&&!n.test(e)&&!s.test(e)){let o=transactions.getPureBcsSchema(e);return r.pure(bcs.bcs.vector(o).serialize(t))}else {let o=t.map(a=>l(r,a));return r.makeMoveVec({elements:o,type:e})}}function f(r,t){return t.map(e=>e instanceof bcs.SerializedBcs||bcs.isSerializedBcs(e)?r.pure(e):rt(e)?"vecType"in e?I(r,e.value,e.vecType):I(r,e):R(e)?m(r,[e])[0]:l(r,e))}function p(r,t){return typeof t=="string"&&utils.isValidSuiAddress(t)?r.pure.address(utils.normalizeSuiAddress(t)):f(r,[t])[0]}function l(r,t){if(typeof t=="string")return r.object(t);if(it(t))return r.objectRef(t);if(nt(t))return r.sharedObjectRef(t);if("Object"in t){if("ImmOrOwnedObject"in t.Object)return r.object(transactions.Inputs.ObjectRef(t.Object.ImmOrOwnedObject));if("SharedObject"in t.Object)return r.object(transactions.Inputs.SharedObjectRef(t.Object.SharedObject));throw new Error("Invalid argument type")}if(typeof t=="function"||"GasCoin"in t||"Input"in t||"Result"in t||"NestedResult"in t)return t;throw new Error("Invalid argument type")}function m(r,t){return t.map(e=>R(e)?r.pure.u64(e):f(r,[e])[0])}var c=class{constructor(t){this.txBlock=t?transactions.Transaction.from(t):new transactions.Transaction;}get gas(){return this.txBlock.gas}get blockData(){return this.txBlock.blockData}get getData(){return this.txBlock.getData()}address(t){return this.txBlock.pure.address(t)}get pure(){return this.txBlock.pure}object(t){return this.txBlock.object(t)}objectRef(t){return this.txBlock.objectRef(t)}sharedObjectRef(t){return this.txBlock.sharedObjectRef(t)}setSender(t){return this.txBlock.setSender(t)}setSenderIfNotSet(t){return this.txBlock.setSenderIfNotSet(t)}setExpiration(t){return this.txBlock.setExpiration(t)}setGasPrice(t){return this.txBlock.setGasPrice(t)}setGasBudget(t){return this.txBlock.setGasBudget(t)}setGasOwner(t){return this.txBlock.setGasOwner(t)}setGasPayment(t){return this.txBlock.setGasPayment(t)}serialize(){return this.txBlock.serialize()}toJSON(){return this.txBlock.toJSON()}sign(t){return this.txBlock.sign(t)}build(t={}){return this.txBlock.build(t)}getDigest(t={}){return this.txBlock.getDigest(t)}add(...t){return this.txBlock.add(...t)}publish({modules:t,dependencies:e}){return this.txBlock.publish({modules:t,dependencies:e})}upgrade(...t){return this.txBlock.upgrade(...t)}makeMoveVec(...t){return this.txBlock.makeMoveVec(...t)}transferObjects(t,e){return this.txBlock.transferObjects(t.map(i=>l(this.txBlock,i)),p(this.txBlock,e))}splitCoins(t,e){let i=this.txBlock.splitCoins(l(this.txBlock,t),m(this.txBlock,e));return e.map((n,s)=>i[s])}mergeCoins(t,e){let i=l(this.txBlock,t),n=e.map(s=>l(this.txBlock,s));return this.txBlock.mergeCoins(i,n)}moveCall(t,e=[],i=[]){let n=/(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/;if(t.match(n)===null)throw new Error("Invalid target format. Expected `${string}::${string}::${string}`");let o=f(this.txBlock,e);return this.txBlock.moveCall({target:t,arguments:o,typeArguments:i})}transferSuiToMany(t,e){if(t.length!==e.length)throw new Error("transferSuiToMany: recipients.length !== amounts.length");let i=this.txBlock.splitCoins(this.txBlock.gas,m(this.txBlock,e));return t.map(s=>p(this.txBlock,s)).forEach((s,o)=>{this.txBlock.transferObjects([i[o]],s);}),this}transferSui(t,e){return this.transferSuiToMany([t],[e])}takeAmountFromCoins(t,e){let i=t.map(o=>l(this.txBlock,o)),n=i[0];t.length>1&&this.txBlock.mergeCoins(n,i.slice(1));let[s]=this.txBlock.splitCoins(n,m(this.txBlock,[e]));return [s,n]}splitSUIFromGas(t){return this.txBlock.splitCoins(this.txBlock.gas,m(this.txBlock,t))}splitMultiCoins(t,e){let i=t.map(o=>l(this.txBlock,o)),n=i[0];return t.length>1&&this.txBlock.mergeCoins(n,i.slice(1)),{splitedCoins:this.txBlock.splitCoins(n,m(this.txBlock,e)),mergedCoin:n}}transferCoinToMany(t,e,i,n){if(i.length!==n.length)throw new Error("transferSuiToMany: recipients.length !== amounts.length");let s=t.map(u=>l(this.txBlock,u)),{splitedCoins:o,mergedCoin:a}=this.splitMultiCoins(s,m(this.txBlock,n));return i.map(u=>p(this.txBlock,u)).forEach((u,h)=>{this.txBlock.transferObjects([o[h]],u);}),this.txBlock.transferObjects([a],p(this.txBlock,e)),this}transferCoin(t,e,i,n){return this.transferCoinToMany(t,e,[i],[n])}stakeSui(t,e){let[i]=this.txBlock.splitCoins(this.txBlock.gas,m(this.txBlock,[t]));return this.txBlock.moveCall({target:"0x3::sui_system::request_add_stake",arguments:f(this.txBlock,[this.txBlock.object(utils.SUI_SYSTEM_STATE_OBJECT_ID),i,p(this.txBlock,e)])})}};var y=class{constructor(t){this.objectId=t.objectId,this.version=t.version,this.digest=t.digest;}isFullObject(){return !!this.version&&!!this.digest}asCallArg(){return !this.version||!this.digest?this.objectId:{$kind:"Object",Object:{$kind:"ImmOrOwnedObject",ImmOrOwnedObject:{objectId:this.objectId,version:this.version,digest:this.digest}}}}updateFromTxResponse(t){let e=t.objectChanges;if(!e)throw new Error("Bad transaction response!");for(let i of e)if(i.type==="mutated"&&i.objectId===this.objectId){this.digest=i.digest,this.version=i.version;return}throw new Error("Could not find object in transaction response!")}};var A=class{constructor(t){this.objectId=t.objectId,this.initialSharedVersion=t.initialSharedVersion;}asCallArg(t=!1){return this.initialSharedVersion?{$kind:"Object",Object:{$kind:"SharedObject",SharedObject:{objectId:this.objectId,initialSharedVersion:this.initialSharedVersion,mutable:t}}}:this.objectId}};var P=r=>new Promise(t=>setTimeout(t,r));var g=class{constructor(t){this.clients=[];this.fullNodes=[];if("fullnodeUrls"in t)this.fullNodes=t.fullnodeUrls,this.clients=this.fullNodes.map(e=>new client.SuiClient({url:e}));else if("suiClients"in t)this.clients=t.suiClients;else throw new Error("Invalid params, must provide fullNodeUrls or suiClients");this.currentClient=this.clients[0];}switchToNextClient(){let t=this.clients.indexOf(this.currentClient);this.currentClient=this.clients[(t+1)%this.clients.length];}async sendTx(t,e){let i={showEvents:!0,showEffects:!0,showRawEffects:!0,showObjectChanges:!0,showBalanceChanges:!0};for(let n in this.clients)try{return await this.clients[n].executeTransactionBlock({transactionBlock:t,signature:e,options:i})}catch(s){console.warn(`Failed to send transaction with fullnode ${this.fullNodes[n]}: ${s}`),await P(2e3);}throw new Error("Failed to send transaction with all fullnodes")}async dryRunTx(t){for(let e in this.clients)try{return await this.clients[e].dryRunTransactionBlock({transactionBlock:t})}catch(i){console.warn(`Failed to dry run transaction with fullnode ${this.fullNodes[e]}: ${i}`),await P(2e3);}throw new Error("Failed to dry run transaction with all fullnodes")}async getObjects(t,e){let i=e??{showContent:!0,showDisplay:!0,showType:!0,showOwner:!0};for(let n in this.clients)try{return (await this.clients[n].multiGetObjects({ids:t,options:i})).map(a=>a.data).filter(a=>a!=null)}catch(s){await P(2e3),console.warn(`Failed to get objects with fullnode ${this.fullNodes[n]}: ${s}`);}throw new Error("Failed to get objects with all fullnodes")}async getObject(t,e){return (await this.getObjects([t],e))[0]}async updateObjects(t){let e=t.map(n=>n.objectId),i=await this.getObjects(e);for(let n of i){let s=t.find(o=>o.objectId===n?.objectId);s instanceof A?n.owner&&typeof n.owner=="object"&&"Shared"in n.owner?s.initialSharedVersion=n.owner.Shared.initial_shared_version:s.initialSharedVersion=void 0:s instanceof y&&(s.version=n?.version,s.digest=n?.digest);}}async selectCoins(t,e,i="0x2::SUI::SUI"){let n=[],s=0,o=!0,a=null;for(;o&&s<e;){let d=await this.currentClient.getCoins({owner:t,coinType:i,cursor:a});d.data.sort((u,h)=>parseInt(h.balance)-parseInt(u.balance));for(let u of d.data)if(n.push({objectId:u.coinObjectId,digest:u.digest,version:u.version,balance:u.balance}),s=s+parseInt(u.balance),s>=e)break;a=d.nextCursor,o=d.hasNextPage;}if(!n.length)throw new Error("No valid coins found for the transaction.");return n}};var O=class{constructor(t){let{mnemonics:e,secretKey:i,networkType:n}=t;this.accountManager=new S({mnemonics:e,secretKey:i});let s;"fullnodeUrls"in t?s={fullnodeUrls:t.fullnodeUrls}:"suiClients"in t?s={suiClients:t.suiClients}:s={fullnodeUrls:[client.getFullnodeUrl(n??"mainnet")]},this.suiInteractor=new g(s);}createTxBlock(){let t=new c;return t.setSender(this.accountManager.currentAddress),t}getKeypair(t){return this.accountManager.getKeyPair(t)}switchAccount(t){this.accountManager.switchAccount(t);}getAddress(t){return this.accountManager.getAddress(t)}currentAddress(){return this.accountManager.currentAddress}async getBalance(t,e){let i=this.accountManager.getAddress(e);return this.suiInteractor.currentClient.getBalance({owner:i,coinType:t})}client(){return this.suiInteractor.currentClient}async getObjects(t,e){return this.suiInteractor.getObjects(t,e)}async updateObjects(t){return this.suiInteractor.updateObjects(t)}async signTxn(t,e){t instanceof c&&t.setSender(this.getAddress(e));let i=t instanceof c?t.txBlock:t,n=i instanceof transactions.Transaction?await i.build({client:this.client()}):i;return await this.getKeypair(e).signTransaction(n)}async signAndSendTxn(t,e){let{bytes:i,signature:n}=await this.signTxn(t,e);return this.suiInteractor.sendTx(i,n)}async dryRunTxn(t,e){t instanceof c&&t.setSender(this.getAddress(e));let i=t instanceof c?t.txBlock:t,n=i instanceof transactions.Transaction?await i.build({client:this.client()}):i;return this.suiInteractor.dryRunTx(n)}async transferSui(t,e,i=!0,n){let s=new c;return s.transferSui(t,e),i?await this.signAndSendTxn(s,n):s}async transferSuiToMany(t,e,i=!0,n){let s=new c;return s.transferSuiToMany(t,e),i?await this.signAndSendTxn(s,n):s}async transferCoinToMany(t,e,i,n=!0,s){let o=new c,a=this.accountManager.getAddress(s),d=e.reduce((h,V)=>h+V,0),u=await this.suiInteractor.selectCoins(a,d,i);return o.transferCoinToMany(u.map(h=>h.objectId),a,t,e),n?await this.signAndSendTxn(o,s):o}async transferCoin(t,e,i,n=!0,s){return this.transferCoinToMany([t],[e],i,n,s)}async transferObjects(t,e,i=!0,n){let s=new c;return s.transferObjects(t,e),i?await this.signAndSendTxn(s,n):s}async moveCall(t){let{target:e,arguments:i=[],typeArguments:n=[],derivePathParams:s}=t,o=new c;return o.moveCall(e,i,n),this.signAndSendTxn(o,s)}async selectCoinsWithAmount(t,e,i){return i=i||this.accountManager.currentAddress,await this.suiInteractor.selectCoins(i,t,e)}async stakeSui(t,e,i=!0,n){let s=new c;return s.stakeSui(t,e),i?await this.signAndSendTxn(s,n):s}async inspectTxn(t,e){let i=t instanceof c?t.txBlock:t;return this.suiInteractor.currentClient.devInspectTransactionBlock({transactionBlock:i,sender:this.getAddress(e)})}};function M(r){let t=utils.fromB64(r);if(t.length!==32&&t.length!==33)throw "invalid pubkey length";return t=t.length===33?t.slice(1):t,new ed25519.Ed25519PublicKey(t)}var x=class r{constructor(t,e){this.pksWeightPairs=t,this.threshold=e,this.multiSigPublicKey=multisig.MultiSigPublicKey.fromPublicKeys({threshold:this.threshold,publicKeys:this.pksWeightPairs});}static fromRawEd25519PublicKeys(t,e,i){let n=t.map((s,o)=>({publicKey:M(s),weight:e[o]}));return new r(n,i)}multiSigAddress(){return this.multiSigPublicKey.toSuiAddress()}combinePartialSigs(t){return this.multiSigPublicKey.combinePartialSignatures(t)}};
|
|
14
|
+
|
|
15
|
+
exports.MultiSigClient = x;
|
|
16
|
+
exports.SuiAccountManager = S;
|
|
17
|
+
exports.SuiInteractor = g;
|
|
18
|
+
exports.SuiKit = O;
|
|
19
|
+
exports.SuiTxBlock = c;
|
|
20
|
+
Object.keys(utils).forEach(function (k) {
|
|
21
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return utils[k]; }
|
|
24
|
+
});
|
|
29
25
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var import_client2 = require("@mysten/sui/client");
|
|
36
|
-
var import_transactions3 = require("@mysten/sui/transactions");
|
|
37
|
-
|
|
38
|
-
// src/libs/suiAccountManager/index.ts
|
|
39
|
-
var import_ed255192 = require("@mysten/sui/keypairs/ed25519");
|
|
40
|
-
|
|
41
|
-
// src/libs/suiAccountManager/keypair.ts
|
|
42
|
-
var import_ed25519 = require("@mysten/sui/keypairs/ed25519");
|
|
43
|
-
var getDerivePathForSUI = (derivePathParams = {}) => {
|
|
44
|
-
const {
|
|
45
|
-
accountIndex = 0,
|
|
46
|
-
isExternal = false,
|
|
47
|
-
addressIndex = 0
|
|
48
|
-
} = derivePathParams;
|
|
49
|
-
return `m/44'/784'/${accountIndex}'/${isExternal ? 1 : 0}'/${addressIndex}'`;
|
|
50
|
-
};
|
|
51
|
-
var getKeyPair = (mnemonics, derivePathParams = {}) => {
|
|
52
|
-
const derivePath = getDerivePathForSUI(derivePathParams);
|
|
53
|
-
return import_ed25519.Ed25519Keypair.deriveKeypair(mnemonics, derivePath);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
// src/libs/suiAccountManager/util.ts
|
|
57
|
-
var import_utils = require("@mysten/sui/utils");
|
|
58
|
-
var isHex = (str) => /^0x[0-9a-fA-F]+$|^[0-9a-fA-F]+$/.test(str);
|
|
59
|
-
var isBase64 = (str) => /^[a-zA-Z0-9+/]+={0,2}$/g.test(str);
|
|
60
|
-
var fromHEX = (hexStr) => {
|
|
61
|
-
if (!hexStr) {
|
|
62
|
-
throw new Error("cannot parse empty string to Uint8Array");
|
|
63
|
-
}
|
|
64
|
-
const intArr = hexStr.replace("0x", "").match(/.{1,2}/g)?.map((byte) => parseInt(byte, 16));
|
|
65
|
-
if (!intArr || intArr.length === 0) {
|
|
66
|
-
throw new Error(`Unable to parse HEX: ${hexStr}`);
|
|
67
|
-
}
|
|
68
|
-
return Uint8Array.from(intArr);
|
|
69
|
-
};
|
|
70
|
-
var hexOrBase64ToUint8Array = (str) => {
|
|
71
|
-
if (isHex(str)) {
|
|
72
|
-
return fromHEX(str);
|
|
73
|
-
} else if (isBase64(str)) {
|
|
74
|
-
return (0, import_utils.fromB64)(str);
|
|
75
|
-
} else {
|
|
76
|
-
throw new Error("The string is not a valid hex or base64 string.");
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
var PRIVATE_KEY_SIZE = 32;
|
|
80
|
-
var LEGACY_PRIVATE_KEY_SIZE = 64;
|
|
81
|
-
var normalizePrivateKey = (key) => {
|
|
82
|
-
if (key.length === LEGACY_PRIVATE_KEY_SIZE) {
|
|
83
|
-
key = key.slice(0, PRIVATE_KEY_SIZE);
|
|
84
|
-
} else if (key.length === PRIVATE_KEY_SIZE + 1 && key[0] === 0) {
|
|
85
|
-
return key.slice(1);
|
|
86
|
-
} else if (key.length === PRIVATE_KEY_SIZE) {
|
|
87
|
-
return key;
|
|
88
|
-
}
|
|
89
|
-
throw new Error("invalid secret key");
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// src/libs/suiAccountManager/crypto.ts
|
|
93
|
-
var import_bip39 = require("@scure/bip39");
|
|
94
|
-
var import_english = require("@scure/bip39/wordlists/english");
|
|
95
|
-
var generateMnemonic = (numberOfWords = 24) => {
|
|
96
|
-
const strength = numberOfWords === 12 ? 128 : 256;
|
|
97
|
-
return (0, import_bip39.generateMnemonic)(import_english.wordlist, strength);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// src/libs/suiAccountManager/index.ts
|
|
101
|
-
var import_cryptography = require("@mysten/sui/cryptography");
|
|
102
|
-
var SuiAccountManager = class {
|
|
103
|
-
/**
|
|
104
|
-
* Support the following ways to init the SuiToolkit:
|
|
105
|
-
* 1. mnemonics
|
|
106
|
-
* 2. secretKey (base64 or hex)
|
|
107
|
-
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
108
|
-
*
|
|
109
|
-
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
110
|
-
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored
|
|
111
|
-
*/
|
|
112
|
-
constructor({ mnemonics, secretKey } = {}) {
|
|
113
|
-
this.mnemonics = mnemonics || "";
|
|
114
|
-
this.secretKey = secretKey || "";
|
|
115
|
-
if (!this.mnemonics && !this.secretKey) {
|
|
116
|
-
this.mnemonics = generateMnemonic(24);
|
|
117
|
-
}
|
|
118
|
-
this.currentKeyPair = this.secretKey ? this.parseSecretKey(this.secretKey) : getKeyPair(this.mnemonics);
|
|
119
|
-
this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Check if the secretKey starts with bench32 format
|
|
123
|
-
*/
|
|
124
|
-
parseSecretKey(secretKey) {
|
|
125
|
-
if (secretKey.startsWith(import_cryptography.SUI_PRIVATE_KEY_PREFIX)) {
|
|
126
|
-
const { secretKey: uint8ArraySecretKey } = (0, import_cryptography.decodeSuiPrivateKey)(secretKey);
|
|
127
|
-
return import_ed255192.Ed25519Keypair.fromSecretKey(
|
|
128
|
-
normalizePrivateKey(uint8ArraySecretKey)
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
return import_ed255192.Ed25519Keypair.fromSecretKey(
|
|
132
|
-
normalizePrivateKey(hexOrBase64ToUint8Array(secretKey))
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair.
|
|
137
|
-
* else:
|
|
138
|
-
* it will generate keyPair from the mnemonic with the given derivePathParams.
|
|
139
|
-
*/
|
|
140
|
-
getKeyPair(derivePathParams) {
|
|
141
|
-
if (!derivePathParams || !this.mnemonics)
|
|
142
|
-
return this.currentKeyPair;
|
|
143
|
-
return getKeyPair(this.mnemonics, derivePathParams);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* if derivePathParams is not provided or mnemonics is empty, it will return the currentAddress.
|
|
147
|
-
* else:
|
|
148
|
-
* it will generate address from the mnemonic with the given derivePathParams.
|
|
149
|
-
*/
|
|
150
|
-
getAddress(derivePathParams) {
|
|
151
|
-
if (!derivePathParams || !this.mnemonics)
|
|
152
|
-
return this.currentAddress;
|
|
153
|
-
return getKeyPair(this.mnemonics, derivePathParams).getPublicKey().toSuiAddress();
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Switch the current account with the given derivePathParams.
|
|
157
|
-
* This is only useful when the mnemonics is provided. For secretKey mode, it will always use the same account.
|
|
158
|
-
*/
|
|
159
|
-
switchAccount(derivePathParams) {
|
|
160
|
-
if (this.mnemonics) {
|
|
161
|
-
this.currentKeyPair = getKeyPair(this.mnemonics, derivePathParams);
|
|
162
|
-
this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
// src/libs/suiTxBuilder/index.ts
|
|
168
|
-
var import_transactions2 = require("@mysten/sui/transactions");
|
|
169
|
-
var import_utils3 = require("@mysten/sui/utils");
|
|
170
|
-
|
|
171
|
-
// src/libs/suiTxBuilder/util.ts
|
|
172
|
-
var import_utils2 = require("@mysten/sui/utils");
|
|
173
|
-
var import_transactions = require("@mysten/sui/transactions");
|
|
174
|
-
var import_bcs = require("@mysten/bcs");
|
|
175
|
-
var getDefaultSuiInputType = (value) => {
|
|
176
|
-
if (typeof value === "string" && (0, import_utils2.isValidSuiObjectId)(value)) {
|
|
177
|
-
return "object";
|
|
178
|
-
} else if (typeof value === "number" || typeof value === "bigint") {
|
|
179
|
-
return "u64";
|
|
180
|
-
} else if (typeof value === "boolean") {
|
|
181
|
-
return "bool";
|
|
182
|
-
} else {
|
|
183
|
-
return void 0;
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
function isAmountArg(arg) {
|
|
187
|
-
return typeof arg === "number" || typeof arg === "bigint" || typeof arg === "string" && !(0, import_utils2.isValidSuiAddress)(arg) && !isNaN(Number(arg));
|
|
188
|
-
}
|
|
189
|
-
function isMoveVecArg(arg) {
|
|
190
|
-
if (typeof arg === "object" && "vecType" in arg && "value" in arg) {
|
|
191
|
-
return true;
|
|
192
|
-
} else if (Array.isArray(arg)) {
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
function isObjectRef(arg) {
|
|
198
|
-
return typeof arg === "object" && "digest" in arg && "version" in arg && "objectId" in arg;
|
|
199
|
-
}
|
|
200
|
-
function isSharedObjectRef(arg) {
|
|
201
|
-
return typeof arg === "object" && "objectId" in arg && "initialSharedVersion" in arg && "mutable" in arg;
|
|
202
|
-
}
|
|
203
|
-
function makeVecParam(txBlock, args, type) {
|
|
204
|
-
if (args.length === 0)
|
|
205
|
-
throw new Error("Transaction builder error: Empty array is not allowed");
|
|
206
|
-
const defaultSuiType = getDefaultSuiInputType(args[0]);
|
|
207
|
-
const VECTOR_REGEX = /^vector<(.+)>$/;
|
|
208
|
-
const STRUCT_REGEX = /^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;
|
|
209
|
-
type = type || defaultSuiType;
|
|
210
|
-
if (type === "object") {
|
|
211
|
-
const elements = args.map(
|
|
212
|
-
(arg) => typeof arg === "string" && (0, import_utils2.isValidSuiObjectId)(arg) ? txBlock.object((0, import_utils2.normalizeSuiObjectId)(arg)) : convertObjArg(txBlock, arg)
|
|
213
|
-
);
|
|
214
|
-
return txBlock.makeMoveVec({ elements });
|
|
215
|
-
} else if (typeof type === "string" && !VECTOR_REGEX.test(type) && !STRUCT_REGEX.test(type)) {
|
|
216
|
-
const bcsSchema = (0, import_transactions.getPureBcsSchema)(type);
|
|
217
|
-
return txBlock.pure(import_bcs.bcs.vector(bcsSchema).serialize(args));
|
|
218
|
-
} else {
|
|
219
|
-
const elements = args.map(
|
|
220
|
-
(arg) => convertObjArg(txBlock, arg)
|
|
221
|
-
);
|
|
222
|
-
return txBlock.makeMoveVec({ elements, type });
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
function convertArgs(txBlock, args) {
|
|
226
|
-
return args.map((arg) => {
|
|
227
|
-
if (arg instanceof import_bcs.SerializedBcs || (0, import_bcs.isSerializedBcs)(arg)) {
|
|
228
|
-
return txBlock.pure(arg);
|
|
229
|
-
}
|
|
230
|
-
if (isMoveVecArg(arg)) {
|
|
231
|
-
const vecType = "vecType" in arg;
|
|
232
|
-
return vecType ? makeVecParam(txBlock, arg.value, arg.vecType) : makeVecParam(txBlock, arg);
|
|
233
|
-
}
|
|
234
|
-
if (isAmountArg(arg)) {
|
|
235
|
-
return convertAmounts(txBlock, [arg])[0];
|
|
236
|
-
}
|
|
237
|
-
return convertObjArg(txBlock, arg);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
function convertAddressArg(txBlock, arg) {
|
|
241
|
-
if (typeof arg === "string" && (0, import_utils2.isValidSuiAddress)(arg)) {
|
|
242
|
-
return txBlock.pure.address((0, import_utils2.normalizeSuiAddress)(arg));
|
|
243
|
-
} else {
|
|
244
|
-
return convertArgs(txBlock, [arg])[0];
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
function convertObjArg(txb, arg) {
|
|
248
|
-
if (typeof arg === "string") {
|
|
249
|
-
return txb.object(arg);
|
|
250
|
-
}
|
|
251
|
-
if (isObjectRef(arg)) {
|
|
252
|
-
return txb.objectRef(arg);
|
|
253
|
-
}
|
|
254
|
-
if (isSharedObjectRef(arg)) {
|
|
255
|
-
return txb.sharedObjectRef(arg);
|
|
256
|
-
}
|
|
257
|
-
if ("Object" in arg) {
|
|
258
|
-
if ("ImmOrOwnedObject" in arg.Object) {
|
|
259
|
-
return txb.object(import_transactions.Inputs.ObjectRef(arg.Object.ImmOrOwnedObject));
|
|
260
|
-
} else if ("SharedObject" in arg.Object) {
|
|
261
|
-
return txb.object(import_transactions.Inputs.SharedObjectRef(arg.Object.SharedObject));
|
|
262
|
-
} else {
|
|
263
|
-
throw new Error("Invalid argument type");
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
if (typeof arg === "function") {
|
|
267
|
-
return arg;
|
|
268
|
-
}
|
|
269
|
-
if ("GasCoin" in arg || "Input" in arg || "Result" in arg || "NestedResult" in arg) {
|
|
270
|
-
return arg;
|
|
271
|
-
}
|
|
272
|
-
throw new Error("Invalid argument type");
|
|
273
|
-
}
|
|
274
|
-
function convertAmounts(txBlock, amounts) {
|
|
275
|
-
return amounts.map((amount) => {
|
|
276
|
-
if (isAmountArg(amount)) {
|
|
277
|
-
return txBlock.pure.u64(amount);
|
|
278
|
-
} else {
|
|
279
|
-
return convertArgs(txBlock, [amount])[0];
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
// src/libs/suiTxBuilder/index.ts
|
|
285
|
-
var SuiTxBlock = class {
|
|
286
|
-
constructor(transaction) {
|
|
287
|
-
this.txBlock = transaction ? import_transactions2.Transaction.from(transaction) : new import_transactions2.Transaction();
|
|
288
|
-
}
|
|
289
|
-
/* Directly wrap methods and properties of TransactionBlock */
|
|
290
|
-
get gas() {
|
|
291
|
-
return this.txBlock.gas;
|
|
292
|
-
}
|
|
293
|
-
/** @deprecated Use `getData()` instead. */
|
|
294
|
-
get blockData() {
|
|
295
|
-
return this.txBlock.blockData;
|
|
296
|
-
}
|
|
297
|
-
get getData() {
|
|
298
|
-
return this.txBlock.getData();
|
|
299
|
-
}
|
|
300
|
-
address(value) {
|
|
301
|
-
return this.txBlock.pure.address(value);
|
|
302
|
-
}
|
|
303
|
-
get pure() {
|
|
304
|
-
return this.txBlock.pure;
|
|
305
|
-
}
|
|
306
|
-
object(value) {
|
|
307
|
-
return this.txBlock.object(value);
|
|
308
|
-
}
|
|
309
|
-
objectRef(ref) {
|
|
310
|
-
return this.txBlock.objectRef(ref);
|
|
311
|
-
}
|
|
312
|
-
sharedObjectRef(ref) {
|
|
313
|
-
return this.txBlock.sharedObjectRef(ref);
|
|
314
|
-
}
|
|
315
|
-
setSender(sender) {
|
|
316
|
-
return this.txBlock.setSender(sender);
|
|
317
|
-
}
|
|
318
|
-
setSenderIfNotSet(sender) {
|
|
319
|
-
return this.txBlock.setSenderIfNotSet(sender);
|
|
320
|
-
}
|
|
321
|
-
setExpiration(expiration) {
|
|
322
|
-
return this.txBlock.setExpiration(expiration);
|
|
323
|
-
}
|
|
324
|
-
setGasPrice(price) {
|
|
325
|
-
return this.txBlock.setGasPrice(price);
|
|
326
|
-
}
|
|
327
|
-
setGasBudget(budget) {
|
|
328
|
-
return this.txBlock.setGasBudget(budget);
|
|
329
|
-
}
|
|
330
|
-
setGasOwner(owner) {
|
|
331
|
-
return this.txBlock.setGasOwner(owner);
|
|
332
|
-
}
|
|
333
|
-
setGasPayment(payments) {
|
|
334
|
-
return this.txBlock.setGasPayment(payments);
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* @deprecated Use toJSON instead.
|
|
338
|
-
* For synchronous serialization, you can use `getData()`
|
|
339
|
-
* */
|
|
340
|
-
serialize() {
|
|
341
|
-
return this.txBlock.serialize();
|
|
342
|
-
}
|
|
343
|
-
toJSON() {
|
|
344
|
-
return this.txBlock.toJSON();
|
|
345
|
-
}
|
|
346
|
-
sign(params) {
|
|
347
|
-
return this.txBlock.sign(params);
|
|
348
|
-
}
|
|
349
|
-
build(params = {}) {
|
|
350
|
-
return this.txBlock.build(params);
|
|
351
|
-
}
|
|
352
|
-
getDigest(params = {}) {
|
|
353
|
-
return this.txBlock.getDigest(params);
|
|
354
|
-
}
|
|
355
|
-
add(...args) {
|
|
356
|
-
return this.txBlock.add(...args);
|
|
357
|
-
}
|
|
358
|
-
publish({
|
|
359
|
-
modules,
|
|
360
|
-
dependencies
|
|
361
|
-
}) {
|
|
362
|
-
return this.txBlock.publish({ modules, dependencies });
|
|
363
|
-
}
|
|
364
|
-
upgrade(...args) {
|
|
365
|
-
return this.txBlock.upgrade(...args);
|
|
366
|
-
}
|
|
367
|
-
makeMoveVec(...args) {
|
|
368
|
-
return this.txBlock.makeMoveVec(...args);
|
|
369
|
-
}
|
|
370
|
-
/* Override methods of TransactionBlock */
|
|
371
|
-
transferObjects(objects, address) {
|
|
372
|
-
return this.txBlock.transferObjects(
|
|
373
|
-
objects.map((object) => convertObjArg(this.txBlock, object)),
|
|
374
|
-
convertAddressArg(this.txBlock, address)
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
splitCoins(coin, amounts) {
|
|
378
|
-
const res = this.txBlock.splitCoins(
|
|
379
|
-
convertObjArg(this.txBlock, coin),
|
|
380
|
-
convertAmounts(this.txBlock, amounts)
|
|
381
|
-
);
|
|
382
|
-
return amounts.map((_, i) => res[i]);
|
|
383
|
-
}
|
|
384
|
-
mergeCoins(destination, sources) {
|
|
385
|
-
const destinationObject = convertObjArg(this.txBlock, destination);
|
|
386
|
-
const sourceObjects = sources.map(
|
|
387
|
-
(source) => convertObjArg(this.txBlock, source)
|
|
388
|
-
);
|
|
389
|
-
return this.txBlock.mergeCoins(destinationObject, sourceObjects);
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* @description Move call
|
|
393
|
-
* @param target `${string}::${string}::${string}`, e.g. `0x3::sui_system::request_add_stake`
|
|
394
|
-
* @param args the arguments of the move call, such as `['0x1', '0x2']`
|
|
395
|
-
* @param typeArgs the type arguments of the move call, such as `['0x2::sui::SUI']`
|
|
396
|
-
*/
|
|
397
|
-
moveCall(target, args = [], typeArgs = []) {
|
|
398
|
-
const regex = /(?<package>[a-zA-Z0-9]+)::(?<module>[a-zA-Z0-9_]+)::(?<function>[a-zA-Z0-9_]+)/;
|
|
399
|
-
const match = target.match(regex);
|
|
400
|
-
if (match === null)
|
|
401
|
-
throw new Error(
|
|
402
|
-
"Invalid target format. Expected `${string}::${string}::${string}`"
|
|
403
|
-
);
|
|
404
|
-
const convertedArgs = convertArgs(this.txBlock, args);
|
|
405
|
-
return this.txBlock.moveCall({
|
|
406
|
-
target,
|
|
407
|
-
arguments: convertedArgs,
|
|
408
|
-
typeArguments: typeArgs
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
/* Enhance methods of TransactionBlock */
|
|
412
|
-
transferSuiToMany(recipients, amounts) {
|
|
413
|
-
if (recipients.length !== amounts.length) {
|
|
414
|
-
throw new Error(
|
|
415
|
-
"transferSuiToMany: recipients.length !== amounts.length"
|
|
416
|
-
);
|
|
417
|
-
}
|
|
418
|
-
const coins = this.txBlock.splitCoins(
|
|
419
|
-
this.txBlock.gas,
|
|
420
|
-
convertAmounts(this.txBlock, amounts)
|
|
421
|
-
);
|
|
422
|
-
const recipientObjects = recipients.map(
|
|
423
|
-
(recipient) => convertAddressArg(this.txBlock, recipient)
|
|
424
|
-
);
|
|
425
|
-
recipientObjects.forEach((address, index) => {
|
|
426
|
-
this.txBlock.transferObjects([coins[index]], address);
|
|
427
|
-
});
|
|
428
|
-
return this;
|
|
429
|
-
}
|
|
430
|
-
transferSui(address, amount) {
|
|
431
|
-
return this.transferSuiToMany([address], [amount]);
|
|
432
|
-
}
|
|
433
|
-
takeAmountFromCoins(coins, amount) {
|
|
434
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));
|
|
435
|
-
const mergedCoin = coinObjects[0];
|
|
436
|
-
if (coins.length > 1) {
|
|
437
|
-
this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
438
|
-
}
|
|
439
|
-
const [sendCoin] = this.txBlock.splitCoins(
|
|
440
|
-
mergedCoin,
|
|
441
|
-
convertAmounts(this.txBlock, [amount])
|
|
442
|
-
);
|
|
443
|
-
return [sendCoin, mergedCoin];
|
|
444
|
-
}
|
|
445
|
-
splitSUIFromGas(amounts) {
|
|
446
|
-
return this.txBlock.splitCoins(
|
|
447
|
-
this.txBlock.gas,
|
|
448
|
-
convertAmounts(this.txBlock, amounts)
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
splitMultiCoins(coins, amounts) {
|
|
452
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));
|
|
453
|
-
const mergedCoin = coinObjects[0];
|
|
454
|
-
if (coins.length > 1) {
|
|
455
|
-
this.txBlock.mergeCoins(mergedCoin, coinObjects.slice(1));
|
|
456
|
-
}
|
|
457
|
-
const splitedCoins = this.txBlock.splitCoins(
|
|
458
|
-
mergedCoin,
|
|
459
|
-
convertAmounts(this.txBlock, amounts)
|
|
460
|
-
);
|
|
461
|
-
return { splitedCoins, mergedCoin };
|
|
462
|
-
}
|
|
463
|
-
transferCoinToMany(coins, sender, recipients, amounts) {
|
|
464
|
-
if (recipients.length !== amounts.length) {
|
|
465
|
-
throw new Error(
|
|
466
|
-
"transferSuiToMany: recipients.length !== amounts.length"
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
const coinObjects = coins.map((coin) => convertObjArg(this.txBlock, coin));
|
|
470
|
-
const { splitedCoins, mergedCoin } = this.splitMultiCoins(
|
|
471
|
-
coinObjects,
|
|
472
|
-
convertAmounts(this.txBlock, amounts)
|
|
473
|
-
);
|
|
474
|
-
const recipientObjects = recipients.map(
|
|
475
|
-
(recipient) => convertAddressArg(this.txBlock, recipient)
|
|
476
|
-
);
|
|
477
|
-
recipientObjects.forEach((address, index) => {
|
|
478
|
-
this.txBlock.transferObjects([splitedCoins[index]], address);
|
|
479
|
-
});
|
|
480
|
-
this.txBlock.transferObjects(
|
|
481
|
-
[mergedCoin],
|
|
482
|
-
convertAddressArg(this.txBlock, sender)
|
|
483
|
-
);
|
|
484
|
-
return this;
|
|
485
|
-
}
|
|
486
|
-
transferCoin(coins, sender, recipient, amount) {
|
|
487
|
-
return this.transferCoinToMany(coins, sender, [recipient], [amount]);
|
|
488
|
-
}
|
|
489
|
-
stakeSui(amount, validatorAddr) {
|
|
490
|
-
const [stakeCoin] = this.txBlock.splitCoins(
|
|
491
|
-
this.txBlock.gas,
|
|
492
|
-
convertAmounts(this.txBlock, [amount])
|
|
493
|
-
);
|
|
494
|
-
return this.txBlock.moveCall({
|
|
495
|
-
target: "0x3::sui_system::request_add_stake",
|
|
496
|
-
arguments: convertArgs(this.txBlock, [
|
|
497
|
-
this.txBlock.object(import_utils3.SUI_SYSTEM_STATE_OBJECT_ID),
|
|
498
|
-
stakeCoin,
|
|
499
|
-
convertAddressArg(this.txBlock, validatorAddr)
|
|
500
|
-
])
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
// src/libs/suiModel/suiOwnedObject.ts
|
|
506
|
-
var SuiOwnedObject = class {
|
|
507
|
-
constructor(param) {
|
|
508
|
-
this.objectId = param.objectId;
|
|
509
|
-
this.version = param.version;
|
|
510
|
-
this.digest = param.digest;
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Check if the object is fully initialized.
|
|
514
|
-
* So that when it's used as an input, it won't be necessary to fetch from fullnode again.
|
|
515
|
-
* Which can save time when sending transactions.
|
|
516
|
-
*/
|
|
517
|
-
isFullObject() {
|
|
518
|
-
return !!this.version && !!this.digest;
|
|
519
|
-
}
|
|
520
|
-
asCallArg() {
|
|
521
|
-
if (!this.version || !this.digest) {
|
|
522
|
-
return this.objectId;
|
|
523
|
-
}
|
|
524
|
-
return {
|
|
525
|
-
$kind: "Object",
|
|
526
|
-
Object: {
|
|
527
|
-
$kind: "ImmOrOwnedObject",
|
|
528
|
-
ImmOrOwnedObject: {
|
|
529
|
-
objectId: this.objectId,
|
|
530
|
-
version: this.version,
|
|
531
|
-
digest: this.digest
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
};
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* Update object version & digest based on the transaction response.
|
|
538
|
-
* @param txResponse
|
|
539
|
-
*/
|
|
540
|
-
updateFromTxResponse(txResponse) {
|
|
541
|
-
const changes = txResponse.objectChanges;
|
|
542
|
-
if (!changes) {
|
|
543
|
-
throw new Error("Bad transaction response!");
|
|
544
|
-
}
|
|
545
|
-
for (const change of changes) {
|
|
546
|
-
if (change.type === "mutated" && change.objectId === this.objectId) {
|
|
547
|
-
this.digest = change.digest;
|
|
548
|
-
this.version = change.version;
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
throw new Error("Could not find object in transaction response!");
|
|
553
|
-
}
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
// src/libs/suiModel/suiSharedObject.ts
|
|
557
|
-
var SuiSharedObject = class {
|
|
558
|
-
constructor(param) {
|
|
559
|
-
this.objectId = param.objectId;
|
|
560
|
-
this.initialSharedVersion = param.initialSharedVersion;
|
|
561
|
-
}
|
|
562
|
-
asCallArg(mutable = false) {
|
|
563
|
-
if (!this.initialSharedVersion) {
|
|
564
|
-
return this.objectId;
|
|
565
|
-
}
|
|
566
|
-
return {
|
|
567
|
-
$kind: "Object",
|
|
568
|
-
Object: {
|
|
569
|
-
$kind: "SharedObject",
|
|
570
|
-
SharedObject: {
|
|
571
|
-
objectId: this.objectId,
|
|
572
|
-
initialSharedVersion: this.initialSharedVersion,
|
|
573
|
-
mutable
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
|
|
580
|
-
// src/libs/suiInteractor/util.ts
|
|
581
|
-
var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
582
|
-
|
|
583
|
-
// src/libs/suiInteractor/suiInteractor.ts
|
|
584
|
-
var import_client = require("@mysten/sui/client");
|
|
585
|
-
var SuiInteractor = class {
|
|
586
|
-
constructor(params) {
|
|
587
|
-
this.clients = [];
|
|
588
|
-
this.fullNodes = [];
|
|
589
|
-
if ("fullnodeUrls" in params) {
|
|
590
|
-
this.fullNodes = params.fullnodeUrls;
|
|
591
|
-
this.clients = this.fullNodes.map((url) => new import_client.SuiClient({ url }));
|
|
592
|
-
} else if ("suiClients" in params) {
|
|
593
|
-
this.clients = params.suiClients;
|
|
594
|
-
} else {
|
|
595
|
-
throw new Error(
|
|
596
|
-
"Invalid params, must provide fullNodeUrls or suiClients"
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
|
-
this.currentClient = this.clients[0];
|
|
600
|
-
}
|
|
601
|
-
switchToNextClient() {
|
|
602
|
-
const currentClientIdx = this.clients.indexOf(this.currentClient);
|
|
603
|
-
this.currentClient = this.clients[(currentClientIdx + 1) % this.clients.length];
|
|
604
|
-
}
|
|
605
|
-
async sendTx(transactionBlock, signature) {
|
|
606
|
-
const txResOptions = {
|
|
607
|
-
showEvents: true,
|
|
608
|
-
showEffects: true,
|
|
609
|
-
showRawEffects: true,
|
|
610
|
-
showObjectChanges: true,
|
|
611
|
-
showBalanceChanges: true
|
|
612
|
-
};
|
|
613
|
-
for (const clientIdx in this.clients) {
|
|
614
|
-
try {
|
|
615
|
-
return await this.clients[clientIdx].executeTransactionBlock({
|
|
616
|
-
transactionBlock,
|
|
617
|
-
signature,
|
|
618
|
-
options: txResOptions
|
|
619
|
-
});
|
|
620
|
-
} catch (err) {
|
|
621
|
-
console.warn(
|
|
622
|
-
`Failed to send transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
623
|
-
);
|
|
624
|
-
await delay(2e3);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
throw new Error("Failed to send transaction with all fullnodes");
|
|
628
|
-
}
|
|
629
|
-
async dryRunTx(transactionBlock) {
|
|
630
|
-
for (const clientIdx in this.clients) {
|
|
631
|
-
try {
|
|
632
|
-
return await this.clients[clientIdx].dryRunTransactionBlock({
|
|
633
|
-
transactionBlock
|
|
634
|
-
});
|
|
635
|
-
} catch (err) {
|
|
636
|
-
console.warn(
|
|
637
|
-
`Failed to dry run transaction with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
638
|
-
);
|
|
639
|
-
await delay(2e3);
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
throw new Error("Failed to dry run transaction with all fullnodes");
|
|
643
|
-
}
|
|
644
|
-
async getObjects(ids, options) {
|
|
645
|
-
const opts = options ?? {
|
|
646
|
-
showContent: true,
|
|
647
|
-
showDisplay: true,
|
|
648
|
-
showType: true,
|
|
649
|
-
showOwner: true
|
|
650
|
-
};
|
|
651
|
-
for (const clientIdx in this.clients) {
|
|
652
|
-
try {
|
|
653
|
-
const objects = await this.clients[clientIdx].multiGetObjects({
|
|
654
|
-
ids,
|
|
655
|
-
options: opts
|
|
656
|
-
});
|
|
657
|
-
const parsedObjects = objects.map((object) => {
|
|
658
|
-
return object.data;
|
|
659
|
-
}).filter((object) => object !== null && object !== void 0);
|
|
660
|
-
return parsedObjects;
|
|
661
|
-
} catch (err) {
|
|
662
|
-
await delay(2e3);
|
|
663
|
-
console.warn(
|
|
664
|
-
`Failed to get objects with fullnode ${this.fullNodes[clientIdx]}: ${err}`
|
|
665
|
-
);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
throw new Error("Failed to get objects with all fullnodes");
|
|
669
|
-
}
|
|
670
|
-
async getObject(id, options) {
|
|
671
|
-
const objects = await this.getObjects([id], options);
|
|
672
|
-
return objects[0];
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* @description Update objects in a batch
|
|
676
|
-
* @param suiObjects
|
|
677
|
-
*/
|
|
678
|
-
async updateObjects(suiObjects) {
|
|
679
|
-
const objectIds = suiObjects.map((obj) => obj.objectId);
|
|
680
|
-
const objects = await this.getObjects(objectIds);
|
|
681
|
-
for (const object of objects) {
|
|
682
|
-
const suiObject = suiObjects.find(
|
|
683
|
-
(obj) => obj.objectId === object?.objectId
|
|
684
|
-
);
|
|
685
|
-
if (suiObject instanceof SuiSharedObject) {
|
|
686
|
-
if (object.owner && typeof object.owner === "object" && "Shared" in object.owner) {
|
|
687
|
-
suiObject.initialSharedVersion = object.owner.Shared.initial_shared_version;
|
|
688
|
-
} else {
|
|
689
|
-
suiObject.initialSharedVersion = void 0;
|
|
690
|
-
}
|
|
691
|
-
} else if (suiObject instanceof SuiOwnedObject) {
|
|
692
|
-
suiObject.version = object?.version;
|
|
693
|
-
suiObject.digest = object?.digest;
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* @description Select coins that add up to the given amount.
|
|
699
|
-
* @param addr the address of the owner
|
|
700
|
-
* @param amount the amount that is needed for the coin
|
|
701
|
-
* @param coinType the coin type, default is '0x2::SUI::SUI'
|
|
702
|
-
*/
|
|
703
|
-
async selectCoins(addr, amount, coinType = "0x2::SUI::SUI") {
|
|
704
|
-
const selectedCoins = [];
|
|
705
|
-
let totalAmount = 0;
|
|
706
|
-
let hasNext = true, nextCursor = null;
|
|
707
|
-
while (hasNext && totalAmount < amount) {
|
|
708
|
-
const coins = await this.currentClient.getCoins({
|
|
709
|
-
owner: addr,
|
|
710
|
-
coinType,
|
|
711
|
-
cursor: nextCursor
|
|
712
|
-
});
|
|
713
|
-
coins.data.sort((a, b) => parseInt(b.balance) - parseInt(a.balance));
|
|
714
|
-
for (const coinData of coins.data) {
|
|
715
|
-
selectedCoins.push({
|
|
716
|
-
objectId: coinData.coinObjectId,
|
|
717
|
-
digest: coinData.digest,
|
|
718
|
-
version: coinData.version,
|
|
719
|
-
balance: coinData.balance
|
|
720
|
-
});
|
|
721
|
-
totalAmount = totalAmount + parseInt(coinData.balance);
|
|
722
|
-
if (totalAmount >= amount) {
|
|
723
|
-
break;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
nextCursor = coins.nextCursor;
|
|
727
|
-
hasNext = coins.hasNextPage;
|
|
728
|
-
}
|
|
729
|
-
if (!selectedCoins.length) {
|
|
730
|
-
throw new Error("No valid coins found for the transaction.");
|
|
731
|
-
}
|
|
732
|
-
return selectedCoins;
|
|
733
|
-
}
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
// src/suiKit.ts
|
|
737
|
-
var SuiKit = class {
|
|
738
|
-
/**
|
|
739
|
-
* Support the following ways to init the SuiToolkit:
|
|
740
|
-
* 1. mnemonics
|
|
741
|
-
* 2. secretKey (base64 or hex)
|
|
742
|
-
* If none of them is provided, will generate a random mnemonics with 24 words.
|
|
743
|
-
*
|
|
744
|
-
* @param mnemonics, 12 or 24 mnemonics words, separated by space
|
|
745
|
-
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored
|
|
746
|
-
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet'
|
|
747
|
-
* @param fullnodeUrls, the fullnode url, default is the preconfig fullnode url for the given network type
|
|
748
|
-
*/
|
|
749
|
-
constructor(params) {
|
|
750
|
-
const { mnemonics, secretKey, networkType } = params;
|
|
751
|
-
this.accountManager = new SuiAccountManager({ mnemonics, secretKey });
|
|
752
|
-
let suiInteractorParams;
|
|
753
|
-
if ("fullnodeUrls" in params) {
|
|
754
|
-
suiInteractorParams = { fullnodeUrls: params.fullnodeUrls };
|
|
755
|
-
} else if ("suiClients" in params) {
|
|
756
|
-
suiInteractorParams = { suiClients: params.suiClients };
|
|
757
|
-
} else {
|
|
758
|
-
suiInteractorParams = {
|
|
759
|
-
fullnodeUrls: [(0, import_client2.getFullnodeUrl)(networkType ?? "mainnet")]
|
|
760
|
-
};
|
|
761
|
-
}
|
|
762
|
-
this.suiInteractor = new SuiInteractor(suiInteractorParams);
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Create SuiTxBlock with sender set to the current signer
|
|
766
|
-
* @returns SuiTxBlock with sender set to the current signer
|
|
767
|
-
*/
|
|
768
|
-
createTxBlock() {
|
|
769
|
-
const txb = new SuiTxBlock();
|
|
770
|
-
txb.setSender(this.accountManager.currentAddress);
|
|
771
|
-
return txb;
|
|
772
|
-
}
|
|
773
|
-
/**
|
|
774
|
-
* if derivePathParams is not provided or mnemonics is empty, it will return the keypair.
|
|
775
|
-
* else:
|
|
776
|
-
* it will generate signer from the mnemonic with the given derivePathParams.
|
|
777
|
-
* @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
|
|
778
|
-
*/
|
|
779
|
-
getKeypair(derivePathParams) {
|
|
780
|
-
return this.accountManager.getKeyPair(derivePathParams);
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* @description Switch the current account with the given derivePathParams
|
|
784
|
-
* @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
|
|
785
|
-
*/
|
|
786
|
-
switchAccount(derivePathParams) {
|
|
787
|
-
this.accountManager.switchAccount(derivePathParams);
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* @description Get the address of the account for the given derivePathParams
|
|
791
|
-
* @param derivePathParams, such as { accountIndex: 2, isExternal: false, addressIndex: 10 }, comply with the BIP44 standard
|
|
792
|
-
*/
|
|
793
|
-
getAddress(derivePathParams) {
|
|
794
|
-
return this.accountManager.getAddress(derivePathParams);
|
|
795
|
-
}
|
|
796
|
-
currentAddress() {
|
|
797
|
-
return this.accountManager.currentAddress;
|
|
798
|
-
}
|
|
799
|
-
async getBalance(coinType, derivePathParams) {
|
|
800
|
-
const owner = this.accountManager.getAddress(derivePathParams);
|
|
801
|
-
return this.suiInteractor.currentClient.getBalance({ owner, coinType });
|
|
802
|
-
}
|
|
803
|
-
client() {
|
|
804
|
-
return this.suiInteractor.currentClient;
|
|
805
|
-
}
|
|
806
|
-
async getObjects(objectIds, options) {
|
|
807
|
-
return this.suiInteractor.getObjects(objectIds, options);
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* @description Update objects in a batch
|
|
811
|
-
* @param suiObjects
|
|
812
|
-
*/
|
|
813
|
-
async updateObjects(suiObjects) {
|
|
814
|
-
return this.suiInteractor.updateObjects(suiObjects);
|
|
815
|
-
}
|
|
816
|
-
async signTxn(tx, derivePathParams) {
|
|
817
|
-
if (tx instanceof SuiTxBlock) {
|
|
818
|
-
tx.setSender(this.getAddress(derivePathParams));
|
|
819
|
-
}
|
|
820
|
-
const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;
|
|
821
|
-
const txBytes = txBlock instanceof import_transactions3.Transaction ? await txBlock.build({ client: this.client() }) : txBlock;
|
|
822
|
-
const keyPair = this.getKeypair(derivePathParams);
|
|
823
|
-
return await keyPair.signTransaction(txBytes);
|
|
824
|
-
}
|
|
825
|
-
async signAndSendTxn(tx, derivePathParams) {
|
|
826
|
-
const { bytes, signature } = await this.signTxn(tx, derivePathParams);
|
|
827
|
-
return this.suiInteractor.sendTx(bytes, signature);
|
|
828
|
-
}
|
|
829
|
-
async dryRunTxn(tx, derivePathParams) {
|
|
830
|
-
if (tx instanceof SuiTxBlock) {
|
|
831
|
-
tx.setSender(this.getAddress(derivePathParams));
|
|
832
|
-
}
|
|
833
|
-
const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;
|
|
834
|
-
const txBytes = txBlock instanceof import_transactions3.Transaction ? await txBlock.build({ client: this.client() }) : txBlock;
|
|
835
|
-
return this.suiInteractor.dryRunTx(txBytes);
|
|
836
|
-
}
|
|
837
|
-
async transferSui(recipient, amount, sign = true, derivePathParams) {
|
|
838
|
-
const tx = new SuiTxBlock();
|
|
839
|
-
tx.transferSui(recipient, amount);
|
|
840
|
-
return sign ? await this.signAndSendTxn(
|
|
841
|
-
tx,
|
|
842
|
-
derivePathParams
|
|
843
|
-
) : tx;
|
|
844
|
-
}
|
|
845
|
-
async transferSuiToMany(recipients, amounts, sign = true, derivePathParams) {
|
|
846
|
-
const tx = new SuiTxBlock();
|
|
847
|
-
tx.transferSuiToMany(recipients, amounts);
|
|
848
|
-
return sign ? await this.signAndSendTxn(
|
|
849
|
-
tx,
|
|
850
|
-
derivePathParams
|
|
851
|
-
) : tx;
|
|
852
|
-
}
|
|
853
|
-
async transferCoinToMany(recipients, amounts, coinType, sign = true, derivePathParams) {
|
|
854
|
-
const tx = new SuiTxBlock();
|
|
855
|
-
const owner = this.accountManager.getAddress(derivePathParams);
|
|
856
|
-
const totalAmount = amounts.reduce((a, b) => a + b, 0);
|
|
857
|
-
const coins = await this.suiInteractor.selectCoins(
|
|
858
|
-
owner,
|
|
859
|
-
totalAmount,
|
|
860
|
-
coinType
|
|
861
|
-
);
|
|
862
|
-
tx.transferCoinToMany(
|
|
863
|
-
coins.map((c) => c.objectId),
|
|
864
|
-
owner,
|
|
865
|
-
recipients,
|
|
866
|
-
amounts
|
|
867
|
-
);
|
|
868
|
-
return sign ? await this.signAndSendTxn(
|
|
869
|
-
tx,
|
|
870
|
-
derivePathParams
|
|
871
|
-
) : tx;
|
|
872
|
-
}
|
|
873
|
-
async transferCoin(recipient, amount, coinType, sign = true, derivePathParams) {
|
|
874
|
-
return this.transferCoinToMany(
|
|
875
|
-
[recipient],
|
|
876
|
-
[amount],
|
|
877
|
-
coinType,
|
|
878
|
-
sign,
|
|
879
|
-
derivePathParams
|
|
880
|
-
);
|
|
881
|
-
}
|
|
882
|
-
async transferObjects(objects, recipient, sign = true, derivePathParams) {
|
|
883
|
-
const tx = new SuiTxBlock();
|
|
884
|
-
tx.transferObjects(objects, recipient);
|
|
885
|
-
return sign ? await this.signAndSendTxn(tx, derivePathParams) : tx;
|
|
886
|
-
}
|
|
887
|
-
async moveCall(callParams) {
|
|
888
|
-
const {
|
|
889
|
-
target,
|
|
890
|
-
arguments: args = [],
|
|
891
|
-
typeArguments = [],
|
|
892
|
-
derivePathParams
|
|
893
|
-
} = callParams;
|
|
894
|
-
const tx = new SuiTxBlock();
|
|
895
|
-
tx.moveCall(target, args, typeArguments);
|
|
896
|
-
return this.signAndSendTxn(tx, derivePathParams);
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Select coins with the given amount and coin type, the total amount is greater than or equal to the given amount
|
|
900
|
-
* @param amount
|
|
901
|
-
* @param coinType
|
|
902
|
-
* @param owner
|
|
903
|
-
*/
|
|
904
|
-
async selectCoinsWithAmount(amount, coinType, owner) {
|
|
905
|
-
owner = owner || this.accountManager.currentAddress;
|
|
906
|
-
const coins = await this.suiInteractor.selectCoins(owner, amount, coinType);
|
|
907
|
-
return coins;
|
|
908
|
-
}
|
|
909
|
-
async stakeSui(amount, validatorAddr, sign = true, derivePathParams) {
|
|
910
|
-
const tx = new SuiTxBlock();
|
|
911
|
-
tx.stakeSui(amount, validatorAddr);
|
|
912
|
-
return sign ? await this.signAndSendTxn(
|
|
913
|
-
tx,
|
|
914
|
-
derivePathParams
|
|
915
|
-
) : tx;
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* Execute the transaction with on-chain data but without really submitting. Useful for querying the effects of a transaction.
|
|
919
|
-
* Since the transaction is not submitted, its gas cost is not charged.
|
|
920
|
-
* @param tx the transaction to execute
|
|
921
|
-
* @param derivePathParams the derive path params
|
|
922
|
-
* @returns the effects and events of the transaction, such as object changes, gas cost, event emitted.
|
|
923
|
-
*/
|
|
924
|
-
async inspectTxn(tx, derivePathParams) {
|
|
925
|
-
const txBlock = tx instanceof SuiTxBlock ? tx.txBlock : tx;
|
|
926
|
-
return this.suiInteractor.currentClient.devInspectTransactionBlock({
|
|
927
|
-
transactionBlock: txBlock,
|
|
928
|
-
sender: this.getAddress(derivePathParams)
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
};
|
|
932
|
-
|
|
933
|
-
// src/libs/multiSig/client.ts
|
|
934
|
-
var import_multisig = require("@mysten/sui/multisig");
|
|
935
|
-
|
|
936
|
-
// src/libs/multiSig/publickey.ts
|
|
937
|
-
var import_ed255193 = require("@mysten/sui/keypairs/ed25519");
|
|
938
|
-
var import_utils4 = require("@mysten/sui/utils");
|
|
939
|
-
function ed25519PublicKeyFromBase64(rawPubkey) {
|
|
940
|
-
let bytes = (0, import_utils4.fromB64)(rawPubkey);
|
|
941
|
-
if (bytes.length !== 32 && bytes.length !== 33)
|
|
942
|
-
throw "invalid pubkey length";
|
|
943
|
-
bytes = bytes.length === 33 ? bytes.slice(1) : bytes;
|
|
944
|
-
return new import_ed255193.Ed25519PublicKey(bytes);
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
// src/libs/multiSig/client.ts
|
|
948
|
-
var MultiSigClient = class _MultiSigClient {
|
|
949
|
-
constructor(pks, threshold) {
|
|
950
|
-
this.pksWeightPairs = pks;
|
|
951
|
-
this.threshold = threshold;
|
|
952
|
-
this.multiSigPublicKey = import_multisig.MultiSigPublicKey.fromPublicKeys({
|
|
953
|
-
threshold: this.threshold,
|
|
954
|
-
publicKeys: this.pksWeightPairs
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
static fromRawEd25519PublicKeys(rawPublicKeys, weights, threshold) {
|
|
958
|
-
const pks = rawPublicKeys.map((rawPublicKey, i) => {
|
|
959
|
-
return {
|
|
960
|
-
publicKey: ed25519PublicKeyFromBase64(rawPublicKey),
|
|
961
|
-
weight: weights[i]
|
|
962
|
-
};
|
|
963
|
-
});
|
|
964
|
-
return new _MultiSigClient(pks, threshold);
|
|
965
|
-
}
|
|
966
|
-
multiSigAddress() {
|
|
967
|
-
return this.multiSigPublicKey.toSuiAddress();
|
|
968
|
-
}
|
|
969
|
-
combinePartialSigs(sigs) {
|
|
970
|
-
return this.multiSigPublicKey.combinePartialSignatures(sigs);
|
|
971
|
-
}
|
|
972
|
-
};
|
|
973
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
974
|
-
0 && (module.exports = {
|
|
975
|
-
MultiSigClient,
|
|
976
|
-
SuiAccountManager,
|
|
977
|
-
SuiInteractor,
|
|
978
|
-
SuiKit,
|
|
979
|
-
SuiTxBlock,
|
|
980
|
-
...require("@mysten/sui/utils"),
|
|
981
|
-
...require("@mysten/sui/transactions")
|
|
26
|
+
Object.keys(transactions).forEach(function (k) {
|
|
27
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return transactions[k]; }
|
|
30
|
+
});
|
|
982
31
|
});
|
|
983
|
-
//# sourceMappingURL=index.js.map
|