Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mysten/sui.js

Package Overview
Dependencies
Maintainers
4
Versions
895
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mysten/sui.js - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

dist/types/events.d.ts

4

dist/cryptography/publickey.d.ts

@@ -16,2 +16,4 @@ /// <reference types="node" />

export declare const PUBLIC_KEY_SIZE = 32;
export declare const TYPE_BYTE = 0;
export declare type SignatureScheme = 'ED25519' | 'Secp256k1';
/**

@@ -51,3 +53,3 @@ * A public key

*/
toSuiAddress(): string;
toSuiAddress(scheme?: SignatureScheme): string;
}

@@ -1,2 +0,2 @@

import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, TransferObjectTransaction, TransferSuiTransaction, MergeCoinTransaction, SplitCoinTransaction, MoveCallTransaction, PublishTransaction, TxnDataSerializer, SignaturePubkeyPair, Signer, TransactionDigest, SuiAddress, ObjectOwner, SuiObjectRef, SuiObjectInfo, ObjectContentFields, MovePackageContent, SuiData, SuiMoveObject, SuiMovePackage, SuiObject, ObjectStatus, ObjectType, GetOwnedObjectsResponse, GetObjectDataResponse, ObjectDigest, ObjectId, SequenceNumber, TransferObject, SuiTransferSui, SuiChangeEpoch, TransactionKindName, SuiTransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, OwnedObjectRef, TransactionEffects, TransactionEffectsResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, MoveCall, SuiJsonValue, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, MergeCoinResponse, SplitCoinResponse, PublishResponse, SuiPackage, TransactionResponse } from "./index";
import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, SignatureScheme, TransferObjectTransaction, TransferSuiTransaction, MergeCoinTransaction, SplitCoinTransaction, MoveCallTransaction, PublishTransaction, TxnDataSerializer, SignaturePubkeyPair, Signer, TransactionDigest, SuiAddress, ObjectOwner, SuiObjectRef, SuiObjectInfo, ObjectContentFields, MovePackageContent, SuiData, SuiMoveObject, SuiMovePackage, SuiMoveFunctionArgTypesResponse, SuiMoveFunctionArgType, SuiMoveFunctionArgTypes, SuiMoveNormalizedModules, SuiMoveNormalizedModule, SuiMoveModuleId, SuiMoveNormalizedStruct, SuiMoveStructTypeParameter, SuiMoveNormalizedField, SuiMoveNormalizedFunction, SuiMoveVisibility, SuiMoveTypeParameterIndex, SuiMoveAbilitySet, SuiMoveNormalizedType, SuiObject, ObjectStatus, ObjectType, GetOwnedObjectsResponse, GetObjectDataResponse, ObjectDigest, ObjectId, SequenceNumber, MoveEvent, PublishEvent, TransferObjectEvent, DeleteObjectEvent, NewObjectEvent, SuiEvent, TransferObject, SuiTransferSui, SuiChangeEpoch, TransactionKindName, SuiTransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, OwnedObjectRef, TransactionEffects, SuiTransactionResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, MoveCall, SuiJsonValue, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, SuiParsedMergeCoinResponse, SuiParsedSplitCoinResponse, SuiParsedPublishResponse, SuiPackage, SuiParsedTransactionResponse } from "./index";
export declare function isEd25519KeypairData(obj: any, _argumentName?: string): obj is Ed25519KeypairData;

@@ -6,2 +6,3 @@ export declare function isKeypair(obj: any, _argumentName?: string): obj is Keypair;

export declare function isPublicKeyData(obj: any, _argumentName?: string): obj is PublicKeyData;
export declare function isSignatureScheme(obj: any, _argumentName?: string): obj is SignatureScheme;
export declare function isTransferObjectTransaction(obj: any, _argumentName?: string): obj is TransferObjectTransaction;

@@ -26,2 +27,16 @@ export declare function isTransferSuiTransaction(obj: any, _argumentName?: string): obj is TransferSuiTransaction;

export declare function isSuiMovePackage(obj: any, _argumentName?: string): obj is SuiMovePackage;
export declare function isSuiMoveFunctionArgTypesResponse(obj: any, _argumentName?: string): obj is SuiMoveFunctionArgTypesResponse;
export declare function isSuiMoveFunctionArgType(obj: any, _argumentName?: string): obj is SuiMoveFunctionArgType;
export declare function isSuiMoveFunctionArgTypes(obj: any, _argumentName?: string): obj is SuiMoveFunctionArgTypes;
export declare function isSuiMoveNormalizedModules(obj: any, _argumentName?: string): obj is SuiMoveNormalizedModules;
export declare function isSuiMoveNormalizedModule(obj: any, _argumentName?: string): obj is SuiMoveNormalizedModule;
export declare function isSuiMoveModuleId(obj: any, _argumentName?: string): obj is SuiMoveModuleId;
export declare function isSuiMoveNormalizedStruct(obj: any, _argumentName?: string): obj is SuiMoveNormalizedStruct;
export declare function isSuiMoveStructTypeParameter(obj: any, _argumentName?: string): obj is SuiMoveStructTypeParameter;
export declare function isSuiMoveNormalizedField(obj: any, _argumentName?: string): obj is SuiMoveNormalizedField;
export declare function isSuiMoveNormalizedFunction(obj: any, _argumentName?: string): obj is SuiMoveNormalizedFunction;
export declare function isSuiMoveVisibility(obj: any, _argumentName?: string): obj is SuiMoveVisibility;
export declare function isSuiMoveTypeParameterIndex(obj: any, _argumentName?: string): obj is SuiMoveTypeParameterIndex;
export declare function isSuiMoveAbilitySet(obj: any, _argumentName?: string): obj is SuiMoveAbilitySet;
export declare function isSuiMoveNormalizedType(obj: any, _argumentName?: string): obj is SuiMoveNormalizedType;
export declare function isSuiObject(obj: any, _argumentName?: string): obj is SuiObject;

@@ -35,2 +50,8 @@ export declare function isObjectStatus(obj: any, _argumentName?: string): obj is ObjectStatus;

export declare function isSequenceNumber(obj: any, _argumentName?: string): obj is SequenceNumber;
export declare function isMoveEvent(obj: any, _argumentName?: string): obj is MoveEvent;
export declare function isPublishEvent(obj: any, _argumentName?: string): obj is PublishEvent;
export declare function isTransferObjectEvent(obj: any, _argumentName?: string): obj is TransferObjectEvent;
export declare function isDeleteObjectEvent(obj: any, _argumentName?: string): obj is DeleteObjectEvent;
export declare function isNewObjectEvent(obj: any, _argumentName?: string): obj is NewObjectEvent;
export declare function isSuiEvent(obj: any, _argumentName?: string): obj is SuiEvent;
export declare function isTransferObject(obj: any, _argumentName?: string): obj is TransferObject;

@@ -50,3 +71,3 @@ export declare function isSuiTransferSui(obj: any, _argumentName?: string): obj is SuiTransferSui;

export declare function isTransactionEffects(obj: any, _argumentName?: string): obj is TransactionEffects;
export declare function isTransactionEffectsResponse(obj: any, _argumentName?: string): obj is TransactionEffectsResponse;
export declare function isSuiTransactionResponse(obj: any, _argumentName?: string): obj is SuiTransactionResponse;
export declare function isGatewayTxSeqNumber(obj: any, _argumentName?: string): obj is GatewayTxSeqNumber;

@@ -60,6 +81,6 @@ export declare function isGetTxnDigestsResponse(obj: any, _argumentName?: string): obj is GetTxnDigestsResponse;

export declare function isTransactionBytes(obj: any, _argumentName?: string): obj is TransactionBytes;
export declare function isMergeCoinResponse(obj: any, _argumentName?: string): obj is MergeCoinResponse;
export declare function isSplitCoinResponse(obj: any, _argumentName?: string): obj is SplitCoinResponse;
export declare function isPublishResponse(obj: any, _argumentName?: string): obj is PublishResponse;
export declare function isSuiParsedMergeCoinResponse(obj: any, _argumentName?: string): obj is SuiParsedMergeCoinResponse;
export declare function isSuiParsedSplitCoinResponse(obj: any, _argumentName?: string): obj is SuiParsedSplitCoinResponse;
export declare function isSuiParsedPublishResponse(obj: any, _argumentName?: string): obj is SuiParsedPublishResponse;
export declare function isSuiPackage(obj: any, _argumentName?: string): obj is SuiPackage;
export declare function isTransactionResponse(obj: any, _argumentName?: string): obj is TransactionResponse;
export declare function isSuiParsedTransactionResponse(obj: any, _argumentName?: string): obj is SuiParsedTransactionResponse;
import { Provider } from './provider';
import { GatewayTxSeqNumber, GetTxnDigestsResponse, GetObjectDataResponse, SuiObjectInfo, TransactionDigest, TransactionEffectsResponse, TransactionResponse } from '../types';
import { GatewayTxSeqNumber, GetTxnDigestsResponse, GetObjectDataResponse, SuiObjectInfo, SuiMoveFunctionArgTypes, SuiMoveNormalizedModules, SuiMoveNormalizedModule, SuiMoveNormalizedFunction, SuiMoveNormalizedStruct, TransactionDigest, SuiTransactionResponse, SuiObjectRef } from '../types';
import { SignatureScheme } from '../cryptography/publickey';
export declare class JsonRpcProvider extends Provider {

@@ -12,14 +13,22 @@ endpoint: string;

constructor(endpoint: string);
getMoveFunctionArgTypes(objectId: string, moduleName: string, functionName: string): Promise<SuiMoveFunctionArgTypes>;
getNormalizedMoveModulesByPackage(objectId: string): Promise<SuiMoveNormalizedModules>;
getNormalizedMoveModule(objectId: string, moduleName: string): Promise<SuiMoveNormalizedModule>;
getNormalizedMoveFunction(objectId: string, moduleName: string, functionName: string): Promise<SuiMoveNormalizedFunction>;
getNormalizedMoveStruct(objectId: string, moduleName: string, structName: string): Promise<SuiMoveNormalizedStruct>;
getObjectsOwnedByAddress(address: string): Promise<SuiObjectInfo[]>;
getGasObjectsOwnedByAddress(address: string): Promise<SuiObjectInfo[]>;
getObjectsOwnedByObject(objectId: string): Promise<SuiObjectInfo[]>;
getObject(objectId: string): Promise<GetObjectDataResponse>;
getObjectRef(objectId: string): Promise<SuiObjectRef | undefined>;
getObjectBatch(objectIds: string[]): Promise<GetObjectDataResponse[]>;
getTransactionsForObject(objectID: string): Promise<GetTxnDigestsResponse>;
getTransactionsForAddress(addressID: string): Promise<GetTxnDigestsResponse>;
getTransactionWithEffects(digest: TransactionDigest): Promise<TransactionEffectsResponse>;
getTransactionWithEffectsBatch(digests: TransactionDigest[]): Promise<TransactionEffectsResponse[]>;
executeTransaction(txnBytes: string, signature: string, pubkey: string): Promise<TransactionResponse>;
getTransactionWithEffects(digest: TransactionDigest): Promise<SuiTransactionResponse>;
getTransactionWithEffectsBatch(digests: TransactionDigest[]): Promise<SuiTransactionResponse[]>;
executeTransaction(txnBytes: string, signatureScheme: SignatureScheme, signature: string, pubkey: string): Promise<SuiTransactionResponse>;
getTotalTransactionNumber(): Promise<number>;
getTransactionDigestsInRange(start: GatewayTxSeqNumber, end: GatewayTxSeqNumber): Promise<GetTxnDigestsResponse>;
getRecentTransactions(count: number): Promise<GetTxnDigestsResponse>;
syncAccountState(address: string): Promise<any>;
}

@@ -1,2 +0,3 @@

import { GetObjectDataResponse, SuiObjectInfo, GatewayTxSeqNumber, GetTxnDigestsResponse, TransactionResponse } from '../types';
import { SignatureScheme } from '../cryptography/publickey';
import { GetObjectDataResponse, SuiObjectInfo, GatewayTxSeqNumber, GetTxnDigestsResponse, SuiTransactionResponse, SuiObjectRef, SuiMoveFunctionArgTypes, SuiMoveNormalizedFunction, SuiMoveNormalizedStruct, SuiMoveNormalizedModule, SuiMoveNormalizedModules } from '../types';
export declare abstract class Provider {

@@ -8,2 +9,6 @@ /**

/**
* Convenience method for getting all gas objects(SUI Tokens) owned by an address
*/
abstract getGasObjectsOwnedByAddress(_address: string): Promise<SuiObjectInfo[]>;
/**
* Get details about an object

@@ -13,2 +18,7 @@ */

/**
* Get object reference(id, tx digest, version id)
* @param objectId
*/
abstract getObjectRef(objectId: string): Promise<SuiObjectRef | undefined>;
/**
* Get transaction digests for a given range

@@ -30,3 +40,25 @@ *

abstract getTotalTransactionNumber(): Promise<number>;
abstract executeTransaction(txnBytes: string, signature: string, pubkey: string): Promise<TransactionResponse>;
abstract executeTransaction(txnBytes: string, signatureScheme: SignatureScheme, signature: string, pubkey: string): Promise<SuiTransactionResponse>;
/**
* Get Move function argument types like read, write and full access
*/
abstract getMoveFunctionArgTypes(objectId: string, moduleName: string, functionName: string): Promise<SuiMoveFunctionArgTypes>;
/**
* Get a map from module name to
* structured representations of Move modules
*/
abstract getNormalizedMoveModulesByPackage(objectId: string): Promise<SuiMoveNormalizedModules>;
/**
* Get a structured representation of Move module
*/
abstract getNormalizedMoveModule(objectId: string, moduleName: string): Promise<SuiMoveNormalizedModule>;
/**
* Get a structured representation of Move function
*/
abstract getNormalizedMoveFunction(objectId: string, moduleName: string, functionName: string): Promise<SuiMoveNormalizedFunction>;
/**
* Get a structured representation of Move struct
*/
abstract getNormalizedMoveStruct(objectId: string, moduleName: string, structName: string): Promise<SuiMoveNormalizedStruct>;
abstract syncAccountState(address: string): Promise<any>;
}

@@ -1,12 +0,21 @@

import { CertifiedTransaction, TransactionDigest, GetTxnDigestsResponse, GatewayTxSeqNumber, SuiObjectInfo, GetObjectDataResponse, TransactionResponse } from '../types';
import { SignatureScheme } from '../cryptography/publickey';
import { CertifiedTransaction, TransactionDigest, GetTxnDigestsResponse, GatewayTxSeqNumber, SuiObjectInfo, GetObjectDataResponse, SuiTransactionResponse, SuiObjectRef, SuiMoveFunctionArgTypes, SuiMoveNormalizedFunction, SuiMoveNormalizedStruct, SuiMoveNormalizedModule, SuiMoveNormalizedModules } from '../types';
import { Provider } from './provider';
export declare class VoidProvider extends Provider {
getObjectsOwnedByAddress(_address: string): Promise<SuiObjectInfo[]>;
getGasObjectsOwnedByAddress(_address: string): Promise<SuiObjectInfo[]>;
getObject(_objectId: string): Promise<GetObjectDataResponse>;
getObjectRef(_objectId: string): Promise<SuiObjectRef | undefined>;
getTransaction(_digest: TransactionDigest): Promise<CertifiedTransaction>;
executeTransaction(_txnBytes: string, _signature: string, _pubkey: string): Promise<TransactionResponse>;
executeTransaction(_txnBytes: string, _signatureScheme: SignatureScheme, _signature: string, _pubkey: string): Promise<SuiTransactionResponse>;
getTotalTransactionNumber(): Promise<number>;
getTransactionDigestsInRange(_start: GatewayTxSeqNumber, _end: GatewayTxSeqNumber): Promise<GetTxnDigestsResponse>;
getRecentTransactions(_count: number): Promise<GetTxnDigestsResponse>;
getMoveFunctionArgTypes(_objectId: string, _moduleName: string, _functionName: string): Promise<SuiMoveFunctionArgTypes>;
getNormalizedMoveModulesByPackage(_objectId: string): Promise<SuiMoveNormalizedModules>;
getNormalizedMoveModule(_objectId: string, _moduleName: string): Promise<SuiMoveNormalizedModule>;
getNormalizedMoveFunction(_objectId: string, _moduleName: string, _functionName: string): Promise<SuiMoveNormalizedFunction>;
getNormalizedMoveStruct(_objectId: string, _oduleName: string, _structName: string): Promise<SuiMoveNormalizedStruct>;
syncAccountState(_address: string): Promise<any>;
private newError;
}
import { Provider } from '../providers/provider';
import { Base64DataBuffer } from '../serialization/base64';
import { SuiAddress, TransactionResponse } from '../types';
import { SuiAddress, SuiTransactionResponse } from '../types';
import { SignaturePubkeyPair, Signer } from './signer';

@@ -21,24 +21,29 @@ import { MoveCallTransaction, MergeCoinTransaction, SplitCoinTransaction, TransferObjectTransaction, TransferSuiTransaction, TxnDataSerializer, PublishTransaction } from './txn-data-serializers/txn-data-serializer';

*/
signAndExecuteTransaction(txBytes: Base64DataBuffer): Promise<TransactionResponse>;
signAndExecuteTransaction(txBytes: Base64DataBuffer): Promise<SuiTransactionResponse>;
/**
* Trigger gateway to sync account state related to the address,
* based on the account state on validators.
*/
syncAccountState(): Promise<any>;
/**
* Serialize and Sign a `TransferObject` transaction and submit to the Gateway for execution
*/
transferObject(transaction: TransferObjectTransaction): Promise<TransactionResponse>;
transferObject(transaction: TransferObjectTransaction): Promise<SuiTransactionResponse>;
/**
* Serialize and Sign a `TransferSui` transaction and submit to the Gateway for execution
*/
transferSui(transaction: TransferSuiTransaction): Promise<TransactionResponse>;
transferSui(transaction: TransferSuiTransaction): Promise<SuiTransactionResponse>;
/**
* Serialize and Sign a `MergeCoin` transaction and submit to the Gateway for execution
*/
mergeCoin(transaction: MergeCoinTransaction): Promise<TransactionResponse>;
mergeCoin(transaction: MergeCoinTransaction): Promise<SuiTransactionResponse>;
/**
* Serialize and Sign a `SplitCoin` transaction and submit to the Gateway for execution
*/
splitCoin(transaction: SplitCoinTransaction): Promise<TransactionResponse>;
splitCoin(transaction: SplitCoinTransaction): Promise<SuiTransactionResponse>;
/**
* Serialize and Sign a `MoveCall` transaction and submit to the Gateway for execution
*/
executeMoveCall(transaction: MoveCallTransaction): Promise<TransactionResponse>;
publish(transaction: PublishTransaction): Promise<TransactionResponse>;
executeMoveCall(transaction: MoveCallTransaction): Promise<SuiTransactionResponse>;
publish(transaction: PublishTransaction): Promise<SuiTransactionResponse>;
}

@@ -1,2 +0,2 @@

import { PublicKey } from '../cryptography/publickey';
import { PublicKey, SignatureScheme } from '../cryptography/publickey';
import { Base64DataBuffer } from '../serialization/base64';

@@ -7,2 +7,3 @@ /**

export declare type SignaturePubkeyPair = {
signatureScheme: SignatureScheme;
signature: Base64DataBuffer;

@@ -9,0 +10,0 @@ pubKey: PublicKey;

@@ -1,2 +0,2 @@

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("tweetnacl")),r=require("buffer"),n=require("bn.js"),o=t(n),i=require("js-sha3"),s=require("util"),u=t(require("jayson/lib/client/browser")),a=t(require("cross-fetch")),c=function(){function t(t){this.data="string"==typeof t?new Uint8Array(r.Buffer.from(t,"base64")):t}var e=t.prototype;return e.getData=function(){return this.data},e.getLength=function(){return this.data.length},e.toString=function(){return r.Buffer.from(this.data).toString("base64")},t}(),f=function(){function t(t){if(function(t){return void 0!==t._bn}(t))this._bn=t._bn;else{if("string"==typeof t){var e=r.Buffer.from(t,"base64");if(32!==e.length)throw new Error("Invalid public key input. Expected 32 bytes, got "+e.length);this._bn=new o(e)}else this._bn=new o(t);if(this._bn.byteLength()>32)throw new Error("Invalid public key input")}}var e=t.prototype;return e.equals=function(t){return this._bn.eq(t._bn)},e.toBase64=function(){return this.toBuffer().toString("base64")},e.toBytes=function(){return this.toBuffer()},e.toBuffer=function(){var t=this._bn.toArrayLike(r.Buffer);if(32===t.length)return t;var e=r.Buffer.alloc(32);return t.copy(e,32-t.length),e},e.toString=function(){return this.toBase64()},e.toSuiAddress=function(){var t=i.sha3_256(this.toBytes());return new o(t,16).toArray(void 0,32).slice(0,20).reduce((function(t,e){return t+("0"+e.toString(16)).slice(-2)}),"")},t}(),p=function(){function t(t){this.keypair=t||e.sign.keyPair()}t.generate=function(){return new t(e.sign.keyPair())},t.fromSecretKey=function(r,n){var o=e.sign.keyPair.fromSecretKey(r);if(!n||!n.skipValidation){var i=(new s.TextEncoder).encode("sui validation"),u=e.sign.detached(i,o.secretKey);if(!e.sign.detached.verify(i,u,o.publicKey))throw new Error("provided secretKey is invalid")}return new t(o)},t.fromSeed=function(r){return new t(e.sign.keyPair.fromSeed(r))};var r=t.prototype;return r.getPublicKey=function(){return new f(this.keypair.publicKey)},r.signData=function(t){return new c(e.sign.detached(t.getData(),this.keypair.secretKey))},t}(),l=function(){};function h(t,e,r,n,o,i,s){try{var u=t[i](s),a=u.value}catch(t){return void r(t)}u.done?e(a):Promise.resolve(a).then(n,o)}function y(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){h(i,n,o,s,u,"next",t)}function u(t){h(i,n,o,s,u,"throw",t)}s(void 0)}))}}function d(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var g,v=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function a(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new T(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var u=w(s,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var a=c(t,e,r);if("normal"===a.type){if(n=r.done?"completed":"suspendedYield",a.arg===f)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(n="completed",r.method="throw",r.arg=a.arg)}}}(t,r,i),o}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var f={};function p(){}function l(){}function h(){}var y={};u(y,o,(function(){return this}));var d=Object.getPrototypeOf,g=d&&d(d(E([])));g&&g!==e&&r.call(g,o)&&(y=g);var v=h.prototype=p.prototype=Object.create(y);function b(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){var n;this._invoke=function(o,i){function s(){return new e((function(n,s){!function n(o,i,s,u){var a=c(t[o],t,i);if("throw"!==a.type){var f=a.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(p).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,u)}))}u(a.arg)}(o,i,n,s)}))}return n=n?n.then(s,s):s()}}function w(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,w(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function m(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(m,this),this.reset(!0)}function E(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return l.prototype=h,u(v,"constructor",h),u(h,"constructor",l),l.displayName=u(h,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,s,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},b(x.prototype),u(x.prototype,i,(function(){return this})),t.AsyncIterator=x,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var s=new x(a(e,r,n,o),i);return t.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},b(v),u(v,s,"Generator"),u(v,o,(function(){return this})),u(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return s.type="throw",s.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),a=r.call(i,"finallyLoc");if(u&&a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=t,s.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(g={exports:{}}),g.exports);function b(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&t._bn instanceof n.BN}function x(t,e){return"string"==typeof t}function w(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.AddressOwner)||(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.ObjectOwner)||(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.SingleOwner)||"Shared"===t||"Immutable"===t}function m(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.digest)&&x(t.objectId)&&B(t.version)}function j(t,e){return m(t)&&(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.type)&&w(t.owner)&&x(t.previousTransaction)}function T(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Object.entries(t).every((function(t){return x(t[0])}))}function E(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Object.entries(t).every((function(t){var e=t[0];return x(t[1])&&x(e)}))}function O(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&P(t.dataType)&&A(t)||(null!==t&&"object"==typeof t||"function"==typeof t)&&P(t.dataType)&&S(t)}function A(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.type)&&T(t.fields)&&(void 0===t.has_public_transfer||!1===t.has_public_transfer||!0===t.has_public_transfer)}function S(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&E(t.disassembled)}function k(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&O(t.data)&&w(t.owner)&&x(t.previousTransaction)&&B(t.storageRebate)&&m(t.reference)}function C(t,e){return"Exists"===t||"NotExists"===t||"Deleted"===t}function P(t,e){return"moveObject"===t||"package"===t}function _(t,e){return Array.isArray(t)&&t.every((function(t){return j(t)}))}function R(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&C(t.status)&&(x(t.details)||m(t.details)||k(t.details))}function B(t,e){return"number"==typeof t}function q(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.recipient)&&m(t.objectRef)}function I(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.recipient)&&(null===t.amount||B(t.amount))}function D(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&B(t.epoch)&&B(t.storage_charge)&&B(t.computation_charge)}function L(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&q(t.TransferObject)||(null!==t&&"object"==typeof t||"function"==typeof t)&&S(t.Publish)||(null!==t&&"object"==typeof t||"function"==typeof t)&&J(t.Call)||(null!==t&&"object"==typeof t||"function"==typeof t)&&I(t.TransferSui)||(null!==t&&"object"==typeof t||"function"==typeof t)&&D(t.ChangeEpoch)}function M(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.transactions)&&t.transactions.every((function(t){return L(t)}))&&x(t.sender)&&m(t.gasPayment)&&B(t.gasBudget)}function N(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&B(t.epoch)&&Array.isArray(t.signature)&&t.signature.every((function(t){return x(t)}))}function K(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.transactionDigest)&&M(t.data)&&x(t.txSignature)&&N(t.authSignInfo)}function W(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&B(t.computationCost)&&B(t.storageCost)&&B(t.storageRebate)}function G(t,e){return"success"===t||"failure"===t}function z(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&G(t.status)&&(void 0===t.error||x(t.error))}function F(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&w(t.owner)&&m(t.reference)}function U(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&z(t.status)&&W(t.gasUsed)&&(void 0===t.sharedObjects||Array.isArray(t.sharedObjects)&&t.sharedObjects.every((function(t){return m(t)})))&&x(t.transactionDigest)&&(void 0===t.created||Array.isArray(t.created)&&t.created.every((function(t){return F(t)})))&&(void 0===t.mutated||Array.isArray(t.mutated)&&t.mutated.every((function(t){return F(t)})))&&(void 0===t.unwrapped||Array.isArray(t.unwrapped)&&t.unwrapped.every((function(t){return F(t)})))&&(void 0===t.deleted||Array.isArray(t.deleted)&&t.deleted.every((function(t){return m(t)})))&&(void 0===t.wrapped||Array.isArray(t.wrapped)&&t.wrapped.every((function(t){return m(t)})))&&F(t.gasObject)&&(void 0===t.events||Array.isArray(t.events))&&(void 0===t.dependencies||Array.isArray(t.dependencies)&&t.dependencies.every((function(t){return x(t)})))}function V(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&K(t.certificate)&&U(t.effects)&&(null===t.timestamp_ms||B(t.timestamp_ms))}function Z(t,e){return Array.isArray(t)&&t.every((function(t){return Array.isArray(t)&&B(t[0])&&x(t[1])}))}function J(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.package)&&x(t.module)&&x(t.function)&&(void 0===t.typeArguments||Array.isArray(t.typeArguments)&&t.typeArguments.every((function(t){return x(t)})))&&(void 0===t.arguments||Array.isArray(t.arguments)&&t.arguments.every((function(t){return Y(t)})))}function Y(t,e){return x(t)||B(t)||!1===t||!0===t||Array.isArray(t)&&t.every((function(t){return x(t)||B(t)||!1===t||!0===t}))}function Q(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.txBytes)&&m(t.gas)}function X(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&K(t.certificate)&&k(t.updatedCoin)&&k(t.updatedGas)}function $(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&K(t.certificate)&&k(t.updatedCoin)&&Array.isArray(t.newCoins)&&t.newCoins.every((function(t){return k(t)}))&&k(t.updatedGas)}function H(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&K(t.certificate)&&Array.isArray(t.createdObjects)&&t.createdObjects.every((function(t){return k(t)}))&&tt(t.package)&&k(t.updatedGas)}function tt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.digest)&&x(t.objectId)&&B(t.version)}function et(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&V(t.EffectResponse)||(null!==t&&"object"==typeof t||"function"==typeof t)&&$(t.SplitCoinResponse)||(null!==t&&"object"==typeof t||"function"==typeof t)&&X(t.MergeCoinResponse)||(null!==t&&"object"==typeof t||"function"==typeof t)&&H(t.PublishResponse)}function rt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"2.0"===t.jsonrpc&&x(t.id)}var nt=require("lossless-json"),ot=function(){function t(t,e){this.rpcClient=this.createRpcClient(t,e)}var e=t.prototype;return e.createRpcClient=function(t,e){return new u(function(){var r=y(v.mark((function r(n,o){var i,s,u,c;return v.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i={method:"POST",body:n,headers:Object.assign({"Content-Type":"application/json"},e||{})},r.prev=1,r.next=4,a(t,i);case 4:return s=r.sent,r.next=7,s.text();case 7:u=r.sent,c=JSON.stringify(nt.parse(u,(function(t,e){if(null==e)return e;if("balance"===t)return e.toString();try{if(e.isLosslessNumber)return e.valueOf()}catch(t){return e.toString()}return e}))),s.ok?o(null,c):o(new Error(s.status+" "+s.statusText+": "+u)),r.next=15;break;case 12:r.prev=12,r.t0=r.catch(1),r.t0 instanceof Error&&o(r.t0);case 15:case"end":return r.stop()}}),r,null,[[1,12]])})));return function(t,e){return r.apply(this,arguments)}}(),{})},e.requestWithType=function(){var t=y(v.mark((function t(e,r,n){var o;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.request(e,r);case 2:if((null===(i=o=t.sent)||"object"!=typeof i)&&"function"!=typeof i||"2.0"!==i.jsonrpc||!x(i.id)||(null===i.error||"object"!=typeof i.error)&&"function"!=typeof i.error||!x(i.error.message)){t.next=7;break}throw new Error("RPC Error: "+o.error.message);case 7:if(!rt(o)){t.next=13;break}if(!n(o.result)){t.next=12;break}return t.abrupt("return",o.result);case 12:throw new Error("RPC Error: result not of expected type. Result received was: "+JSON.stringify(o.result));case 13:throw new Error("Unexpected RPC Response: "+o);case 14:case"end":return t.stop()}var i}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.request=function(){var t=y(v.mark((function t(e,r){var n=this;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,o){n.rpcClient.request(e,r,(function(e,r){e?o(e):t(r)}))})));case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),e.batchRequestWithType=function(){var t=y(v.mark((function t(e,r){var n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.batchRequest(e);case 2:return n=t.sent.filter((function(t){return rt(t)&&r(t.result)})),t.abrupt("return",n.map((function(t){return t.result})));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.batchRequest=function(){var t=y(v.mark((function t(e){var r=this;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){0===e.length&&t([]);var o=e.map((function(t){return r.rpcClient.request(t.method,t.args)}));r.rpcClient.request(o,(function(e,r){e?n(e):t(r)}))})));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t}(),it=function(t){return"number"==typeof t},st=function(t){function e(e){var r;return(r=t.call(this)||this).endpoint=e,r.client=new ot(e),r}d(e,t);var r=e.prototype;return r.getObjectsOwnedByAddress=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getObjectsOwnedByAddress",[e],_);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching owned object: "+t.t0+" for address "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),r.getObjectsOwnedByObject=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getObjectsOwnedByObject",[e],_);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching owned object: "+t.t0+" for objectId "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),r.getObject=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getObject",[e],R);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching object info: "+t.t0+" for id "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),r.getObjectBatch=function(){var t=y(v.mark((function t(e){var r;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return{method:"sui_getObject",args:[t]}})),t.prev=1,t.next=4,this.client.batchRequestWithType(r,R);case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(1),new Error("Error fetching object info: "+t.t0+" for id "+e);case 10:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(e){return t.apply(this,arguments)}}(),r.getTransactionsForObject=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[{method:"sui_getTransactionsByInputObject",args:[e]},{method:"sui_getTransactionsByMutatedObject",args:[e]}],t.prev=1,t.next=4,this.client.batchRequestWithType(r,Z);case 4:return t.abrupt("return",[].concat((n=t.sent)[0],n[1]));case 8:throw t.prev=8,t.t0=t.catch(1),new Error("Error getting transactions for object: "+t.t0+" for id "+e);case 11:case"end":return t.stop()}}),t,this,[[1,8]])})));return function(e){return t.apply(this,arguments)}}(),r.getTransactionsForAddress=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[{method:"sui_getTransactionsToAddress",args:[e]},{method:"sui_getTransactionsFromAddress",args:[e]}],t.prev=1,t.next=4,this.client.batchRequestWithType(r,Z);case 4:return t.abrupt("return",[].concat((n=t.sent)[0],n[1]));case 8:throw t.prev=8,t.t0=t.catch(1),new Error("Error getting transactions for address: "+t.t0+" for id "+e);case 11:case"end":return t.stop()}}),t,this,[[1,8]])})));return function(e){return t.apply(this,arguments)}}(),r.getTransactionWithEffects=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getTransaction",[e],V);case 3:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error getting transaction with effects: "+t.t0+" for digest "+e);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),r.getTransactionWithEffectsBatch=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return{method:"sui_getTransaction",args:[t]}})),t.prev=1,t.next=4,this.client.batchRequestWithType(r,V);case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(1),n=e.join(", ").substring(0,-2),new Error("Error getting transaction effects: "+t.t0+" for digests ["+n+"]");case 11:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(e){return t.apply(this,arguments)}}(),r.executeTransaction=function(){var t=y(v.mark((function t(e,r,n){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_executeTransaction",[e,r,n],et);case 3:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error executing transaction: "+t.t0+"}");case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r,n){return t.apply(this,arguments)}}(),r.getTotalTransactionNumber=function(){var t=y(v.mark((function t(){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getTotalTransactionNumber",[],it);case 3:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error fetching total transaction number: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(){return t.apply(this,arguments)}}(),r.getTransactionDigestsInRange=function(){var t=y(v.mark((function t(e,r){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getTransactionsInRange",[e,r],Z);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching transaction digests in range: "+t.t0+" for range "+e+"-"+r);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e,r){return t.apply(this,arguments)}}(),r.getRecentTransactions=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getRecentTransactions",[e],Z);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching recent transactions: "+t.t0+" for count "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),e}(l),ut=function(){function t(t){this._data="string"==typeof t?new Uint8Array(r.Buffer.from(t,"hex")):t}var e=t.prototype;return e.getData=function(){return this._data},e.getLength=function(){return this._data.length},e.toString=function(){return r.Buffer.from(this._data).toString("hex")},t}(),at=function(){function t(t){this.client=new ot(t)}var e=t.prototype;return e.newTransferObject=function(){var t=y(v.mark((function t(e,r){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_transferObject",[e,r.objectId,r.gasPayment,r.gasBudget,r.recipient],Q);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error transferring object: "+t.t0+" with args "+r);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newTransferSui=function(){var t=y(v.mark((function t(e,r){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_transferSui",[e,r.suiObjectId,r.gasBudget,r.recipient,r.amount],Q);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error transferring Sui coin: "+t.t0+" with args "+r);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newMoveCall=function(){var t=y(v.mark((function t(e,r){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_moveCall",[e,r.packageObjectId,r.module,r.function,r.typeArguments,r.arguments,r.gasPayment,r.gasBudget],Q);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error executing a move call: "+t.t0+" with args "+r);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newMergeCoin=function(){var t=y(v.mark((function t(e,r){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_mergeCoins",[e,r.primaryCoin,r.coinToMerge,r.gasPayment,r.gasBudget],Q);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error merging coin: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newSplitCoin=function(){var t=y(v.mark((function t(e,r){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_splitCoin",[e,r.coinObjectId,r.splitAmounts,r.gasPayment,r.gasBudget],Q);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error splitting coin: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newPublish=function(){var t=y(v.mark((function t(e,r){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_publish",[e,r.compiledModules,r.gasPayment,r.gasBudget],Q);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error publishing package "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),t}(),ct=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var r=e.prototype;return r.getObjectsOwnedByAddress=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getOwnedObjects");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getObject=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getObject");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getTransaction=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getTransaction");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.executeTransaction=function(){var t=y(v.mark((function t(e,r,n){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("executeTransaction");case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.getTotalTransactionNumber=function(){var t=y(v.mark((function t(){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getTotalTransactionNumber");case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getTransactionDigestsInRange=function(){var t=y(v.mark((function t(e,r){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getTransactionDigestsInRange");case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.getRecentTransactions=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getRecentTransactions");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.newError=function(t){return new Error("Please use a valid provider for "+t)},e}(l),ft=function(){function t(t,e){this.provider=t||new ct;var r="";this.provider instanceof st&&(r=this.provider.endpoint),this.serializer=e||new at(r)}var e=t.prototype;return e.signAndExecuteTransaction=function(){var t=y(v.mark((function t(e){var r;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signData(e);case 2:return r=t.sent,t.next=5,this.provider.executeTransaction(e.toString(),r.signature.toString(),r.pubKey.toString());case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.transferObject=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newTransferObject(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.transferSui=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newTransferSui(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.mergeCoin=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newMergeCoin(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.splitCoin=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newSplitCoin(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.executeMoveCall=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newMoveCall(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.publish=function(){var t=y(v.mark((function t(e){var r,n;return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newPublish(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),pt=function(t){function e(e,r,n){var o;return(o=t.call(this,r,n)||this).keypair=e,o}d(e,t);var r=e.prototype;return r.getAddress=function(){var t=y(v.mark((function t(){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.keypair.getPublicKey().toSuiAddress());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.signData=function(){var t=y(v.mark((function t(e){return v.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",{signature:this.keypair.signData(e),pubKey:this.keypair.getPublicKey()});case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.connect=function(t){return new e(this.keypair,t)},e}(ft),lt=/^(?:[a-zA-Z0-9+\/]{4})*(?:|(?:[a-zA-Z0-9+\/]{3}=)|(?:[a-zA-Z0-9+\/]{2}==)|(?:[a-zA-Z0-9+\/]{1}===))$/;function ht(t){return function(t){return/^(0x|0X)?[a-fA-F0-9]+$/.test(t)&&t.length%2==0}(t)&&20===function(t){return/^(0x|0X)/.test(t)?(t.length-2)/2:t.length/2}(t)}function yt(t){return"Exists"!==t.status?void 0:t.details}function dt(t){return"Deleted"!==t.status?void 0:t.details}function gt(t){return"NotExists"!==t.status?void 0:t.details}function vt(t){var e;return(null==(e=yt(t))?void 0:e.reference)||dt(t)}function bt(t){var e;return null==(e=wt(t))?void 0:e.type}function xt(t){var e;return null==(e=wt(t))?void 0:e.fields}function wt(t){var e="data"in t?t:yt(t);if("moveObject"===(null==e?void 0:e.data.dataType))return e.data}function mt(t){return t.effects.status}function jt(t){return t.effects.gasUsed}function Tt(t){return"SplitCoinResponse"in t?t.SplitCoinResponse:void 0}function Et(t){return"MergeCoinResponse"in t?t.MergeCoinResponse:void 0}var Ot=function(){function t(){}return t.isCoin=function(t){var e,r;return null!=(e=null==(r=bt(t))?void 0:r.startsWith("0x2::coin::Coin"))&&e},t.getBalance=function(e){var r;if(t.isCoin(e)){var n=null==(r=xt(e))?void 0:r.balance;return new o.BN(n,10)}},t.getZero=function(){return new o.BN("0",10)},t}();exports.Base64DataBuffer=c,exports.Coin=Ot,exports.Ed25519Keypair=p,exports.HexDataBuffer=ut,exports.JsonRpcProvider=st,exports.PUBLIC_KEY_SIZE=32,exports.Provider=l,exports.PublicKey=f,exports.RawSigner=pt,exports.RpcTxnDataSerializer=at,exports.SignerWithProvider=ft,exports.getChangeEpochTransaction=function(t){return"ChangeEpoch"in t?t.ChangeEpoch:void 0},exports.getCoinAfterMerge=function(t){var e;return null==(e=Et(t))?void 0:e.updatedCoin},exports.getCoinAfterSplit=function(t){var e;return null==(e=Tt(t))?void 0:e.updatedCoin},exports.getExecutionStatus=mt,exports.getExecutionStatusError=function(t){return mt(t).error},exports.getExecutionStatusGasSummary=jt,exports.getExecutionStatusType=function(t){return mt(t).status},exports.getMergeCoinResponse=Et,exports.getMoveCallTransaction=function(t){return"Call"in t?t.Call:void 0},exports.getMoveObject=wt,exports.getMoveObjectType=bt,exports.getMovePackageContent=function(t){if("disassembled"in t)return t.disassembled;var e=yt(t);return"package"===(null==e?void 0:e.data.dataType)?e.data.disassembled:void 0},exports.getNewlyCreatedCoinsAfterSplit=function(t){var e;return null==(e=Tt(t))?void 0:e.newCoins},exports.getObjectDeletedResponse=dt,exports.getObjectExistsResponse=yt,exports.getObjectFields=xt,exports.getObjectId=function(t){var e,r;return"objectId"in t?t.objectId:null!=(e=null==(r=vt(t))?void 0:r.objectId)?e:gt(t)},exports.getObjectNotExistsResponse=gt,exports.getObjectOwner=function(t){var e;return null==(e=yt(t))?void 0:e.owner},exports.getObjectPreviousTransactionDigest=function(t){var e;return null==(e=yt(t))?void 0:e.previousTransaction},exports.getObjectReference=vt,exports.getObjectType=function(t){var e;return null==(e=yt(t))?void 0:e.data.dataType},exports.getObjectVersion=function(t){var e;return"version"in t?t.version:null==(e=vt(t))?void 0:e.version},exports.getPublishResponse=function(t){return"PublishResponse"in t?t.PublishResponse:void 0},exports.getPublishTransaction=function(t){return"Publish"in t?t.Publish:void 0},exports.getSplitCoinResponse=Tt,exports.getTotalGasUsed=function(t){var e=jt(t);return e.computationCost+e.storageCost-e.storageRebate},exports.getTransactionAuthorityQuorumSignInfo=function(t){return t.authSignInfo},exports.getTransactionData=function(t){return t.data},exports.getTransactionDigest=function(t){return t.transactionDigest},exports.getTransactionEffectsResponse=function(t){return"EffectResponse"in t?t.EffectResponse:void 0},exports.getTransactionGasBudget=function(t){return t.data.gasBudget},exports.getTransactionGasObject=function(t){return t.data.gasPayment},exports.getTransactionKindName=function(t){return Object.keys(t)[0]},exports.getTransactionSender=function(t){return t.data.sender},exports.getTransactionSignature=function(t){return t.txSignature},exports.getTransactions=function(t){return t.data.transactions},exports.getTransferObjectTransaction=function(t){return"TransferObject"in t?t.TransferObject:void 0},exports.getTransferSuiTransaction=function(t){return"TransferSui"in t?t.TransferSui:void 0},exports.hasPublicTransfer=function(t){var e,r;return null!=(e=null==(r=wt(t))?void 0:r.has_public_transfer)&&e},exports.isAuthorityName=function(t,e){return"string"==typeof t},exports.isAuthorityQuorumSignInfo=N,exports.isAuthoritySignature=function(t,e){return"string"==typeof t},exports.isCertifiedTransaction=K,exports.isEd25519KeypairData=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&t.publicKey instanceof Uint8Array&&t.secretKey instanceof Uint8Array},exports.isEmptySignInfo=function(t,e){return"object"==typeof t},exports.isEpochId=function(t,e){return"number"==typeof t},exports.isExecutionStatus=z,exports.isExecutionStatusType=G,exports.isGasCostSummary=W,exports.isGatewayTxSeqNumber=function(t,e){return"number"==typeof t},exports.isGetObjectDataResponse=R,exports.isGetOwnedObjectsResponse=_,exports.isGetTxnDigestsResponse=Z,exports.isKeypair=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.getPublicKey&&"function"==typeof t.signData},exports.isMergeCoinResponse=X,exports.isMergeCoinTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.primaryCoin)&&x(t.coinToMerge)&&(void 0===t.gasPayment||x(t.gasPayment))&&B(t.gasBudget)},exports.isMoveCall=J,exports.isMoveCallTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.packageObjectId)&&x(t.module)&&x(t.function)&&Array.isArray(t.typeArguments)&&t.typeArguments.every((function(t){return x(t)}))&&Array.isArray(t.arguments)&&t.arguments.every((function(t){return Y(t)}))&&(void 0===t.gasPayment||x(t.gasPayment))&&B(t.gasBudget)},exports.isMovePackageContent=E,exports.isObjectContentFields=T,exports.isObjectDigest=function(t,e){return"string"==typeof t},exports.isObjectId=function(t,e){return"string"==typeof t},exports.isObjectOwner=w,exports.isObjectStatus=C,exports.isObjectType=P,exports.isOwnedObjectRef=F,exports.isPublicKeyData=b,exports.isPublicKeyInitData=function(t,e){return x(t)||B(t)||t instanceof Buffer||t instanceof Uint8Array||Array.isArray(t)&&t.every((function(t){return B(t)}))||b(t)},exports.isPublishResponse=H,exports.isPublishTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.compiledModules)&&t.compiledModules.every((function(t){return x(t)}))&&(void 0===t.gasPayment||x(t.gasPayment))&&B(t.gasBudget)},exports.isSequenceNumber=B,exports.isSignaturePubkeyPair=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&t.signature instanceof c&&t.pubKey instanceof f},exports.isSigner=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.getAddress&&"function"==typeof t.signData},exports.isSplitCoinResponse=$,exports.isSplitCoinTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.coinObjectId)&&Array.isArray(t.splitAmounts)&&t.splitAmounts.every((function(t){return B(t)}))&&(void 0===t.gasPayment||x(t.gasPayment))&&B(t.gasBudget)},exports.isSuiAddress=function(t,e){return"string"==typeof t},exports.isSuiChangeEpoch=D,exports.isSuiData=O,exports.isSuiJsonValue=Y,exports.isSuiMoveObject=A,exports.isSuiMovePackage=S,exports.isSuiObject=k,exports.isSuiObjectInfo=j,exports.isSuiObjectRef=m,exports.isSuiPackage=tt,exports.isSuiTransactionKind=L,exports.isSuiTransferSui=I,exports.isTransactionBytes=Q,exports.isTransactionData=M,exports.isTransactionDigest=x,exports.isTransactionEffects=U,exports.isTransactionEffectsResponse=V,exports.isTransactionKindName=function(t,e){return"TransferObject"===t||"Publish"===t||"Call"===t||"TransferSui"===t||"ChangeEpoch"===t},exports.isTransactionResponse=et,exports.isTransferObject=q,exports.isTransferObjectTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.objectId)&&(void 0===t.gasPayment||x(t.gasPayment))&&B(t.gasBudget)&&x(t.recipient)},exports.isTransferSuiTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.suiObjectId)&&B(t.gasBudget)&&x(t.recipient)&&(void 0===t.amount||B(t.amount))},exports.isTxnDataSerializer=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.newTransferObject&&"function"==typeof t.newTransferSui&&"function"==typeof t.newMoveCall&&"function"==typeof t.newMergeCoin&&"function"==typeof t.newSplitCoin&&"function"==typeof t.newPublish},exports.isValidSuiAddress=ht,exports.isValidSuiObjectId=function(t){return ht(t)},exports.isValidTransactionDigest=function(t){return 32===new c(t).getLength()&&lt.test(t)};
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("tweetnacl")),r=require("buffer"),n=require("bn.js"),o=t(n),i=require("js-sha3"),u=t(require("jayson/lib/client/browser")),s=t(require("cross-fetch")),a=require("lossless-json"),c=function(){function t(t){this.data="string"==typeof t?new Uint8Array(r.Buffer.from(t,"base64")):t}var e=t.prototype;return e.getData=function(){return this.data},e.getLength=function(){return this.data.length},e.toString=function(){return r.Buffer.from(this.data).toString("base64")},t}(),f={ED25519:0,Secp256k1:1},p=function(){function t(t){if(function(t){return void 0!==t._bn}(t))this._bn=t._bn;else{if("string"==typeof t){var e=r.Buffer.from(t,"base64");if(32!==e.length)throw new Error("Invalid public key input. Expected 32 bytes, got "+e.length);this._bn=new o(e)}else this._bn=new o(t);if(this._bn.byteLength()>32)throw new Error("Invalid public key input")}}var e=t.prototype;return e.equals=function(t){return this._bn.eq(t._bn)},e.toBase64=function(){return this.toBuffer().toString("base64")},e.toBytes=function(){return this.toBuffer()},e.toBuffer=function(){var t=this._bn.toArrayLike(r.Buffer);if(32===t.length)return t;var e=r.Buffer.alloc(32);return t.copy(e,32-t.length),e},e.toString=function(){return this.toBase64()},e.toSuiAddress=function(t){void 0===t&&(t="ED25519");var e=new Uint8Array(33);e.set([f[t]]),e.set(this.toBytes(),1);var r=i.sha3_256(e);return new o(r,16).toArray(void 0,32).slice(0,20).reduce((function(t,e){return t+("0"+e.toString(16)).slice(-2)}),"")},t}(),l=function(){function t(t){this.keypair=t||e.sign.keyPair()}t.generate=function(){return new t(e.sign.keyPair())},t.fromSecretKey=function(r,n){var o=e.sign.keyPair.fromSecretKey(r);if(!n||!n.skipValidation){var i=(new TextEncoder).encode("sui validation"),u=e.sign.detached(i,o.secretKey);if(!e.sign.detached.verify(i,u,o.publicKey))throw new Error("provided secretKey is invalid")}return new t(o)},t.fromSeed=function(r){return new t(e.sign.keyPair.fromSeed(r))};var r=t.prototype;return r.getPublicKey=function(){return new p(this.keypair.publicKey)},r.signData=function(t){return new c(e.sign.detached(t.getData(),this.keypair.secretKey))},t}(),y=function(){};function h(t,e,r,n,o,i,u){try{var s=t[i](u),a=s.value}catch(t){return void r(t)}s.done?e(a):Promise.resolve(a).then(n,o)}function d(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){h(i,n,o,u,s,"next",t)}function s(t){h(i,n,o,u,s,"throw",t)}u(void 0)}))}}function v(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var g,b=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",u=n.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function a(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new T(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var u=r.delegate;if(u){var s=x(u,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var a=c(t,e,r);if("normal"===a.type){if(n=r.done?"completed":"suspendedYield",a.arg===f)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(n="completed",r.method="throw",r.arg=a.arg)}}}(t,r,i),o}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var f={};function p(){}function l(){}function y(){}var h={};s(h,o,(function(){return this}));var d=Object.getPrototypeOf,v=d&&d(d(S([])));v&&v!==e&&r.call(v,o)&&(h=v);var g=y.prototype=p.prototype=Object.create(h);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(o,i){function u(){return new e((function(n,u){!function n(o,i,u,s){var a=c(t[o],t,i);if("throw"!==a.type){var f=a.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,u,s)}),(function(t){n("throw",t,u,s)})):e.resolve(p).then((function(t){f.value=t,u(f)}),(function(t){return n("throw",t,u,s)}))}s(a.arg)}(o,i,n,u)}))}return n=n?n.then(u,u):u()}}function x(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function m(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(m,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:E}}function E(){return{value:void 0,done:!0}}return l.prototype=y,s(g,"constructor",y),s(y,"constructor",l),l.displayName=s(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,s(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},b(w.prototype),s(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var u=new w(a(e,r,n,o),i);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},b(g),s(g,u,"Generator"),s(g,o,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=S,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(j),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return u.type="throw",u.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var s=r.call(i,"catchLoc"),a=r.call(i,"finallyLoc");if(s&&a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;j(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(g={exports:{}}),g.exports);function w(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&t._bn instanceof n.BN}function x(t,e){return"ED25519"===t||"Secp256k1"===t}function m(t,e){return"string"==typeof t}function j(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.AddressOwner)||(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.ObjectOwner)||(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.SingleOwner)||"Shared"===t||"Immutable"===t}function T(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.digest)&&m(t.objectId)&&L(t.version)}function S(t,e){return T(t)&&(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.type)&&j(t.owner)&&m(t.previousTransaction)}function E(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Object.entries(t).every((function(t){return m(t[0])}))}function A(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Object.entries(t).every((function(t){var e=t[0];return m(t[1])&&m(e)}))}function O(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&U(t.dataType)&&k(t)||(null!==t&&"object"==typeof t||"function"==typeof t)&&U(t.dataType)&&_(t)}function k(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.type)&&E(t.fields)&&(void 0===t.has_public_transfer||!1===t.has_public_transfer||!0===t.has_public_transfer)}function _(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&A(t.disassembled)}function P(t,e){return m(t)||(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.Object)}function C(t,e){return Array.isArray(t)&&t.every((function(t){return P(t)}))}function M(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Object.entries(t).every((function(t){var e=t[0];return B(t[1])&&m(e)}))}function B(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&L(t.file_format_version)&&m(t.address)&&m(t.name)&&Array.isArray(t.friends)&&t.friends.every((function(t){return R(t)}))&&(null!==t.structs&&"object"==typeof t.structs||"function"==typeof t.structs)&&Object.entries(t.structs).every((function(t){var e=t[0];return I(t[1])&&m(e)}))&&(null!==t.exposed_functions&&"object"==typeof t.exposed_functions||"function"==typeof t.exposed_functions)&&Object.entries(t.exposed_functions).every((function(t){var e=t[0];return D(t[1])&&m(e)}))}function R(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.address)&&m(t.name)}function I(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&W(t.abilities)&&Array.isArray(t.type_parameters)&&t.type_parameters.every((function(t){return N(t)}))&&Array.isArray(t.fields)&&t.fields.every((function(t){return q(t)}))}function N(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&W(t.constraints)&&"boolean"==typeof t.is_phantom}function q(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.name)&&F(t.type_)}function D(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&z(t.visibility)&&"boolean"==typeof t.is_entry&&Array.isArray(t.type_parameters)&&t.type_parameters.every((function(t){return W(t)}))&&Array.isArray(t.parameters)&&t.parameters.every((function(t){return F(t)}))&&Array.isArray(t.return_)&&t.return_.every((function(t){return F(t)}))}function z(t,e){return"Private"===t||"Public"===t||"Friend"===t}function L(t,e){return"number"==typeof t}function W(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.abilities)&&t.abilities.every((function(t){return m(t)}))}function F(t,e){return m(t)||(null!==t&&"object"==typeof t||"function"==typeof t)&&L(t.TypeParameter)||(null!==t&&"object"==typeof t||"function"==typeof t)&&F(t.Reference)||(null!==t&&"object"==typeof t||"function"==typeof t)&&F(t.MutableReference)||(null!==t&&"object"==typeof t||"function"==typeof t)&&F(t.Vector)||(null!==t&&"object"==typeof t||"function"==typeof t)&&(null!==t.Struct&&"object"==typeof t.Struct||"function"==typeof t.Struct)&&m(t.Struct.address)&&m(t.Struct.module)&&m(t.Struct.name)&&Array.isArray(t.Struct.type_arguments)&&t.Struct.type_arguments.every((function(t){return F(t)}))}function K(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&O(t.data)&&j(t.owner)&&m(t.previousTransaction)&&L(t.storageRebate)&&T(t.reference)}function G(t,e){return"Exists"===t||"NotExists"===t||"Deleted"===t}function U(t,e){return"moveObject"===t||"package"===t}function V(t,e){return Array.isArray(t)&&t.every((function(t){return S(t)}))}function Z(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&G(t.status)&&(m(t.details)||T(t.details)||K(t.details))}function Y(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.packageId)&&m(t.transactionModule)&&m(t.sender)&&m(t.type)&&(null!==t.fields&&"object"==typeof t.fields||"function"==typeof t.fields)&&m(t.bcs)}function J(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.sender)&&m(t.packageId)}function $(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.packageId)&&m(t.transactionModule)&&m(t.sender)&&j(t.recipient)&&m(t.objectId)&&L(t.version)&&m(t.type)}function Q(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.packageId)&&m(t.transactionModule)&&m(t.sender)&&m(t.objectId)}function X(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.packageId)&&m(t.transactionModule)&&m(t.sender)&&j(t.recipient)&&m(t.objectId)}function H(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.recipient)&&T(t.objectRef)}function tt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.recipient)&&(null===t.amount||L(t.amount))}function et(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&L(t.epoch)&&L(t.storage_charge)&&L(t.computation_charge)}function rt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&H(t.TransferObject)||(null!==t&&"object"==typeof t||"function"==typeof t)&&_(t.Publish)||(null!==t&&"object"==typeof t||"function"==typeof t)&&yt(t.Call)||(null!==t&&"object"==typeof t||"function"==typeof t)&&tt(t.TransferSui)||(null!==t&&"object"==typeof t||"function"==typeof t)&&et(t.ChangeEpoch)}function nt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.transactions)&&t.transactions.every((function(t){return rt(t)}))&&m(t.sender)&&T(t.gasPayment)&&L(t.gasBudget)}function ot(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&L(t.epoch)&&Array.isArray(t.signature)&&t.signature.every((function(t){return m(t)}))}function it(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.transactionDigest)&&nt(t.data)&&m(t.txSignature)&&ot(t.authSignInfo)}function ut(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&L(t.computationCost)&&L(t.storageCost)&&L(t.storageRebate)}function st(t,e){return"success"===t||"failure"===t}function at(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&st(t.status)&&(void 0===t.error||m(t.error))}function ct(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&j(t.owner)&&T(t.reference)}function ft(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&at(t.status)&&ut(t.gasUsed)&&(void 0===t.sharedObjects||Array.isArray(t.sharedObjects)&&t.sharedObjects.every((function(t){return T(t)})))&&m(t.transactionDigest)&&(void 0===t.created||Array.isArray(t.created)&&t.created.every((function(t){return ct(t)})))&&(void 0===t.mutated||Array.isArray(t.mutated)&&t.mutated.every((function(t){return ct(t)})))&&(void 0===t.unwrapped||Array.isArray(t.unwrapped)&&t.unwrapped.every((function(t){return ct(t)})))&&(void 0===t.deleted||Array.isArray(t.deleted)&&t.deleted.every((function(t){return T(t)})))&&(void 0===t.wrapped||Array.isArray(t.wrapped)&&t.wrapped.every((function(t){return T(t)})))&&ct(t.gasObject)&&(void 0===t.events||Array.isArray(t.events))&&(void 0===t.dependencies||Array.isArray(t.dependencies)&&t.dependencies.every((function(t){return m(t)})))}function pt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&it(t.certificate)&&ft(t.effects)&&(null===t.timestamp_ms||L(t.timestamp_ms))&&(null===t.parsed_data||(null!==t.parsed_data&&"object"==typeof t.parsed_data||"function"==typeof t.parsed_data)&&gt(t.parsed_data.SplitCoin)||(null!==t.parsed_data&&"object"==typeof t.parsed_data||"function"==typeof t.parsed_data)&&vt(t.parsed_data.MergeCoin)||(null!==t.parsed_data&&"object"==typeof t.parsed_data||"function"==typeof t.parsed_data)&&bt(t.parsed_data.Publish))}function lt(t,e){return Array.isArray(t)&&t.every((function(t){return Array.isArray(t)&&L(t[0])&&m(t[1])}))}function yt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&T(t.package)&&m(t.module)&&m(t.function)&&(void 0===t.typeArguments||Array.isArray(t.typeArguments)&&t.typeArguments.every((function(t){return m(t)})))&&(void 0===t.arguments||Array.isArray(t.arguments)&&t.arguments.every((function(t){return ht(t)})))}function ht(t,e){return m(t)||L(t)||!1===t||!0===t||Array.isArray(t)&&t.every((function(t){return m(t)||L(t)||!1===t||!0===t}))}function dt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.txBytes)&&T(t.gas)}function vt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&K(t.updatedCoin)&&K(t.updatedGas)}function gt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&K(t.updatedCoin)&&Array.isArray(t.newCoins)&&t.newCoins.every((function(t){return K(t)}))&&K(t.updatedGas)}function bt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.createdObjects)&&t.createdObjects.every((function(t){return K(t)}))&&wt(t.package)&&K(t.updatedGas)}function wt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.digest)&&m(t.objectId)&&L(t.version)}function xt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"2.0"===t.jsonrpc&&m(t.id)}var mt=function(){function t(t,e){this.rpcClient=this.createRpcClient(t,e)}var e=t.prototype;return e.createRpcClient=function(t,e){return new u(function(){var r=d(b.mark((function r(n,o){var i,u,c,f;return b.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return i={method:"POST",body:n,headers:Object.assign({"Content-Type":"application/json"},e||{})},r.prev=1,r.next=4,s(t,i);case 4:return u=r.sent,r.next=7,u.text();case 7:c=r.sent,f=JSON.stringify(a.parse(c,(function(t,e){if(null==e)return e;if("balance"===t&&"number"==typeof e)return e.toString();try{if(e.isLosslessNumber)return e.valueOf()}catch(t){return e.toString()}return e}))),u.ok?o(null,f):o(new Error(u.status+" "+u.statusText+": "+c)),r.next=15;break;case 12:r.prev=12,r.t0=r.catch(1),r.t0 instanceof Error&&o(r.t0);case 15:case"end":return r.stop()}}),r,null,[[1,12]])})));return function(t,e){return r.apply(this,arguments)}}(),{})},e.requestWithType=function(){var t=d(b.mark((function t(e,r,n){var o;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.request(e,r);case 2:if((null===(i=o=t.sent)||"object"!=typeof i)&&"function"!=typeof i||"2.0"!==i.jsonrpc||!m(i.id)||(null===i.error||"object"!=typeof i.error)&&"function"!=typeof i.error||!m(i.error.message)){t.next=7;break}throw new Error("RPC Error: "+o.error.message);case 7:if(!xt(o)){t.next=11;break}if(!n(o.result)){t.next=10;break}return t.abrupt("return",o.result);case 10:throw new Error("RPC Error: result not of expected type. Result received was: "+JSON.stringify(o.result));case 11:throw new Error("Unexpected RPC Response: "+o);case 12:case"end":return t.stop()}var i}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),e.request=function(){var t=d(b.mark((function t(e,r){var n=this;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,o){n.rpcClient.request(e,r,(function(e,r){e?o(e):t(r)}))})));case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),e.batchRequestWithType=function(){var t=d(b.mark((function t(e,r){var n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.batchRequest(e);case 2:return n=t.sent.filter((function(t){return xt(t)&&r(t.result)})),t.abrupt("return",n.map((function(t){return t.result})));case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),e.batchRequest=function(){var t=d(b.mark((function t(e){var r=this;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){0===e.length&&t([]);var o=e.map((function(t){return r.rpcClient.request(t.method,t.args)}));r.rpcClient.request(o,(function(e,r){e?n(e):t(r)}))})));case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t}(),jt=/^(?:[a-zA-Z0-9+\/]{4})*(?:|(?:[a-zA-Z0-9+\/]{3}=)|(?:[a-zA-Z0-9+\/]{2}==)|(?:[a-zA-Z0-9+\/]{1}===))$/;function Tt(t){return function(t){return/^(0x|0X)?[a-fA-F0-9]+$/.test(t)&&t.length%2==0}(t)&&20===function(t){return/^(0x|0X)/.test(t)?(t.length-2)/2:t.length/2}(t)}function St(t){return"Exists"!==t.status?void 0:t.details}function Et(t){return"Deleted"!==t.status?void 0:t.details}function At(t){return"NotExists"!==t.status?void 0:t.details}function Ot(t){var e;return(null==(e=St(t))?void 0:e.reference)||Et(t)}function kt(t){var e;return null==(e=Pt(t))?void 0:e.type}function _t(t){var e;return"fields"in t?t.fields:null==(e=Pt(t))?void 0:e.fields}function Pt(t){var e="data"in t?t:St(t);if("moveObject"===(null==e?void 0:e.data.dataType))return e.data}function Ct(t){return t.effects.status}function Mt(t){return t.effects.gasUsed}function Bt(t){var e=t.parsed_data;return e&&"SplitCoin"in e?e.SplitCoin:void 0}function Rt(t){var e=t.parsed_data;return e&&"MergeCoin"in e?e.MergeCoin:void 0}var It=/^0x2::coin::Coin<(.+)>$/,Nt=function(){function t(){}return t.isCoin=function(e){var r,n;return null!=(r=null==(n=t.getType(e))?void 0:n.startsWith("0x2::coin::Coin"))&&r},t.getCoinTypeArg=function(e){var r,n=null==(r=t.getType(e))?void 0:r.match(It);return n?n[1]:null},t.isSUI=function(e){var r=t.getCoinTypeArg(e);return!!r&&"SUI"===t.getCoinSymbol(r)},t.getCoinSymbol=function(t){return t.substring(t.lastIndexOf(":")+1)},t.getBalance=function(e){var r;if(t.isCoin(e)){var n=null==(r=_t(e))?void 0:r.balance;return new o.BN(n,10)}},t.getZero=function(){return new o.BN("0",10)},t.getType=function(t){return"status"in t?kt(t):t.type},t}(),qt=function(t){return"number"==typeof t},Dt=function(t){return!0},zt=function(t){function e(e){var r;return(r=t.call(this)||this).endpoint=e,r.client=new mt(e),r}v(e,t);var r=e.prototype;return r.getMoveFunctionArgTypes=function(){var t=d(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getMoveFunctionArgTypes",[e,r,n],C);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching Move function arg types with package object ID: "+e+", module name: "+r+", function name: "+n);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e,r,n){return t.apply(this,arguments)}}(),r.getNormalizedMoveModulesByPackage=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getNormalizedMoveModulesByPackage",[e],M);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching package: "+t.t0+" for package "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),r.getNormalizedMoveModule=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getNormalizedMoveModule",[e,r],B);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching module: "+t.t0+" for package "+e+", module "+r+"}");case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e,r){return t.apply(this,arguments)}}(),r.getNormalizedMoveFunction=function(){var t=d(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getNormalizedMoveFunction",[e,r,n],D);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching function: "+t.t0+" for package "+e+", module "+r+" and function "+n+"}");case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e,r,n){return t.apply(this,arguments)}}(),r.getNormalizedMoveStruct=function(){var t=d(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getNormalizedMoveStruct",[e,r,n],I);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching struct: "+t.t0+" for package "+e+", module "+r+" and struct "+n+"}");case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e,r,n){return t.apply(this,arguments)}}(),r.getObjectsOwnedByAddress=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getObjectsOwnedByAddress",[e],V);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching owned object: "+t.t0+" for address "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),r.getGasObjectsOwnedByAddress=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getObjectsOwnedByAddress(e);case 2:return t.abrupt("return",t.sent.filter((function(t){return Nt.isSUI(t)})));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getObjectsOwnedByObject=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getObjectsOwnedByObject",[e],V);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching owned object: "+t.t0+" for objectId "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),r.getObject=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getObject",[e],Z);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching object info: "+t.t0+" for id "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),r.getObjectRef=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getObject(e);case 2:return t.abrupt("return",Ot(t.sent));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getObjectBatch=function(){var t=d(b.mark((function t(e){var r;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return{method:"sui_getObject",args:[t]}})),t.prev=1,t.next=4,this.client.batchRequestWithType(r,Z);case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(1),new Error("Error fetching object info: "+t.t0+" for id "+e);case 10:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(e){return t.apply(this,arguments)}}(),r.getTransactionsForObject=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[{method:"sui_getTransactionsByInputObject",args:[e]},{method:"sui_getTransactionsByMutatedObject",args:[e]}],t.prev=1,t.next=4,this.client.batchRequestWithType(r,lt);case 4:return t.abrupt("return",[].concat((n=t.sent)[0],n[1]));case 8:throw t.prev=8,t.t0=t.catch(1),new Error("Error getting transactions for object: "+t.t0+" for id "+e);case 11:case"end":return t.stop()}}),t,this,[[1,8]])})));return function(e){return t.apply(this,arguments)}}(),r.getTransactionsForAddress=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=[{method:"sui_getTransactionsToAddress",args:[e]},{method:"sui_getTransactionsFromAddress",args:[e]}],t.prev=1,t.next=4,this.client.batchRequestWithType(r,lt);case 4:return t.abrupt("return",[].concat((n=t.sent)[0],n[1]));case 8:throw t.prev=8,t.t0=t.catch(1),new Error("Error getting transactions for address: "+t.t0+" for id "+e);case 11:case"end":return t.stop()}}),t,this,[[1,8]])})));return function(e){return t.apply(this,arguments)}}(),r.getTransactionWithEffects=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getTransaction",[e],pt);case 3:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error getting transaction with effects: "+t.t0+" for digest "+e);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),r.getTransactionWithEffectsBatch=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.map((function(t){return{method:"sui_getTransaction",args:[t]}})),t.prev=1,t.next=4,this.client.batchRequestWithType(r,pt);case 4:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(1),n=e.join(", ").substring(0,-2),new Error("Error getting transaction effects: "+t.t0+" for digests ["+n+"]");case 11:case"end":return t.stop()}}),t,this,[[1,7]])})));return function(e){return t.apply(this,arguments)}}(),r.executeTransaction=function(){var t=d(b.mark((function t(e,r,n,o){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_executeTransaction",[e,r,n,o],pt);case 3:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error executing transaction: "+t.t0+"}");case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r,n,o){return t.apply(this,arguments)}}(),r.getTotalTransactionNumber=function(){var t=d(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getTotalTransactionNumber",[],qt);case 3:return t.abrupt("return",t.sent);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error fetching total transaction number: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(){return t.apply(this,arguments)}}(),r.getTransactionDigestsInRange=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getTransactionsInRange",[e,r],lt);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching transaction digests in range: "+t.t0+" for range "+e+"-"+r);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e,r){return t.apply(this,arguments)}}(),r.getRecentTransactions=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_getRecentTransactions",[e],lt);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error fetching recent transactions: "+t.t0+" for count "+e);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),r.syncAccountState=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_syncAccountState",[e],Dt);case 3:return t.abrupt("return",t.sent);case 6:throw t.prev=6,t.t0=t.catch(0),new Error("Error sync account address for address: "+e+" with error: "+t.t0);case 9:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e){return t.apply(this,arguments)}}(),e}(y),Lt=function(){function t(t){this._data="string"==typeof t?new Uint8Array(r.Buffer.from(t,"hex")):t}var e=t.prototype;return e.getData=function(){return this._data},e.getLength=function(){return this._data.length},e.toString=function(){return r.Buffer.from(this._data).toString("hex")},t}(),Wt=function(){function t(t){this.client=new mt(t)}var e=t.prototype;return e.newTransferObject=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_transferObject",[e,r.objectId,r.gasPayment,r.gasBudget,r.recipient],dt);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error transferring object: "+t.t0+" with args "+r);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newTransferSui=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_transferSui",[e,r.suiObjectId,r.gasBudget,r.recipient,r.amount],dt);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error transferring Sui coin: "+t.t0+" with args "+r);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newMoveCall=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_moveCall",[e,r.packageObjectId,r.module,r.function,r.typeArguments,r.arguments,r.gasPayment,r.gasBudget],dt);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error executing a move call: "+t.t0+" with args "+r);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newMergeCoin=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_mergeCoins",[e,r.primaryCoin,r.coinToMerge,r.gasPayment,r.gasBudget],dt);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error merging coin: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newSplitCoin=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_splitCoin",[e,r.coinObjectId,r.splitAmounts,r.gasPayment,r.gasBudget],dt);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error splitting coin: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),e.newPublish=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.requestWithType("sui_publish",[e,r.compiledModules,r.gasPayment,r.gasBudget],dt);case 3:return t.abrupt("return",new c(t.sent.txBytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error publishing package "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e,r){return t.apply(this,arguments)}}(),t}(),Ft=function(t){function e(){return t.apply(this,arguments)||this}v(e,t);var r=e.prototype;return r.getObjectsOwnedByAddress=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getObjectsOwnedByAddress");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getGasObjectsOwnedByAddress=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getGasObjectsOwnedByAddress");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getObject=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getObject");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getObjectRef=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getObjectRef");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getTransaction=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getTransaction");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.executeTransaction=function(){var t=d(b.mark((function t(e,r,n,o){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("executeTransaction");case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n,o){return t.apply(this,arguments)}}(),r.getTotalTransactionNumber=function(){var t=d(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getTotalTransactionNumber");case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.getTransactionDigestsInRange=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getTransactionDigestsInRange");case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.getRecentTransactions=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getRecentTransactions");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getMoveFunctionArgTypes=function(){var t=d(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getMoveFunctionArgTypes");case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.getNormalizedMoveModulesByPackage=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getNormalizedMoveModulesByPackage");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getNormalizedMoveModule=function(){var t=d(b.mark((function t(e,r){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getNormalizedMoveModule");case 1:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.getNormalizedMoveFunction=function(){var t=d(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getNormalizedMoveFunction");case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.getNormalizedMoveStruct=function(){var t=d(b.mark((function t(e,r,n){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getNormalizedMoveStruct");case 1:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.syncAccountState=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("syncAccountState");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.newError=function(t){return new Error("Please use a valid provider for "+t)},e}(y),Kt=function(){function t(t,e){this.provider=t||new Ft;var r="";this.provider instanceof zt&&(r=this.provider.endpoint),this.serializer=e||new Wt(r)}var e=t.prototype;return e.signAndExecuteTransaction=function(){var t=d(b.mark((function t(e){var r;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signData(e);case 2:return r=t.sent,t.next=5,this.provider.executeTransaction(e.toString(),r.signatureScheme,r.signature.toString(),r.pubKey.toString());case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.syncAccountState=function(){var t=d(b.mark((function t(){var e;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return e=t.sent,t.next=5,this.provider.syncAccountState(e);case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.transferObject=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newTransferObject(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.transferSui=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newTransferSui(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.mergeCoin=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newMergeCoin(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.splitCoin=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newSplitCoin(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.executeMoveCall=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newMoveCall(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.publish=function(){var t=d(b.mark((function t(e){var r,n;return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getAddress();case 2:return r=t.sent,t.next=5,this.serializer.newPublish(r,e);case 5:return n=t.sent,t.next=8,this.signAndExecuteTransaction(n);case 8:return t.abrupt("return",t.sent);case 9:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}(),Gt=function(t){function e(e,r,n){var o;return(o=t.call(this,r,n)||this).keypair=e,o}v(e,t);var r=e.prototype;return r.getAddress=function(){var t=d(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",this.keypair.getPublicKey().toSuiAddress());case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),r.signData=function(){var t=d(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",{signatureScheme:"ED25519",signature:this.keypair.signData(e),pubKey:this.keypair.getPublicKey()});case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.connect=function(t){return new e(this.keypair,t)},e}(Kt);exports.Base64DataBuffer=c,exports.Coin=Nt,exports.Ed25519Keypair=l,exports.HexDataBuffer=Lt,exports.JsonRpcProvider=zt,exports.PUBLIC_KEY_SIZE=32,exports.Provider=y,exports.PublicKey=p,exports.RawSigner=Gt,exports.RpcTxnDataSerializer=Wt,exports.SignerWithProvider=Kt,exports.TYPE_BYTE=0,exports.getChangeEpochTransaction=function(t){return"ChangeEpoch"in t?t.ChangeEpoch:void 0},exports.getCoinAfterMerge=function(t){var e;return null==(e=Rt(t))?void 0:e.updatedCoin},exports.getCoinAfterSplit=function(t){var e;return null==(e=Bt(t))?void 0:e.updatedCoin},exports.getExecutionStatus=Ct,exports.getExecutionStatusError=function(t){return Ct(t).error},exports.getExecutionStatusGasSummary=Mt,exports.getExecutionStatusType=function(t){return Ct(t).status},exports.getMoveCallTransaction=function(t){return"Call"in t?t.Call:void 0},exports.getMoveObject=Pt,exports.getMoveObjectType=kt,exports.getMovePackageContent=function(t){if("disassembled"in t)return t.disassembled;var e=St(t);return"package"===(null==e?void 0:e.data.dataType)?e.data.disassembled:void 0},exports.getNewlyCreatedCoinsAfterSplit=function(t){var e;return null==(e=Bt(t))?void 0:e.newCoins},exports.getObjectDeletedResponse=Et,exports.getObjectExistsResponse=St,exports.getObjectFields=_t,exports.getObjectId=function(t){var e,r;return"objectId"in t?t.objectId:null!=(e=null==(r=Ot(t))?void 0:r.objectId)?e:At(t)},exports.getObjectNotExistsResponse=At,exports.getObjectOwner=function(t){var e;return null==(e=St(t))?void 0:e.owner},exports.getObjectPreviousTransactionDigest=function(t){var e;return null==(e=St(t))?void 0:e.previousTransaction},exports.getObjectReference=Ot,exports.getObjectType=function(t){var e;return null==(e=St(t))?void 0:e.data.dataType},exports.getObjectVersion=function(t){var e;return"version"in t?t.version:null==(e=Ot(t))?void 0:e.version},exports.getParsedMergeCoinResponse=Rt,exports.getParsedPublishResponse=function(t){var e=t.parsed_data;return e&&"Publish"in e?e.Publish:void 0},exports.getParsedSplitCoinResponse=Bt,exports.getPublishTransaction=function(t){return"Publish"in t?t.Publish:void 0},exports.getTotalGasUsed=function(t){var e=Mt(t);return e.computationCost+e.storageCost-e.storageRebate},exports.getTransactionAuthorityQuorumSignInfo=function(t){return t.authSignInfo},exports.getTransactionData=function(t){return t.data},exports.getTransactionDigest=function(t){return t.transactionDigest},exports.getTransactionGasBudget=function(t){return t.data.gasBudget},exports.getTransactionGasObject=function(t){return t.data.gasPayment},exports.getTransactionKindName=function(t){return Object.keys(t)[0]},exports.getTransactionSender=function(t){return t.data.sender},exports.getTransactionSignature=function(t){return t.txSignature},exports.getTransactions=function(t){return t.data.transactions},exports.getTransferObjectTransaction=function(t){return"TransferObject"in t?t.TransferObject:void 0},exports.getTransferSuiTransaction=function(t){return"TransferSui"in t?t.TransferSui:void 0},exports.hasPublicTransfer=function(t){var e,r;return null!=(e=null==(r=Pt(t))?void 0:r.has_public_transfer)&&e},exports.isAuthorityName=function(t,e){return"string"==typeof t},exports.isAuthorityQuorumSignInfo=ot,exports.isAuthoritySignature=function(t,e){return"string"==typeof t},exports.isCertifiedTransaction=it,exports.isDeleteObjectEvent=Q,exports.isEd25519KeypairData=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&t.publicKey instanceof Uint8Array&&t.secretKey instanceof Uint8Array},exports.isEmptySignInfo=function(t,e){return"object"==typeof t},exports.isEpochId=function(t,e){return"number"==typeof t},exports.isExecutionStatus=at,exports.isExecutionStatusType=st,exports.isGasCostSummary=ut,exports.isGatewayTxSeqNumber=function(t,e){return"number"==typeof t},exports.isGetObjectDataResponse=Z,exports.isGetOwnedObjectsResponse=V,exports.isGetTxnDigestsResponse=lt,exports.isKeypair=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.getPublicKey&&"function"==typeof t.signData},exports.isMergeCoinTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.primaryCoin)&&m(t.coinToMerge)&&(void 0===t.gasPayment||m(t.gasPayment))&&L(t.gasBudget)},exports.isMoveCall=yt,exports.isMoveCallTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.packageObjectId)&&m(t.module)&&m(t.function)&&Array.isArray(t.typeArguments)&&t.typeArguments.every((function(t){return m(t)}))&&Array.isArray(t.arguments)&&t.arguments.every((function(t){return ht(t)}))&&(void 0===t.gasPayment||m(t.gasPayment))&&L(t.gasBudget)},exports.isMoveEvent=Y,exports.isMovePackageContent=A,exports.isNewObjectEvent=X,exports.isObjectContentFields=E,exports.isObjectDigest=function(t,e){return"string"==typeof t},exports.isObjectId=function(t,e){return"string"==typeof t},exports.isObjectOwner=j,exports.isObjectStatus=G,exports.isObjectType=U,exports.isOwnedObjectRef=ct,exports.isPublicKeyData=w,exports.isPublicKeyInitData=function(t,e){return m(t)||L(t)||t instanceof Buffer||t instanceof Uint8Array||Array.isArray(t)&&t.every((function(t){return L(t)}))||w(t)},exports.isPublishEvent=J,exports.isPublishTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.compiledModules)&&t.compiledModules.every((function(t){return m(t)}))&&(void 0===t.gasPayment||m(t.gasPayment))&&L(t.gasBudget)},exports.isSequenceNumber=function(t,e){return"number"==typeof t},exports.isSignaturePubkeyPair=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&x(t.signatureScheme)&&t.signature instanceof c&&t.pubKey instanceof p},exports.isSignatureScheme=x,exports.isSigner=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.getAddress&&"function"==typeof t.signData},exports.isSplitCoinTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.coinObjectId)&&Array.isArray(t.splitAmounts)&&t.splitAmounts.every((function(t){return L(t)}))&&(void 0===t.gasPayment||m(t.gasPayment))&&L(t.gasBudget)},exports.isSuiAddress=function(t,e){return"string"==typeof t},exports.isSuiChangeEpoch=et,exports.isSuiData=O,exports.isSuiEvent=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Y(t.moveEvent)||(null!==t&&"object"==typeof t||"function"==typeof t)&&J(t.publish)||(null!==t&&"object"==typeof t||"function"==typeof t)&&$(t.transferObject)||(null!==t&&"object"==typeof t||"function"==typeof t)&&Q(t.deleteObject)||(null!==t&&"object"==typeof t||"function"==typeof t)&&X(t.newObject)||(null!==t&&"object"==typeof t||"function"==typeof t)&&"bigint"==typeof t.epochChange||(null!==t&&"object"==typeof t||"function"==typeof t)&&"bigint"==typeof t.checkpoint},exports.isSuiJsonValue=ht,exports.isSuiMoveAbilitySet=W,exports.isSuiMoveFunctionArgType=P,exports.isSuiMoveFunctionArgTypes=C,exports.isSuiMoveFunctionArgTypesResponse=function(t,e){return Array.isArray(t)&&t.every((function(t){return P(t)}))},exports.isSuiMoveModuleId=R,exports.isSuiMoveNormalizedField=q,exports.isSuiMoveNormalizedFunction=D,exports.isSuiMoveNormalizedModule=B,exports.isSuiMoveNormalizedModules=M,exports.isSuiMoveNormalizedStruct=I,exports.isSuiMoveNormalizedType=F,exports.isSuiMoveObject=k,exports.isSuiMovePackage=_,exports.isSuiMoveStructTypeParameter=N,exports.isSuiMoveTypeParameterIndex=L,exports.isSuiMoveVisibility=z,exports.isSuiObject=K,exports.isSuiObjectInfo=S,exports.isSuiObjectRef=T,exports.isSuiPackage=wt,exports.isSuiParsedMergeCoinResponse=vt,exports.isSuiParsedPublishResponse=bt,exports.isSuiParsedSplitCoinResponse=gt,exports.isSuiParsedTransactionResponse=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&gt(t.SplitCoin)||(null!==t&&"object"==typeof t||"function"==typeof t)&&vt(t.MergeCoin)||(null!==t&&"object"==typeof t||"function"==typeof t)&&bt(t.Publish)},exports.isSuiTransactionKind=rt,exports.isSuiTransactionResponse=pt,exports.isSuiTransferSui=tt,exports.isTransactionBytes=dt,exports.isTransactionData=nt,exports.isTransactionDigest=m,exports.isTransactionEffects=ft,exports.isTransactionKindName=function(t,e){return"TransferObject"===t||"Publish"===t||"Call"===t||"TransferSui"===t||"ChangeEpoch"===t},exports.isTransferObject=H,exports.isTransferObjectEvent=$,exports.isTransferObjectTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.objectId)&&(void 0===t.gasPayment||m(t.gasPayment))&&L(t.gasBudget)&&m(t.recipient)},exports.isTransferSuiTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.suiObjectId)&&L(t.gasBudget)&&m(t.recipient)&&(void 0===t.amount||L(t.amount))},exports.isTxnDataSerializer=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.newTransferObject&&"function"==typeof t.newTransferSui&&"function"==typeof t.newMoveCall&&"function"==typeof t.newMergeCoin&&"function"==typeof t.newSplitCoin&&"function"==typeof t.newPublish},exports.isValidSuiAddress=Tt,exports.isValidSuiObjectId=function(t){return Tt(t)},exports.isValidTransactionDigest=function(t){return 32===new c(t).getLength()&&jt.test(t)};
//# sourceMappingURL=sui.js.cjs.production.min.js.map

@@ -1,3 +0,4 @@

import { GetObjectDataResponse } from './objects';
import { GetObjectDataResponse, SuiMoveObject, SuiObjectInfo } from './objects';
import BN from 'bn.js';
declare type ObjectData = GetObjectDataResponse | SuiMoveObject | SuiObjectInfo;
/**

@@ -8,5 +9,10 @@ * Utility class for 0x2::coin

export declare class Coin {
static isCoin(data: GetObjectDataResponse): boolean;
static getBalance(data: GetObjectDataResponse): BN | undefined;
static isCoin(data: ObjectData): boolean;
static getCoinTypeArg(obj: ObjectData): string | null;
static isSUI(obj: ObjectData): boolean;
static getCoinSymbol(coinTypeArg: string): string;
static getBalance(data: GetObjectDataResponse | SuiMoveObject): BN | undefined;
static getZero(): BN;
private static getType;
}
export {};
export * from './common';
export * from './objects';
export * from './events';
export * from './transactions';
export * from './framework';

@@ -32,2 +32,61 @@ import { ObjectOwner } from './common';

};
export declare type SuiMoveFunctionArgTypesResponse = SuiMoveFunctionArgType[];
export declare type SuiMoveFunctionArgType = string | {
Object: string;
};
export declare type SuiMoveFunctionArgTypes = SuiMoveFunctionArgType[];
export declare type SuiMoveNormalizedModules = Record<string, SuiMoveNormalizedModule>;
export declare type SuiMoveNormalizedModule = {
file_format_version: number;
address: string;
name: string;
friends: SuiMoveModuleId[];
structs: Record<string, SuiMoveNormalizedStruct>;
exposed_functions: Record<string, SuiMoveNormalizedFunction>;
};
export declare type SuiMoveModuleId = {
address: string;
name: string;
};
export declare type SuiMoveNormalizedStruct = {
abilities: SuiMoveAbilitySet;
type_parameters: SuiMoveStructTypeParameter[];
fields: SuiMoveNormalizedField[];
};
export declare type SuiMoveStructTypeParameter = {
constraints: SuiMoveAbilitySet;
is_phantom: boolean;
};
export declare type SuiMoveNormalizedField = {
name: string;
type_: SuiMoveNormalizedType;
};
export declare type SuiMoveNormalizedFunction = {
visibility: SuiMoveVisibility;
is_entry: boolean;
type_parameters: SuiMoveAbilitySet[];
parameters: SuiMoveNormalizedType[];
return_: SuiMoveNormalizedType[];
};
export declare type SuiMoveVisibility = "Private" | "Public" | "Friend";
export declare type SuiMoveTypeParameterIndex = number;
export declare type SuiMoveAbilitySet = {
abilities: string[];
};
export declare type SuiMoveNormalizedType = (string | {
TypeParameter: SuiMoveTypeParameterIndex;
} | {
Reference: SuiMoveNormalizedType;
} | {
MutableReference: SuiMoveNormalizedType;
} | {
Vector: SuiMoveNormalizedType;
} | {
Struct: {
address: string;
module: string;
name: string;
type_arguments: SuiMoveNormalizedType[];
};
});
export declare type SuiObject = {

@@ -68,5 +127,5 @@ /** The meat of the object */

export declare function getMoveObjectType(resp: GetObjectDataResponse): string | undefined;
export declare function getObjectFields(resp: GetObjectDataResponse): ObjectContentFields | undefined;
export declare function getObjectFields(resp: GetObjectDataResponse | SuiMoveObject): ObjectContentFields | undefined;
export declare function getMoveObject(data: GetObjectDataResponse | SuiObject): SuiMoveObject | undefined;
export declare function hasPublicTransfer(data: GetObjectDataResponse | SuiObject): boolean;
export declare function getMovePackageContent(data: GetObjectDataResponse | SuiMovePackage): MovePackageContent | undefined;

@@ -91,6 +91,7 @@ import { ObjectOwner, SuiAddress, TransactionDigest } from './common';

};
export declare type TransactionEffectsResponse = {
export declare type SuiTransactionResponse = {
certificate: CertifiedTransaction;
effects: TransactionEffects;
timestamp_ms: number | null;
parsed_data: SuiParsedTransactionResponse | null;
};

@@ -114,9 +115,7 @@ export declare type GatewayTxSeqNumber = number;

};
export declare type MergeCoinResponse = {
certificate: CertifiedTransaction;
export declare type SuiParsedMergeCoinResponse = {
updatedCoin: SuiObject;
updatedGas: SuiObject;
};
export declare type SplitCoinResponse = {
certificate: CertifiedTransaction;
export declare type SuiParsedSplitCoinResponse = {
updatedCoin: SuiObject;

@@ -126,4 +125,3 @@ newCoins: SuiObject[];

};
export declare type PublishResponse = {
certificate: CertifiedTransaction;
export declare type SuiParsedPublishResponse = {
createdObjects: SuiObject[];

@@ -138,10 +136,8 @@ package: SuiPackage;

};
export declare type TransactionResponse = {
EffectResponse: TransactionEffectsResponse;
export declare type SuiParsedTransactionResponse = {
SplitCoin: SuiParsedSplitCoinResponse;
} | {
SplitCoinResponse: SplitCoinResponse;
MergeCoin: SuiParsedMergeCoinResponse;
} | {
MergeCoinResponse: MergeCoinResponse;
} | {
PublishResponse: PublishResponse;
Publish: SuiParsedPublishResponse;
};

@@ -162,11 +158,10 @@ export declare function getTransactionDigest(tx: CertifiedTransaction): TransactionDigest;

export declare function getTransactionKindName(data: SuiTransactionKind): TransactionKindName;
export declare function getExecutionStatusType(data: TransactionEffectsResponse): ExecutionStatusType;
export declare function getExecutionStatus(data: TransactionEffectsResponse): ExecutionStatus;
export declare function getExecutionStatusError(data: TransactionEffectsResponse): string | undefined;
export declare function getExecutionStatusGasSummary(data: TransactionEffectsResponse): GasCostSummary;
export declare function getTotalGasUsed(data: TransactionEffectsResponse): number;
export declare function getTransactionEffectsResponse(data: TransactionResponse): TransactionEffectsResponse | undefined;
export declare function getSplitCoinResponse(data: TransactionResponse): SplitCoinResponse | undefined;
export declare function getMergeCoinResponse(data: TransactionResponse): MergeCoinResponse | undefined;
export declare function getPublishResponse(data: TransactionResponse): PublishResponse | undefined;
export declare function getExecutionStatusType(data: SuiTransactionResponse): ExecutionStatusType;
export declare function getExecutionStatus(data: SuiTransactionResponse): ExecutionStatus;
export declare function getExecutionStatusError(data: SuiTransactionResponse): string | undefined;
export declare function getExecutionStatusGasSummary(data: SuiTransactionResponse): GasCostSummary;
export declare function getTotalGasUsed(data: SuiTransactionResponse): number;
export declare function getParsedSplitCoinResponse(data: SuiTransactionResponse): SuiParsedSplitCoinResponse | undefined;
export declare function getParsedMergeCoinResponse(data: SuiTransactionResponse): SuiParsedMergeCoinResponse | undefined;
export declare function getParsedPublishResponse(data: SuiTransactionResponse): SuiParsedPublishResponse | undefined;
/**

@@ -177,3 +172,3 @@ * Get the updated coin after a merge.

*/
export declare function getCoinAfterMerge(data: TransactionResponse): SuiObject | undefined;
export declare function getCoinAfterMerge(data: SuiTransactionResponse): SuiObject | undefined;
/**

@@ -184,3 +179,3 @@ * Get the updated coin after a split.

*/
export declare function getCoinAfterSplit(data: TransactionResponse): SuiObject | undefined;
export declare function getCoinAfterSplit(data: SuiTransactionResponse): SuiObject | undefined;
/**

@@ -191,2 +186,2 @@ * Get the newly created coin after a split.

*/
export declare function getNewlyCreatedCoinsAfterSplit(data: TransactionResponse): SuiObject[] | undefined;
export declare function getNewlyCreatedCoinsAfterSplit(data: SuiTransactionResponse): SuiObject[] | undefined;
{
"version": "0.9.0",
"version": "0.10.0",
"license": "Apache-2.0",

@@ -57,2 +57,3 @@ "main": "dist/index.js",

"@types/bn.js": "^5.1.0",
"@types/lossless-json": "^1.0.1",
"@types/mocha": "^9.1.0",

@@ -75,4 +76,3 @@ "husky": "^7.0.4",

"lossless-json": "^1.0.5",
"tweetnacl": "^1.0.3",
"util": "^0.12.4"
"tweetnacl": "^1.0.3"
},

@@ -79,0 +79,0 @@ "resolutions": {

@@ -8,3 +8,2 @@ // Copyright (c) 2022, Mysten Labs, Inc.

import { PublicKey } from './publickey';
import { TextEncoder } from 'util';

@@ -11,0 +10,0 @@ /**

@@ -28,3 +28,11 @@ // Copyright (c) 2022, Mysten Labs, Inc.

export const PUBLIC_KEY_SIZE = 32;
export const TYPE_BYTE = 0x00;
export type SignatureScheme = 'ED25519' | 'Secp256k1';
const SIGNATURE_SCHEME_TO_FLAG = {
ED25519: 0x00,
Secp256k1: 0x01,
};
function isPublicKeyData(value: PublicKeyInitData): value is PublicKeyData {

@@ -111,4 +119,7 @@ return (value as PublicKeyData)._bn !== undefined;

*/
toSuiAddress(): string {
const hexHash = sha3_256(this.toBytes());
toSuiAddress(scheme: SignatureScheme = 'ED25519'): string {
let tmp = new Uint8Array(PUBLIC_KEY_SIZE + 1);
tmp.set([SIGNATURE_SCHEME_TO_FLAG[scheme]]);
tmp.set(this.toBytes(), 1);
const hexHash = sha3_256(tmp);
const publicKeyBytes = new BN(hexHash, 16).toArray(undefined, 32);

@@ -115,0 +126,0 @@ // Only take the first 20 bytes

@@ -8,3 +8,3 @@ // Copyright (c) 2022, Mysten Labs, Inc.

*/
import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, TransferObjectTransaction, TransferSuiTransaction, MergeCoinTransaction, SplitCoinTransaction, MoveCallTransaction, PublishTransaction, TxnDataSerializer, SignaturePubkeyPair, Signer, TransactionDigest, SuiAddress, ObjectOwner, SuiObjectRef, SuiObjectInfo, ObjectContentFields, MovePackageContent, SuiData, SuiMoveObject, SuiMovePackage, SuiObject, ObjectStatus, ObjectType, GetOwnedObjectsResponse, GetObjectDataResponse, ObjectDigest, ObjectId, SequenceNumber, TransferObject, SuiTransferSui, SuiChangeEpoch, TransactionKindName, SuiTransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, OwnedObjectRef, TransactionEffects, TransactionEffectsResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, MoveCall, SuiJsonValue, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, MergeCoinResponse, SplitCoinResponse, PublishResponse, SuiPackage, TransactionResponse } from "./index";
import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, SignatureScheme, TransferObjectTransaction, TransferSuiTransaction, MergeCoinTransaction, SplitCoinTransaction, MoveCallTransaction, PublishTransaction, TxnDataSerializer, SignaturePubkeyPair, Signer, TransactionDigest, SuiAddress, ObjectOwner, SuiObjectRef, SuiObjectInfo, ObjectContentFields, MovePackageContent, SuiData, SuiMoveObject, SuiMovePackage, SuiMoveFunctionArgTypesResponse, SuiMoveFunctionArgType, SuiMoveFunctionArgTypes, SuiMoveNormalizedModules, SuiMoveNormalizedModule, SuiMoveModuleId, SuiMoveNormalizedStruct, SuiMoveStructTypeParameter, SuiMoveNormalizedField, SuiMoveNormalizedFunction, SuiMoveVisibility, SuiMoveTypeParameterIndex, SuiMoveAbilitySet, SuiMoveNormalizedType, SuiObject, ObjectStatus, ObjectType, GetOwnedObjectsResponse, GetObjectDataResponse, ObjectDigest, ObjectId, SequenceNumber, MoveEvent, PublishEvent, TransferObjectEvent, DeleteObjectEvent, NewObjectEvent, SuiEvent, TransferObject, SuiTransferSui, SuiChangeEpoch, TransactionKindName, SuiTransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, OwnedObjectRef, TransactionEffects, SuiTransactionResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, MoveCall, SuiJsonValue, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, SuiParsedMergeCoinResponse, SuiParsedSplitCoinResponse, SuiParsedPublishResponse, SuiPackage, SuiParsedTransactionResponse } from "./index";
import { BN } from "bn.js";

@@ -37,3 +37,3 @@ import { Base64DataBuffer } from "./serialization/base64";

(isTransactionDigest(obj) as boolean ||
isSequenceNumber(obj) as boolean ||
isSuiMoveTypeParameterIndex(obj) as boolean ||
obj instanceof Buffer ||

@@ -43,3 +43,3 @@ obj instanceof Uint8Array ||

obj.every((e: any) =>
isSequenceNumber(e) as boolean
isSuiMoveTypeParameterIndex(e) as boolean
) ||

@@ -59,2 +59,9 @@ isPublicKeyData(obj) as boolean)

export function isSignatureScheme(obj: any, _argumentName?: string): obj is SignatureScheme {
return (
(obj === "ED25519" ||
obj === "Secp256k1")
)
}
export function isTransferObjectTransaction(obj: any, _argumentName?: string): obj is TransferObjectTransaction {

@@ -68,3 +75,3 @@ return (

isTransactionDigest(obj.gasPayment) as boolean) &&
isSequenceNumber(obj.gasBudget) as boolean &&
isSuiMoveTypeParameterIndex(obj.gasBudget) as boolean &&
isTransactionDigest(obj.recipient) as boolean

@@ -80,6 +87,6 @@ )

isTransactionDigest(obj.suiObjectId) as boolean &&
isSequenceNumber(obj.gasBudget) as boolean &&
isSuiMoveTypeParameterIndex(obj.gasBudget) as boolean &&
isTransactionDigest(obj.recipient) as boolean &&
(typeof obj.amount === "undefined" ||
isSequenceNumber(obj.amount) as boolean)
isSuiMoveTypeParameterIndex(obj.amount) as boolean)
)

@@ -97,3 +104,3 @@ }

isTransactionDigest(obj.gasPayment) as boolean) &&
isSequenceNumber(obj.gasBudget) as boolean
isSuiMoveTypeParameterIndex(obj.gasBudget) as boolean
)

@@ -110,7 +117,7 @@ }

obj.splitAmounts.every((e: any) =>
isSequenceNumber(e) as boolean
isSuiMoveTypeParameterIndex(e) as boolean
) &&
(typeof obj.gasPayment === "undefined" ||
isTransactionDigest(obj.gasPayment) as boolean) &&
isSequenceNumber(obj.gasBudget) as boolean
isSuiMoveTypeParameterIndex(obj.gasBudget) as boolean
)

@@ -137,3 +144,3 @@ }

isTransactionDigest(obj.gasPayment) as boolean) &&
isSequenceNumber(obj.gasBudget) as boolean
isSuiMoveTypeParameterIndex(obj.gasBudget) as boolean
)

@@ -153,3 +160,3 @@ }

isTransactionDigest(obj.gasPayment) as boolean) &&
isSequenceNumber(obj.gasBudget) as boolean
isSuiMoveTypeParameterIndex(obj.gasBudget) as boolean
)

@@ -177,2 +184,3 @@ }

typeof obj === "function") &&
isSignatureScheme(obj.signatureScheme) as boolean &&
obj.signature instanceof Base64DataBuffer &&

@@ -231,3 +239,3 @@ obj.pubKey instanceof PublicKey

isTransactionDigest(obj.objectId) as boolean &&
isSequenceNumber(obj.version) as boolean
isSuiMoveTypeParameterIndex(obj.version) as boolean
)

@@ -306,2 +314,198 @@ }

export function isSuiMoveFunctionArgTypesResponse(obj: any, _argumentName?: string): obj is SuiMoveFunctionArgTypesResponse {
return (
Array.isArray(obj) &&
obj.every((e: any) =>
isSuiMoveFunctionArgType(e) as boolean
)
)
}
export function isSuiMoveFunctionArgType(obj: any, _argumentName?: string): obj is SuiMoveFunctionArgType {
return (
(isTransactionDigest(obj) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.Object) as boolean)
)
}
export function isSuiMoveFunctionArgTypes(obj: any, _argumentName?: string): obj is SuiMoveFunctionArgTypes {
return (
Array.isArray(obj) &&
obj.every((e: any) =>
isSuiMoveFunctionArgType(e) as boolean
)
)
}
export function isSuiMoveNormalizedModules(obj: any, _argumentName?: string): obj is SuiMoveNormalizedModules {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
Object.entries<any>(obj)
.every(([key, value]) => (isSuiMoveNormalizedModule(value) as boolean &&
isTransactionDigest(key) as boolean))
)
}
export function isSuiMoveNormalizedModule(obj: any, _argumentName?: string): obj is SuiMoveNormalizedModule {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSuiMoveTypeParameterIndex(obj.file_format_version) as boolean &&
isTransactionDigest(obj.address) as boolean &&
isTransactionDigest(obj.name) as boolean &&
Array.isArray(obj.friends) &&
obj.friends.every((e: any) =>
isSuiMoveModuleId(e) as boolean
) &&
(obj.structs !== null &&
typeof obj.structs === "object" ||
typeof obj.structs === "function") &&
Object.entries<any>(obj.structs)
.every(([key, value]) => (isSuiMoveNormalizedStruct(value) as boolean &&
isTransactionDigest(key) as boolean)) &&
(obj.exposed_functions !== null &&
typeof obj.exposed_functions === "object" ||
typeof obj.exposed_functions === "function") &&
Object.entries<any>(obj.exposed_functions)
.every(([key, value]) => (isSuiMoveNormalizedFunction(value) as boolean &&
isTransactionDigest(key) as boolean))
)
}
export function isSuiMoveModuleId(obj: any, _argumentName?: string): obj is SuiMoveModuleId {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.address) as boolean &&
isTransactionDigest(obj.name) as boolean
)
}
export function isSuiMoveNormalizedStruct(obj: any, _argumentName?: string): obj is SuiMoveNormalizedStruct {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSuiMoveAbilitySet(obj.abilities) as boolean &&
Array.isArray(obj.type_parameters) &&
obj.type_parameters.every((e: any) =>
isSuiMoveStructTypeParameter(e) as boolean
) &&
Array.isArray(obj.fields) &&
obj.fields.every((e: any) =>
isSuiMoveNormalizedField(e) as boolean
)
)
}
export function isSuiMoveStructTypeParameter(obj: any, _argumentName?: string): obj is SuiMoveStructTypeParameter {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSuiMoveAbilitySet(obj.constraints) as boolean &&
typeof obj.is_phantom === "boolean"
)
}
export function isSuiMoveNormalizedField(obj: any, _argumentName?: string): obj is SuiMoveNormalizedField {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.name) as boolean &&
isSuiMoveNormalizedType(obj.type_) as boolean
)
}
export function isSuiMoveNormalizedFunction(obj: any, _argumentName?: string): obj is SuiMoveNormalizedFunction {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSuiMoveVisibility(obj.visibility) as boolean &&
typeof obj.is_entry === "boolean" &&
Array.isArray(obj.type_parameters) &&
obj.type_parameters.every((e: any) =>
isSuiMoveAbilitySet(e) as boolean
) &&
Array.isArray(obj.parameters) &&
obj.parameters.every((e: any) =>
isSuiMoveNormalizedType(e) as boolean
) &&
Array.isArray(obj.return_) &&
obj.return_.every((e: any) =>
isSuiMoveNormalizedType(e) as boolean
)
)
}
export function isSuiMoveVisibility(obj: any, _argumentName?: string): obj is SuiMoveVisibility {
return (
(obj === "Private" ||
obj === "Public" ||
obj === "Friend")
)
}
export function isSuiMoveTypeParameterIndex(obj: any, _argumentName?: string): obj is SuiMoveTypeParameterIndex {
return (
typeof obj === "number"
)
}
export function isSuiMoveAbilitySet(obj: any, _argumentName?: string): obj is SuiMoveAbilitySet {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
Array.isArray(obj.abilities) &&
obj.abilities.every((e: any) =>
isTransactionDigest(e) as boolean
)
)
}
export function isSuiMoveNormalizedType(obj: any, _argumentName?: string): obj is SuiMoveNormalizedType {
return (
(isTransactionDigest(obj) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSuiMoveTypeParameterIndex(obj.TypeParameter) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSuiMoveNormalizedType(obj.Reference) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSuiMoveNormalizedType(obj.MutableReference) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSuiMoveNormalizedType(obj.Vector) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
(obj.Struct !== null &&
typeof obj.Struct === "object" ||
typeof obj.Struct === "function") &&
isTransactionDigest(obj.Struct.address) as boolean &&
isTransactionDigest(obj.Struct.module) as boolean &&
isTransactionDigest(obj.Struct.name) as boolean &&
Array.isArray(obj.Struct.type_arguments) &&
obj.Struct.type_arguments.every((e: any) =>
isSuiMoveNormalizedType(e) as boolean
))
)
}
export function isSuiObject(obj: any, _argumentName?: string): obj is SuiObject {

@@ -315,3 +519,3 @@ return (

isTransactionDigest(obj.previousTransaction) as boolean &&
isSequenceNumber(obj.storageRebate) as boolean &&
isSuiMoveTypeParameterIndex(obj.storageRebate) as boolean &&
isSuiObjectRef(obj.reference) as boolean

@@ -375,2 +579,101 @@ )

export function isMoveEvent(obj: any, _argumentName?: string): obj is MoveEvent {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.packageId) as boolean &&
isTransactionDigest(obj.transactionModule) as boolean &&
isTransactionDigest(obj.sender) as boolean &&
isTransactionDigest(obj.type) as boolean &&
(obj.fields !== null &&
typeof obj.fields === "object" ||
typeof obj.fields === "function") &&
isTransactionDigest(obj.bcs) as boolean
)
}
export function isPublishEvent(obj: any, _argumentName?: string): obj is PublishEvent {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.sender) as boolean &&
isTransactionDigest(obj.packageId) as boolean
)
}
export function isTransferObjectEvent(obj: any, _argumentName?: string): obj is TransferObjectEvent {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.packageId) as boolean &&
isTransactionDigest(obj.transactionModule) as boolean &&
isTransactionDigest(obj.sender) as boolean &&
isObjectOwner(obj.recipient) as boolean &&
isTransactionDigest(obj.objectId) as boolean &&
isSuiMoveTypeParameterIndex(obj.version) as boolean &&
isTransactionDigest(obj.type) as boolean
)
}
export function isDeleteObjectEvent(obj: any, _argumentName?: string): obj is DeleteObjectEvent {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.packageId) as boolean &&
isTransactionDigest(obj.transactionModule) as boolean &&
isTransactionDigest(obj.sender) as boolean &&
isTransactionDigest(obj.objectId) as boolean
)
}
export function isNewObjectEvent(obj: any, _argumentName?: string): obj is NewObjectEvent {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.packageId) as boolean &&
isTransactionDigest(obj.transactionModule) as boolean &&
isTransactionDigest(obj.sender) as boolean &&
isObjectOwner(obj.recipient) as boolean &&
isTransactionDigest(obj.objectId) as boolean
)
}
export function isSuiEvent(obj: any, _argumentName?: string): obj is SuiEvent {
return (
((obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isMoveEvent(obj.moveEvent) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isPublishEvent(obj.publish) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransferObjectEvent(obj.transferObject) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isDeleteObjectEvent(obj.deleteObject) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isNewObjectEvent(obj.newObject) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
typeof obj.epochChange === "bigint" ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
typeof obj.checkpoint === "bigint")
)
}
export function isTransferObject(obj: any, _argumentName?: string): obj is TransferObject {

@@ -393,3 +696,3 @@ return (

(obj.amount === null ||
isSequenceNumber(obj.amount) as boolean)
isSuiMoveTypeParameterIndex(obj.amount) as boolean)
)

@@ -403,5 +706,5 @@ }

typeof obj === "function") &&
isSequenceNumber(obj.epoch) as boolean &&
isSequenceNumber(obj.storage_charge) as boolean &&
isSequenceNumber(obj.computation_charge) as boolean
isSuiMoveTypeParameterIndex(obj.epoch) as boolean &&
isSuiMoveTypeParameterIndex(obj.storage_charge) as boolean &&
isSuiMoveTypeParameterIndex(obj.computation_charge) as boolean
)

@@ -456,3 +759,3 @@ }

isSuiObjectRef(obj.gasPayment) as boolean &&
isSequenceNumber(obj.gasBudget) as boolean
isSuiMoveTypeParameterIndex(obj.gasBudget) as boolean
)

@@ -472,3 +775,3 @@ }

typeof obj === "function") &&
isSequenceNumber(obj.epoch) as boolean &&
isSuiMoveTypeParameterIndex(obj.epoch) as boolean &&
Array.isArray(obj.signature) &&

@@ -498,5 +801,5 @@ obj.signature.every((e: any) =>

typeof obj === "function") &&
isSequenceNumber(obj.computationCost) as boolean &&
isSequenceNumber(obj.storageCost) as boolean &&
isSequenceNumber(obj.storageRebate) as boolean
isSuiMoveTypeParameterIndex(obj.computationCost) as boolean &&
isSuiMoveTypeParameterIndex(obj.storageCost) as boolean &&
isSuiMoveTypeParameterIndex(obj.storageRebate) as boolean
)

@@ -582,3 +885,3 @@ }

export function isTransactionEffectsResponse(obj: any, _argumentName?: string): obj is TransactionEffectsResponse {
export function isSuiTransactionResponse(obj: any, _argumentName?: string): obj is SuiTransactionResponse {
return (

@@ -591,3 +894,16 @@ (obj !== null &&

(obj.timestamp_ms === null ||
isSequenceNumber(obj.timestamp_ms) as boolean)
isSuiMoveTypeParameterIndex(obj.timestamp_ms) as boolean) &&
(obj.parsed_data === null ||
(obj.parsed_data !== null &&
typeof obj.parsed_data === "object" ||
typeof obj.parsed_data === "function") &&
isSuiParsedSplitCoinResponse(obj.parsed_data.SplitCoin) as boolean ||
(obj.parsed_data !== null &&
typeof obj.parsed_data === "object" ||
typeof obj.parsed_data === "function") &&
isSuiParsedMergeCoinResponse(obj.parsed_data.MergeCoin) as boolean ||
(obj.parsed_data !== null &&
typeof obj.parsed_data === "object" ||
typeof obj.parsed_data === "function") &&
isSuiParsedPublishResponse(obj.parsed_data.Publish) as boolean)
)

@@ -607,3 +923,3 @@ }

Array.isArray(e) &&
isSequenceNumber(e[0]) as boolean &&
isSuiMoveTypeParameterIndex(e[0]) as boolean &&
isTransactionDigest(e[1]) as boolean

@@ -638,3 +954,3 @@ )

(isTransactionDigest(obj) as boolean ||
isSequenceNumber(obj) as boolean ||
isSuiMoveTypeParameterIndex(obj) as boolean ||
obj === false ||

@@ -645,3 +961,3 @@ obj === true ||

(isTransactionDigest(e) as boolean ||
isSequenceNumber(e) as boolean ||
isSuiMoveTypeParameterIndex(e) as boolean ||
e === false ||

@@ -681,3 +997,3 @@ e === true)

export function isMergeCoinResponse(obj: any, _argumentName?: string): obj is MergeCoinResponse {
export function isSuiParsedMergeCoinResponse(obj: any, _argumentName?: string): obj is SuiParsedMergeCoinResponse {
return (

@@ -687,3 +1003,2 @@ (obj !== null &&

typeof obj === "function") &&
isCertifiedTransaction(obj.certificate) as boolean &&
isSuiObject(obj.updatedCoin) as boolean &&

@@ -694,3 +1009,3 @@ isSuiObject(obj.updatedGas) as boolean

export function isSplitCoinResponse(obj: any, _argumentName?: string): obj is SplitCoinResponse {
export function isSuiParsedSplitCoinResponse(obj: any, _argumentName?: string): obj is SuiParsedSplitCoinResponse {
return (

@@ -700,3 +1015,2 @@ (obj !== null &&

typeof obj === "function") &&
isCertifiedTransaction(obj.certificate) as boolean &&
isSuiObject(obj.updatedCoin) as boolean &&

@@ -711,3 +1025,3 @@ Array.isArray(obj.newCoins) &&

export function isPublishResponse(obj: any, _argumentName?: string): obj is PublishResponse {
export function isSuiParsedPublishResponse(obj: any, _argumentName?: string): obj is SuiParsedPublishResponse {
return (

@@ -717,3 +1031,2 @@ (obj !== null &&

typeof obj === "function") &&
isCertifiedTransaction(obj.certificate) as boolean &&
Array.isArray(obj.createdObjects) &&

@@ -735,7 +1048,7 @@ obj.createdObjects.every((e: any) =>

isTransactionDigest(obj.objectId) as boolean &&
isSequenceNumber(obj.version) as boolean
isSuiMoveTypeParameterIndex(obj.version) as boolean
)
}
export function isTransactionResponse(obj: any, _argumentName?: string): obj is TransactionResponse {
export function isSuiParsedTransactionResponse(obj: any, _argumentName?: string): obj is SuiParsedTransactionResponse {
return (

@@ -745,16 +1058,12 @@ ((obj !== null &&

typeof obj === "function") &&
isTransactionEffectsResponse(obj.EffectResponse) as boolean ||
isSuiParsedSplitCoinResponse(obj.SplitCoin) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSplitCoinResponse(obj.SplitCoinResponse) as boolean ||
isSuiParsedMergeCoinResponse(obj.MergeCoin) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isMergeCoinResponse(obj.MergeCoinResponse) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isPublishResponse(obj.PublishResponse) as boolean)
isSuiParsedPublishResponse(obj.Publish) as boolean)
)
}

@@ -10,4 +10,8 @@ // Copyright (c) 2022, Mysten Labs, Inc.

isGetTxnDigestsResponse,
isTransactionEffectsResponse,
isTransactionResponse,
isSuiTransactionResponse,
isSuiMoveFunctionArgTypes,
isSuiMoveNormalizedModules,
isSuiMoveNormalizedModule,
isSuiMoveNormalizedFunction,
isSuiMoveNormalizedStruct,
} from '../index.guard';

@@ -19,8 +23,17 @@ import {

SuiObjectInfo,
SuiMoveFunctionArgTypes,
SuiMoveNormalizedModules,
SuiMoveNormalizedModule,
SuiMoveNormalizedFunction,
SuiMoveNormalizedStruct,
TransactionDigest,
TransactionEffectsResponse,
TransactionResponse,
SuiTransactionResponse,
SuiObjectRef,
getObjectReference,
Coin,
} from '../types';
import { SignatureScheme } from '../cryptography/publickey';
const isNumber = (val: any): val is number => typeof val === 'number';
const isAny = (_val: any): _val is any => true;

@@ -40,2 +53,80 @@ export class JsonRpcProvider extends Provider {

// Move info
async getMoveFunctionArgTypes(
objectId: string,
moduleName: string,
functionName: string
): Promise<SuiMoveFunctionArgTypes> {
try {
return await this.client.requestWithType(
'sui_getMoveFunctionArgTypes',
[objectId, moduleName, functionName],
isSuiMoveFunctionArgTypes
);
} catch (err) {
throw new Error(
`Error fetching Move function arg types with package object ID: ${objectId}, module name: ${moduleName}, function name: ${functionName}`
);
}
}
async getNormalizedMoveModulesByPackage(objectId: string,): Promise<SuiMoveNormalizedModules> {
try {
return await this.client.requestWithType(
'sui_getNormalizedMoveModulesByPackage',
[objectId],
isSuiMoveNormalizedModules,
);
} catch (err) {
throw new Error(`Error fetching package: ${err} for package ${objectId}`);
}
}
async getNormalizedMoveModule(
objectId: string,
moduleName: string,
): Promise<SuiMoveNormalizedModule> {
try {
return await this.client.requestWithType(
'sui_getNormalizedMoveModule',
[objectId, moduleName],
isSuiMoveNormalizedModule,
);
} catch (err) {
throw new Error(`Error fetching module: ${err} for package ${objectId}, module ${moduleName}}`);
}
}
async getNormalizedMoveFunction(
objectId: string,
moduleName: string,
functionName: string
): Promise<SuiMoveNormalizedFunction> {
try {
return await this.client.requestWithType(
'sui_getNormalizedMoveFunction',
[objectId, moduleName, functionName],
isSuiMoveNormalizedFunction,
);
} catch (err) {
throw new Error(`Error fetching function: ${err} for package ${objectId}, module ${moduleName} and function ${functionName}}`);
}
}
async getNormalizedMoveStruct(
objectId: string,
moduleName: string,
structName: string
): Promise<SuiMoveNormalizedStruct> {
try {
return await this.client.requestWithType(
'sui_getNormalizedMoveStruct',
[objectId, moduleName, structName],
isSuiMoveNormalizedStruct,
);
} catch (err) {
throw new Error(`Error fetching struct: ${err} for package ${objectId}, module ${moduleName} and struct ${structName}}`);
}
}
// Objects

@@ -56,2 +147,7 @@ async getObjectsOwnedByAddress(address: string): Promise<SuiObjectInfo[]> {

async getGasObjectsOwnedByAddress(address: string): Promise<SuiObjectInfo[]> {
const objects = await this.getObjectsOwnedByAddress(address);
return objects.filter((obj: SuiObjectInfo) => Coin.isSUI(obj));
}
async getObjectsOwnedByObject(objectId: string): Promise<SuiObjectInfo[]> {

@@ -83,2 +179,7 @@ try {

async getObjectRef(objectId: string): Promise<SuiObjectRef | undefined> {
const resp = await this.getObject(objectId);
return getObjectReference(resp);
}
async getObjectBatch(objectIds: string[]): Promise<GetObjectDataResponse[]> {

@@ -157,3 +258,3 @@ const requests = objectIds.map(id => ({

digest: TransactionDigest
): Promise<TransactionEffectsResponse> {
): Promise<SuiTransactionResponse> {
try {

@@ -163,3 +264,3 @@ const resp = await this.client.requestWithType(

[digest],
isTransactionEffectsResponse
isSuiTransactionResponse
);

@@ -176,3 +277,3 @@ return resp;

digests: TransactionDigest[]
): Promise<TransactionEffectsResponse[]> {
): Promise<SuiTransactionResponse[]> {
const requests = digests.map(d => ({

@@ -185,3 +286,3 @@ method: 'sui_getTransaction',

requests,
isTransactionEffectsResponse
isSuiTransactionResponse
);

@@ -198,10 +299,11 @@ } catch (err) {

txnBytes: string,
signatureScheme: SignatureScheme,
signature: string,
pubkey: string
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
try {
const resp = await this.client.requestWithType(
'sui_executeTransaction',
[txnBytes, signature, pubkey],
isTransactionResponse
[txnBytes, signatureScheme, signature, pubkey],
isSuiTransactionResponse
);

@@ -257,2 +359,16 @@ return resp;

}
async syncAccountState(address: string): Promise<any> {
try {
return await this.client.requestWithType(
'sui_syncAccountState',
[address],
isAny
);
} catch (err) {
throw new Error(
`Error sync account address for address: ${address} with error: ${err}`
);
}
}
}
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { SignatureScheme } from '../cryptography/publickey';
import {

@@ -9,3 +10,9 @@ GetObjectDataResponse,

GetTxnDigestsResponse,
TransactionResponse,
SuiTransactionResponse,
SuiObjectRef,
SuiMoveFunctionArgTypes,
SuiMoveNormalizedFunction,
SuiMoveNormalizedStruct,
SuiMoveNormalizedModule,
SuiMoveNormalizedModules,
} from '../types';

@@ -25,2 +32,9 @@

/**
* Convenience method for getting all gas objects(SUI Tokens) owned by an address
*/
abstract getGasObjectsOwnedByAddress(
_address: string
): Promise<SuiObjectInfo[]>;
/**
* Get details about an object

@@ -30,2 +44,8 @@ */

/**
* Get object reference(id, tx digest, version id)
* @param objectId
*/
abstract getObjectRef(objectId: string): Promise<SuiObjectRef | undefined>;
// Transactions

@@ -57,7 +77,51 @@ /**

txnBytes: string,
signatureScheme: SignatureScheme,
signature: string,
pubkey: string
): Promise<TransactionResponse>;
): Promise<SuiTransactionResponse>;
// Move info
/**
* Get Move function argument types like read, write and full access
*/
abstract getMoveFunctionArgTypes(
objectId: string,
moduleName: string,
functionName: string
): Promise<SuiMoveFunctionArgTypes>;
/**
* Get a map from module name to
* structured representations of Move modules
*/
abstract getNormalizedMoveModulesByPackage(objectId: string,): Promise<SuiMoveNormalizedModules>;
/**
* Get a structured representation of Move module
*/
abstract getNormalizedMoveModule(
objectId: string,
moduleName: string,
): Promise<SuiMoveNormalizedModule>;
/**
* Get a structured representation of Move function
*/
abstract getNormalizedMoveFunction(
objectId: string,
moduleName: string,
functionName: string
): Promise<SuiMoveNormalizedFunction>
/**
* Get a structured representation of Move struct
*/
abstract getNormalizedMoveStruct(
objectId: string,
moduleName: string,
structName: string
): Promise<SuiMoveNormalizedStruct>;
abstract syncAccountState(address: string): Promise<any>;
// TODO: add more interface methods
}
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { SignatureScheme } from '../cryptography/publickey';
import {

@@ -11,3 +12,9 @@ CertifiedTransaction,

GetObjectDataResponse,
TransactionResponse,
SuiTransactionResponse,
SuiObjectRef,
SuiMoveFunctionArgTypes,
SuiMoveNormalizedFunction,
SuiMoveNormalizedStruct,
SuiMoveNormalizedModule,
SuiMoveNormalizedModules,
} from '../types';

@@ -19,5 +26,11 @@ import { Provider } from './provider';

async getObjectsOwnedByAddress(_address: string): Promise<SuiObjectInfo[]> {
throw this.newError('getOwnedObjects');
throw this.newError('getObjectsOwnedByAddress');
}
async getGasObjectsOwnedByAddress(
_address: string
): Promise<SuiObjectInfo[]> {
throw this.newError('getGasObjectsOwnedByAddress');
}
async getObject(_objectId: string): Promise<GetObjectDataResponse> {

@@ -27,2 +40,6 @@ throw this.newError('getObject');

async getObjectRef(_objectId: string): Promise<SuiObjectRef | undefined> {
throw this.newError('getObjectRef');
}
// Transactions

@@ -37,5 +54,6 @@ async getTransaction(

_txnBytes: string,
_signatureScheme: SignatureScheme,
_signature: string,
_pubkey: string
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
throw this.newError('executeTransaction');

@@ -59,2 +77,42 @@ }

async getMoveFunctionArgTypes(
_objectId: string,
_moduleName: string,
_functionName: string
): Promise<SuiMoveFunctionArgTypes> {
throw this.newError('getMoveFunctionArgTypes');
}
async getNormalizedMoveModulesByPackage(_objectId: string,): Promise<SuiMoveNormalizedModules> {
throw this.newError('getNormalizedMoveModulesByPackage');
}
async getNormalizedMoveModule(
_objectId: string,
_moduleName: string,
): Promise<SuiMoveNormalizedModule> {
throw this.newError('getNormalizedMoveModule');
}
async getNormalizedMoveFunction(
_objectId: string,
_moduleName: string,
_functionName: string
): Promise<SuiMoveNormalizedFunction> {
throw this.newError('getNormalizedMoveFunction');
}
async getNormalizedMoveStruct(
_objectId: string,
_oduleName: string,
_structName: string
): Promise<SuiMoveNormalizedStruct> {
throw this.newError('getNormalizedMoveStruct');
}
async syncAccountState(_address: string): Promise<any> {
throw this.newError('syncAccountState');
}
private newError(operation: string): Error {

@@ -61,0 +119,0 @@ return new Error(`Please use a valid provider for ${operation}`);

@@ -7,3 +7,3 @@ // Copyright (c) 2022, Mysten Labs, Inc.

import { isErrorResponse, isValidResponse } from './client.guard';
const LosslessJSON = require('lossless-json');
import * as LosslessJSON from 'lossless-json';

@@ -51,7 +51,12 @@ /**

const result = JSON.stringify(
LosslessJSON.parse(text, (key: string, value: any) => {
LosslessJSON.parse(text, (key, value) => {
if (value == null) {
return value;
}
if (key === 'balance') return value.toString();
// TODO: This is a bad hack, we really shouldn't be doing this here:
if (key === 'balance' && typeof value === 'number') {
return value.toString();
}
try {

@@ -90,3 +95,2 @@ if (value.isLosslessNumber) return value.valueOf();

if (isT(response.result)) return response.result;
else
throw new Error(

@@ -93,0 +97,0 @@ `RPC Error: result not of expected type. Result received was: ${JSON.stringify(

@@ -30,2 +30,3 @@ // Copyright (c) 2022, Mysten Labs, Inc.

return {
signatureScheme: 'ED25519',
signature: this.keypair.signData(data),

@@ -32,0 +33,0 @@ pubKey: this.keypair.getPublicKey(),

@@ -8,3 +8,3 @@ // Copyright (c) 2022, Mysten Labs, Inc.

import { Base64DataBuffer } from '../serialization/base64';
import { SuiAddress, TransactionResponse } from '../types';
import { SuiAddress, SuiTransactionResponse } from '../types';
import { SignaturePubkeyPair, Signer } from './signer';

@@ -62,6 +62,7 @@ import { RpcTxnDataSerializer } from './txn-data-serializers/rpc-txn-data-serializer';

txBytes: Base64DataBuffer
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
const sig = await this.signData(txBytes);
return await this.provider.executeTransaction(
txBytes.toString(),
sig.signatureScheme,
sig.signature.toString(),

@@ -73,2 +74,11 @@ sig.pubKey.toString()

/**
* Trigger gateway to sync account state related to the address,
* based on the account state on validators.
*/
async syncAccountState(): Promise<any> {
const address = await this.getAddress();
return await this.provider.syncAccountState(address);
}
/**
* Serialize and Sign a `TransferObject` transaction and submit to the Gateway for execution

@@ -78,3 +88,3 @@ */

transaction: TransferObjectTransaction
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
const signerAddress = await this.getAddress();

@@ -93,3 +103,3 @@ const txBytes = await this.serializer.newTransferObject(

transaction: TransferSuiTransaction
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
const signerAddress = await this.getAddress();

@@ -108,3 +118,3 @@ const txBytes = await this.serializer.newTransferSui(

transaction: MergeCoinTransaction
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
const signerAddress = await this.getAddress();

@@ -123,3 +133,3 @@ const txBytes = await this.serializer.newMergeCoin(

transaction: SplitCoinTransaction
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
const signerAddress = await this.getAddress();

@@ -138,3 +148,3 @@ const txBytes = await this.serializer.newSplitCoin(

transaction: MoveCallTransaction
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
const signerAddress = await this.getAddress();

@@ -150,3 +160,3 @@ const txBytes = await this.serializer.newMoveCall(

transaction: PublishTransaction
): Promise<TransactionResponse> {
): Promise<SuiTransactionResponse> {
const signerAddress = await this.getAddress();

@@ -153,0 +163,0 @@ const txBytes = await this.serializer.newPublish(

// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { PublicKey } from '../cryptography/publickey';
import { PublicKey, SignatureScheme } from '../cryptography/publickey';
import { Base64DataBuffer } from '../serialization/base64';

@@ -14,2 +14,3 @@

export type SignaturePubkeyPair = {
signatureScheme: SignatureScheme;
signature: Base64DataBuffer;

@@ -16,0 +17,0 @@ pubKey: PublicKey;

// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { getObjectFields, GetObjectDataResponse } from './objects';
import {
getObjectFields,
GetObjectDataResponse,
SuiMoveObject,
SuiObjectInfo,
} from './objects';

@@ -10,2 +15,7 @@ import { getMoveObjectType } from './objects';

const COIN_TYPE = '0x2::coin::Coin';
const COIN_TYPE_ARG_REGEX = /^0x2::coin::Coin<(.+)>$/;
type ObjectData = GetObjectDataResponse | SuiMoveObject | SuiObjectInfo;
/**

@@ -16,7 +26,23 @@ * Utility class for 0x2::coin

export class Coin {
static isCoin(data: GetObjectDataResponse): boolean {
return getMoveObjectType(data)?.startsWith('0x2::coin::Coin') ?? false;
static isCoin(data: ObjectData): boolean {
return Coin.getType(data)?.startsWith(COIN_TYPE) ?? false;
}
static getBalance(data: GetObjectDataResponse): BN | undefined {
static getCoinTypeArg(obj: ObjectData) {
const res = Coin.getType(obj)?.match(COIN_TYPE_ARG_REGEX);
return res ? res[1] : null;
}
static isSUI(obj: ObjectData) {
const arg = Coin.getCoinTypeArg(obj);
return arg ? Coin.getCoinSymbol(arg) === 'SUI' : false;
}
static getCoinSymbol(coinTypeArg: string) {
return coinTypeArg.substring(coinTypeArg.lastIndexOf(':') + 1);
}
static getBalance(
data: GetObjectDataResponse | SuiMoveObject
): BN | undefined {
if (!Coin.isCoin(data)) {

@@ -32,2 +58,9 @@ return undefined;

}
private static getType(data: ObjectData): string | undefined {
if ('status' in data) {
return getMoveObjectType(data);
}
return data.type;
}
}

@@ -6,3 +6,4 @@ // Copyright (c) 2022, Mysten Labs, Inc.

export * from './objects';
export * from './events';
export * from './transactions';
export * from './framework';

@@ -44,2 +44,73 @@ // Copyright (c) 2022, Mysten Labs, Inc.

export type SuiMoveFunctionArgTypesResponse = SuiMoveFunctionArgType[];
export type SuiMoveFunctionArgType = string | { Object: string };
export type SuiMoveFunctionArgTypes = SuiMoveFunctionArgType[];
export type SuiMoveNormalizedModules = Record<string, SuiMoveNormalizedModule>;
export type SuiMoveNormalizedModule = {
file_format_version: number;
address: string;
name: string;
friends: SuiMoveModuleId[];
structs: Record<string, SuiMoveNormalizedStruct>;
exposed_functions: Record<string, SuiMoveNormalizedFunction>;
}
export type SuiMoveModuleId = {
address: string;
name: string;
};
export type SuiMoveNormalizedStruct = {
abilities: SuiMoveAbilitySet;
type_parameters: SuiMoveStructTypeParameter[];
fields: SuiMoveNormalizedField[];
}
export type SuiMoveStructTypeParameter = {
constraints: SuiMoveAbilitySet;
is_phantom: boolean;
}
export type SuiMoveNormalizedField = {
name: string;
type_: SuiMoveNormalizedType;
}
export type SuiMoveNormalizedFunction = {
visibility: SuiMoveVisibility;
is_entry: boolean;
type_parameters: SuiMoveAbilitySet[];
parameters: SuiMoveNormalizedType[];
return_: SuiMoveNormalizedType[];
};
export type SuiMoveVisibility =
| "Private"
| "Public"
| "Friend";
export type SuiMoveTypeParameterIndex = number;
export type SuiMoveAbilitySet = {
abilities: string[],
};
export type SuiMoveNormalizedType = (
| string
| {TypeParameter: SuiMoveTypeParameterIndex}
| {Reference: SuiMoveNormalizedType}
| {MutableReference: SuiMoveNormalizedType}
| {Vector: SuiMoveNormalizedType}
| {Struct: {
address: string,
module: string,
name: string,
type_arguments: SuiMoveNormalizedType[],
}}
);
export type SuiObject = {

@@ -156,4 +227,7 @@ /** The meat of the object */

export function getObjectFields(
resp: GetObjectDataResponse
resp: GetObjectDataResponse | SuiMoveObject
): ObjectContentFields | undefined {
if ('fields' in resp) {
return resp.fields;
}
return getMoveObject(resp)?.fields;

@@ -160,0 +234,0 @@ }

@@ -109,6 +109,7 @@ // Copyright (c) 2022, Mysten Labs, Inc.

export type TransactionEffectsResponse = {
export type SuiTransactionResponse = {
certificate: CertifiedTransaction;
effects: TransactionEffects;
timestamp_ms: number | null;
parsed_data: SuiParsedTransactionResponse | null;
};

@@ -144,4 +145,3 @@

export type MergeCoinResponse = {
certificate: CertifiedTransaction;
export type SuiParsedMergeCoinResponse = {
updatedCoin: SuiObject;

@@ -151,4 +151,3 @@ updatedGas: SuiObject;

export type SplitCoinResponse = {
certificate: CertifiedTransaction;
export type SuiParsedSplitCoinResponse = {
updatedCoin: SuiObject;

@@ -159,4 +158,3 @@ newCoins: SuiObject[];

export type PublishResponse = {
certificate: CertifiedTransaction;
export type SuiParsedPublishResponse = {
createdObjects: SuiObject[];

@@ -173,14 +171,11 @@ package: SuiPackage;

export type TransactionResponse =
export type SuiParsedTransactionResponse =
| {
EffectResponse: TransactionEffectsResponse;
SplitCoin: SuiParsedSplitCoinResponse;
}
| {
SplitCoinResponse: SplitCoinResponse;
MergeCoin: SuiParsedMergeCoinResponse;
}
| {
MergeCoinResponse: MergeCoinResponse;
}
| {
PublishResponse: PublishResponse;
Publish: SuiParsedPublishResponse;
};

@@ -274,3 +269,3 @@

export function getExecutionStatusType(
data: TransactionEffectsResponse
data: SuiTransactionResponse
): ExecutionStatusType {

@@ -281,3 +276,3 @@ return getExecutionStatus(data).status;

export function getExecutionStatus(
data: TransactionEffectsResponse
data: SuiTransactionResponse
): ExecutionStatus {

@@ -288,3 +283,3 @@ return data.effects.status;

export function getExecutionStatusError(
data: TransactionEffectsResponse
data: SuiTransactionResponse
): string | undefined {

@@ -295,3 +290,3 @@ return getExecutionStatus(data).error;

export function getExecutionStatusGasSummary(
data: TransactionEffectsResponse
data: SuiTransactionResponse
): GasCostSummary {

@@ -301,3 +296,3 @@ return data.effects.gasUsed;

export function getTotalGasUsed(data: TransactionEffectsResponse): number {
export function getTotalGasUsed(data: SuiTransactionResponse): number {
const gasSummary = getExecutionStatusGasSummary(data);

@@ -313,26 +308,23 @@ return (

export function getTransactionEffectsResponse(
data: TransactionResponse
): TransactionEffectsResponse | undefined {
return 'EffectResponse' in data ? data.EffectResponse : undefined;
export function getParsedSplitCoinResponse(
data: SuiTransactionResponse
): SuiParsedSplitCoinResponse | undefined {
const parsed = data.parsed_data;
return parsed && 'SplitCoin' in parsed ? parsed.SplitCoin : undefined;
}
export function getSplitCoinResponse(
data: TransactionResponse
): SplitCoinResponse | undefined {
return 'SplitCoinResponse' in data ? data.SplitCoinResponse : undefined;
export function getParsedMergeCoinResponse(
data: SuiTransactionResponse
): SuiParsedMergeCoinResponse | undefined {
const parsed = data.parsed_data;
return parsed && 'MergeCoin' in parsed ? parsed.MergeCoin : undefined;
}
export function getMergeCoinResponse(
data: TransactionResponse
): MergeCoinResponse | undefined {
return 'MergeCoinResponse' in data ? data.MergeCoinResponse : undefined;
export function getParsedPublishResponse(
data: SuiTransactionResponse
): SuiParsedPublishResponse | undefined {
const parsed = data.parsed_data;
return parsed && 'Publish' in parsed ? parsed.Publish : undefined;
}
export function getPublishResponse(
data: TransactionResponse
): PublishResponse | undefined {
return 'PublishResponse' in data ? data.PublishResponse : undefined;
}
/**

@@ -344,5 +336,5 @@ * Get the updated coin after a merge.

export function getCoinAfterMerge(
data: TransactionResponse
data: SuiTransactionResponse
): SuiObject | undefined {
return getMergeCoinResponse(data)?.updatedCoin;
return getParsedMergeCoinResponse(data)?.updatedCoin;
}

@@ -356,5 +348,5 @@

export function getCoinAfterSplit(
data: TransactionResponse
data: SuiTransactionResponse
): SuiObject | undefined {
return getSplitCoinResponse(data)?.updatedCoin;
return getParsedSplitCoinResponse(data)?.updatedCoin;
}

@@ -368,5 +360,5 @@

export function getNewlyCreatedCoinsAfterSplit(
data: TransactionResponse
data: SuiTransactionResponse
): SuiObject[] | undefined {
return getSplitCoinResponse(data)?.newCoins;
return getParsedSplitCoinResponse(data)?.newCoins;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc