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

@mysten/sui.js

Package Overview
Dependencies
Maintainers
1
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.1.2 to 0.2.0

dist/types/framework.d.ts

25

dist/index.guard.d.ts

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

import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, TransferCoinTransaction, TxnDataSerializer, TransactionDigest, SuiAddress, ObjectOwner, ObjectRef, ObjectContentField, ObjectContentFields, ObjectContent, MovePackageContent, SuiObject, ObjectExistsInfo, ObjectNotExistsInfo, ObjectStatus, ObjectType, GetOwnedObjectRefsResponse, GetObjectInfoResponse, ObjectDigest, ObjectId, SequenceNumber, RawObjectRef, Transfer, RawAuthoritySignInfo, TransactionKindName, SingleTransactionKind, TransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, ExecutionStatusDetail, OwnedObjectRef, TransactionEffects, TransactionEffectsResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, MoveModulePublish, Event, StructTag, MoveTypeTag, MoveCall, MoveCallArg, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, TransactionResponse, SignedTransaction } from "./index";
import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, TransferCoinTransaction, TxnDataSerializer, TransactionDigest, SuiAddress, ObjectOwner, SuiObjectRef, ObjectContentFields, MovePackageContent, SuiData, SuiMoveObject, SuiMovePackage, SuiObject, ObjectStatus, ObjectType, GetOwnedObjectRefsResponse, GetObjectInfoResponse, ObjectDigest, ObjectId, SequenceNumber, TransferCoin, RawAuthoritySignInfo, TransactionKindName, SuiTransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, OwnedObjectRef, TransactionEffects, TransactionEffectsResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, Event, MoveCall, SuiJsonValue, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, SplitCoinResponse, TransactionResponse } from "./index";
export declare function isEd25519KeypairData(obj: any, _argumentName?: string): obj is Ed25519KeypairData;

@@ -11,10 +11,9 @@ export declare function isKeypair(obj: any, _argumentName?: string): obj is Keypair;

export declare function isObjectOwner(obj: any, _argumentName?: string): obj is ObjectOwner;
export declare function isObjectRef(obj: any, _argumentName?: string): obj is ObjectRef;
export declare function isObjectContentField(obj: any, _argumentName?: string): obj is ObjectContentField;
export declare function isSuiObjectRef(obj: any, _argumentName?: string): obj is SuiObjectRef;
export declare function isObjectContentFields(obj: any, _argumentName?: string): obj is ObjectContentFields;
export declare function isObjectContent(obj: any, _argumentName?: string): obj is ObjectContent;
export declare function isMovePackageContent(obj: any, _argumentName?: string): obj is MovePackageContent;
export declare function isSuiData(obj: any, _argumentName?: string): obj is SuiData;
export declare function isSuiMoveObject(obj: any, _argumentName?: string): obj is SuiMoveObject;
export declare function isSuiMovePackage(obj: any, _argumentName?: string): obj is SuiMovePackage;
export declare function isSuiObject(obj: any, _argumentName?: string): obj is SuiObject;
export declare function isObjectExistsInfo(obj: any, _argumentName?: string): obj is ObjectExistsInfo;
export declare function isObjectNotExistsInfo(obj: any, _argumentName?: string): obj is ObjectNotExistsInfo;
export declare function isObjectStatus(obj: any, _argumentName?: string): obj is ObjectStatus;

@@ -27,8 +26,6 @@ export declare function isObjectType(obj: any, _argumentName?: string): obj is ObjectType;

export declare function isSequenceNumber(obj: any, _argumentName?: string): obj is SequenceNumber;
export declare function isRawObjectRef(obj: any, _argumentName?: string): obj is RawObjectRef;
export declare function isTransfer(obj: any, _argumentName?: string): obj is Transfer;
export declare function isTransferCoin(obj: any, _argumentName?: string): obj is TransferCoin;
export declare function isRawAuthoritySignInfo(obj: any, _argumentName?: string): obj is RawAuthoritySignInfo;
export declare function isTransactionKindName(obj: any, _argumentName?: string): obj is TransactionKindName;
export declare function isSingleTransactionKind(obj: any, _argumentName?: string): obj is SingleTransactionKind;
export declare function isTransactionKind(obj: any, _argumentName?: string): obj is TransactionKind;
export declare function isSuiTransactionKind(obj: any, _argumentName?: string): obj is SuiTransactionKind;
export declare function isTransactionData(obj: any, _argumentName?: string): obj is TransactionData;

@@ -41,3 +38,2 @@ export declare function isEpochId(obj: any, _argumentName?: string): obj is EpochId;

export declare function isExecutionStatus(obj: any, _argumentName?: string): obj is ExecutionStatus;
export declare function isExecutionStatusDetail(obj: any, _argumentName?: string): obj is ExecutionStatusDetail;
export declare function isOwnedObjectRef(obj: any, _argumentName?: string): obj is OwnedObjectRef;

@@ -48,8 +44,5 @@ export declare function isTransactionEffects(obj: any, _argumentName?: string): obj is TransactionEffects;

export declare function isGetTxnDigestsResponse(obj: any, _argumentName?: string): obj is GetTxnDigestsResponse;
export declare function isMoveModulePublish(obj: any, _argumentName?: string): obj is MoveModulePublish;
export declare function isEvent(obj: any, _argumentName?: string): obj is Event;
export declare function isStructTag(obj: any, _argumentName?: string): obj is StructTag;
export declare function isMoveTypeTag(obj: any, _argumentName?: string): obj is MoveTypeTag;
export declare function isMoveCall(obj: any, _argumentName?: string): obj is MoveCall;
export declare function isMoveCallArg(obj: any, _argumentName?: string): obj is MoveCallArg;
export declare function isSuiJsonValue(obj: any, _argumentName?: string): obj is SuiJsonValue;
export declare function isEmptySignInfo(obj: any, _argumentName?: string): obj is EmptySignInfo;

@@ -59,3 +52,3 @@ export declare function isAuthorityName(obj: any, _argumentName?: string): obj is AuthorityName;

export declare function isTransactionBytes(obj: any, _argumentName?: string): obj is TransactionBytes;
export declare function isSplitCoinResponse(obj: any, _argumentName?: string): obj is SplitCoinResponse;
export declare function isTransactionResponse(obj: any, _argumentName?: string): obj is TransactionResponse;
export declare function isSignedTransaction(obj: any, _argumentName?: string): obj is SignedTransaction;
import { Provider } from './provider';
import { CertifiedTransaction, GatewayTxSeqNumber, GetTxnDigestsResponse, GetObjectInfoResponse, ObjectRef, TransactionDigest, TransactionEffectsResponse, SignedTransaction, TransactionResponse } from '../types';
import { GatewayTxSeqNumber, GetTxnDigestsResponse, GetObjectInfoResponse, SuiObjectRef, TransactionDigest, TransactionEffectsResponse, TransactionResponse } from '../types';
export declare class JsonRpcProvider extends Provider {

@@ -12,3 +12,3 @@ endpoint: string;

constructor(endpoint: string);
getOwnedObjectRefs(address: string): Promise<ObjectRef[]>;
getOwnedObjectRefs(address: string): Promise<SuiObjectRef[]>;
getObjectInfo(objectId: string): Promise<GetObjectInfoResponse>;

@@ -18,4 +18,3 @@ getObjectInfoBatch(objectIds: string[]): Promise<GetObjectInfoResponse[]>;

getTransactionWithEffectsBatch(digests: TransactionDigest[]): Promise<TransactionEffectsResponse[]>;
getTransaction(digest: TransactionDigest): Promise<CertifiedTransaction>;
executeTransaction(txn: SignedTransaction): Promise<TransactionResponse>;
executeTransaction(txnBytes: string, signature: string, pubkey: string): Promise<TransactionResponse>;
getTotalTransactionNumber(): Promise<number>;

@@ -22,0 +21,0 @@ getTransactionDigestsInRange(start: GatewayTxSeqNumber, end: GatewayTxSeqNumber): Promise<GetTxnDigestsResponse>;

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

import { GetObjectInfoResponse, ObjectRef, GatewayTxSeqNumber, GetTxnDigestsResponse, TransactionResponse, SignedTransaction } from '../types';
import { GetObjectInfoResponse, SuiObjectRef, GatewayTxSeqNumber, GetTxnDigestsResponse, TransactionResponse } from '../types';
export declare abstract class Provider {

@@ -6,3 +6,3 @@ /**

*/
abstract getOwnedObjectRefs(address: string): Promise<ObjectRef[]>;
abstract getOwnedObjectRefs(address: string): Promise<SuiObjectRef[]>;
/**

@@ -29,3 +29,3 @@ * Get information about an object

abstract getTotalTransactionNumber(): Promise<number>;
abstract executeTransaction(txn: SignedTransaction): Promise<TransactionResponse>;
abstract executeTransaction(txnBytes: string, signature: string, pubkey: string): Promise<TransactionResponse>;
}

@@ -1,8 +0,8 @@

import { CertifiedTransaction, TransactionDigest, GetTxnDigestsResponse, GatewayTxSeqNumber, ObjectRef, GetObjectInfoResponse, SignedTransaction, TransactionResponse } from '../types';
import { CertifiedTransaction, TransactionDigest, GetTxnDigestsResponse, GatewayTxSeqNumber, SuiObjectRef, GetObjectInfoResponse, TransactionResponse } from '../types';
import { Provider } from './provider';
export declare class VoidProvider extends Provider {
getOwnedObjectRefs(_address: string): Promise<ObjectRef[]>;
getOwnedObjectRefs(_address: string): Promise<SuiObjectRef[]>;
getObjectInfo(_objectId: string): Promise<GetObjectInfoResponse>;
getTransaction(_digest: TransactionDigest): Promise<CertifiedTransaction>;
executeTransaction(_txn: SignedTransaction): Promise<TransactionResponse>;
executeTransaction(_txnBytes: string, _signature: string, _pubkey: string): Promise<TransactionResponse>;
getTotalTransactionNumber(): Promise<number>;

@@ -9,0 +9,0 @@ getTransactionDigestsInRange(_start: GatewayTxSeqNumber, _end: GatewayTxSeqNumber): Promise<GetTxnDigestsResponse>;

@@ -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"),u=require("util"),c=t(require("jayson/lib/client/browser")),a=t(require("cross-fetch")),s=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 u.TextEncoder).encode("sui validation"),c=e.sign.detached(i,o.secretKey);if(!e.sign.detached.verify(i,c,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 s(e.sign.detached(t.getData(),this.keypair.secretKey))},t}(),h=function(){};function y(t,e,r,n,o,i,u){try{var c=t[i](u),a=c.value}catch(t){return void r(t)}c.done?e(a):Promise.resolve(a).then(n,o)}function l(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){y(i,n,o,u,c,"next",t)}function c(t){y(i,n,o,u,c,"throw",t)}u(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)}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function g(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return v(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var w,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 c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=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 c=x(u,r);if(c){if(c===f)continue;return c}}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=s(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 s(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 h(){}function y(){}var l={};c(l,o,(function(){return this}));var d=Object.getPrototypeOf,v=d&&d(d(E([])));v&&v!==e&&r.call(v,o)&&(l=v);var g=y.prototype=p.prototype=Object.create(l);function w(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(o,i){function u(){return new e((function(n,u){!function n(o,i,u,c){var a=s(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,c)}),(function(t){n("throw",t,u,c)})):e.resolve(p).then((function(t){f.value=t,u(f)}),(function(t){return n("throw",t,u,c)}))}c(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=s(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:S}}function S(){return{value:void 0,done:!0}}return h.prototype=y,c(g,"constructor",y),c(y,"constructor",h),h.displayName=c(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,c(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},w(b.prototype),c(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var u=new b(a(e,r,n,o),i);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},w(g),c(g,u,"Generator"),c(g,o,(function(){return this})),c(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=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 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 c=r.call(i,"catchLoc"),a=r.call(i,"finallyLoc");if(c&&a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){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: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)}}(w={exports:{}}),w.exports);function x(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&t._bn instanceof n.BN}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)||"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 E(t,e){return m(t)||L(t)||!1===t||!0===t||Array.isArray(t)&&t.every((function(t){return L(t)}))||_(t)||Array.isArray(t)&&t.every((function(t){return _(t)}))}function S(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Object.entries(t).every((function(t){var e=t[0];return E(t[1])&&m(e)}))}function _(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&S(t.fields)&&m(t.type)}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)&&(_(t.contents)||A(t.contents))&&j(t.owner)&&m(t.tx_digest)}function k(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&T(t.objectRef)&&R(t.objectType)&&O(t.object)}function B(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.objectId)}function P(t,e){return"Exists"===t||"NotExists"===t||"Deleted"===t}function R(t,e){return"moveObject"===t||"movePackage"===t}function I(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.objects)&&t.objects.every((function(t){return T(t)}))}function C(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&P(t.status)&&(T(t.details)||k(t.details)||B(t.details))}function L(t,e){return"number"==typeof t}function U(t,e){return Array.isArray(t)&&m(t[0])&&L(t[1])&&m(t[2])}function N(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.recipient)&&U(t.object_ref)}function D(t,e){return Array.isArray(t)&&m(t[0])&&m(t[1])}function q(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&N(t.Transfer)||(null!==t&&"object"==typeof t||"function"==typeof t)&&Q(t.Publish)||(null!==t&&"object"==typeof t||"function"==typeof t)&&et(t.Call)}function V(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&q(t.Single)||(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.Batch)&&t.Batch.every((function(t){return q(t)}))}function K(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&V(t.kind)&&m(t.sender)&&U(t.gas_payment)&&L(t.gas_budget)}function F(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&L(t.epoch)&&Array.isArray(t.signatures)&&t.signatures.every((function(t){return D(t)}))}function W(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&K(t.data)&&m(t.tx_signature)&&F(t.auth_sign_info)}function G(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&L(t.computation_cost)&&L(t.storage_cost)&&L(t.storage_rebate)}function M(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&z(t.Success)||(null!==t&&"object"==typeof t||"function"==typeof t)&&z(t.Failure)}function z(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&G(t.gas_cost)}function J(t,e){return Array.isArray(t)&&U(t[0])&&j(t[1])}function Y(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&M(t.status)&&Array.isArray(t.shared_objects)&&t.shared_objects.every((function(t){return U(t)}))&&m(t.transaction_digest)&&Array.isArray(t.created)&&t.created.every((function(t){return J(t)}))&&Array.isArray(t.mutated)&&t.mutated.every((function(t){return J(t)}))&&Array.isArray(t.unwrapped)&&t.unwrapped.every((function(t){return J(t)}))&&Array.isArray(t.deleted)&&t.deleted.every((function(t){return U(t)}))&&Array.isArray(t.wrapped)&&t.wrapped.every((function(t){return U(t)}))&&J(t.gas_object)&&Array.isArray(t.events)&&t.events.every((function(t){return Z(t)}))&&Array.isArray(t.dependencies)&&t.dependencies.every((function(t){return m(t)}))}function $(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&W(t.certificate)&&Y(t.effects)}function H(t,e){return Array.isArray(t)&&t.every((function(t){return Array.isArray(t)&&L(t[0])&&m(t[1])}))}function Q(t,e){return null!==t&&"object"==typeof t||"function"==typeof t}function Z(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&X(t.type_)&&m(t.contents)}function X(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.address)&&m(t.module)&&m(t.name)&&Array.isArray(t.type_args)&&t.type_args.every((function(t){return tt(t)}))}function tt(t,e){return"bool"===t||"u8"===t||"u64"===t||"u128"===t||"address"===t||"signer"===t||(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.vector)&&t.vector.every((function(t){return tt(t)}))||(null!==t&&"object"==typeof t||"function"==typeof t)&&X(t.struct)}function et(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&U(t.package)&&m(t.module)&&m(t.function)&&Array.isArray(t.type_arguments)&&t.type_arguments.every((function(t){return tt(t)}))&&Array.isArray(t.arguments)&&t.arguments.every((function(t){return rt(t)}))}function rt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.Pure)&&t.Pure.every((function(t){return L(t)}))||(null!==t&&"object"==typeof t||"function"==typeof t)&&U(t.ImmOrOwnedObject)||(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.SharedObject)}function nt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.tx_bytes)}function ot(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&$(t.EffectResponse)}function it(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"2.0"===t.jsonrpc&&m(t.id)}var ut=function(){function t(t,e){this.rpcClient=this.createRpcClient(t,e)}var e=t.prototype;return e.createRpcClient=function(t,e){return new c(function(){var r=l(b.mark((function r(n,o){var i,u,c;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,a(t,i);case 4:return u=r.sent,r.next=7,u.text();case 7:c=r.sent,u.ok?o(null,c):o(new Error(u.status+" "+u.statusText+": "+c)),r.next=14;break;case 11:r.prev=11,r.t0=r.catch(1),r.t0 instanceof Error&&o(r.t0);case 14:case"end":return r.stop()}}),r,null,[[1,11]])})));return function(t,e){return r.apply(this,arguments)}}(),{})},e.requestWithType=function(){var t=l(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(!it(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=l(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=l(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 it(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=l(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}();function ct(t){return"Exists"!==t.status?void 0:t.details}function at(t){var e=ct(t);if(null!=e)return"moveObject"===e.objectType?e.object.contents:void 0}function st(t){var e=at(t);return null!=e&&(t.details.object.contents=function t(e){var r={};return Object.entries(e.fields).forEach((function(e){var n=e[0],o=e[1];if(_(o)){for(var i=!1,u=0,c=[yt,pt,ht];u<c.length;u++){var a=c[u];if(a.canTransform(o)){r[n]=a.toFieldValue(o),i=!0;break}}i||(r[n]=t(o))}else r[n]=o})),{fields:r,type:e.type}}(e)),t}var ft=function(){function t(){}return t.toFieldValue=function(t){throw new Error("Children classes must override")},t.canTransform=function(t){throw new Error("Children classes must override")},t}(),pt=function(t){function e(){return t.apply(this,arguments)||this}return d(e,t),e.toFieldValue=function(t){var e=t.fields.bytes;switch(t.type){case"0x1::ASCII::String":return e.map((function(t){return String.fromCharCode(t)})).join("");case"0x2::UTF8::String":return function(t){for(var e=[1,1,1,1,2,2,3,0],r=t.length,n="",o=0;o<r;){var i=t[o++];if(128&i){var u=e[i>>3&7];if(!(64&i)||!u||o+u>r)return null;for(i&=63>>u;u>0;u-=1){var c=t[o++];if(128!=(192&c))return null;i=i<<6|63&c}}n+=String.fromCharCode(i)}return n}(new Uint8Array(e))}return t},e.canTransform=function(t){return"0x2::UTF8::String"===t.type||"0x1::ASCII::String"===t.type},e}(ft),ht=function(t){function e(){return t.apply(this,arguments)||this}return d(e,t),e.toFieldValue=function(t){return e.canTransform(t)?t.fields.id.fields.bytes:t},e.canTransform=function(t){return"0x2::ID::UniqueID"===t.type&&_(t.fields.id)&&"0x2::ID::ID"===t.fields.id.type},e}(ft),yt=function(t){function e(){return t.apply(this,arguments)||this}return d(e,t),e.toFieldValue=function(t){return e.canTransform(t)?t.fields.value:t},e.canTransform=function(t){return t.type.startsWith("0x2::Balance::Balance")},e}(ft),lt=function(t){return"number"==typeof t},dt=function(t){function e(e){var r;return(r=t.call(this)||this).endpoint=e,r.client=new ut(e),r}d(e,t);var r=e.prototype;return r.getOwnedObjectRefs=function(){var t=l(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_getOwnedObjects",[e],I);case 3:return t.abrupt("return",t.sent.objects);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error fetching owned object refs: "+t.t0+" for address "+e);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),r.getObjectInfo=function(){var t=l(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_getObjectTypedInfo",[e],C);case 3:return t.abrupt("return",st(t.sent));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error fetching object info: "+t.t0+" for id "+e);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),r.getObjectInfoBatch=function(){var t=l(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_getObjectTypedInfo",args:[t]}})),t.prev=1,t.next=4,this.client.batchRequestWithType(r,C);case 4:return t.abrupt("return",t.sent.map((function(t){return st(t)})));case 8:throw t.prev=8,t.t0=t.catch(1),new Error("Error fetching object info: "+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=l(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],$);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=l(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,$);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.getTransaction=function(){var t=l(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],$);case 3:return t.abrupt("return",t.sent.certificate);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error getting transaction: "+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.executeTransaction=function(){var t=l(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_executeTransaction",[e],ot);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+" for txn "+JSON.stringify(e));case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),r.getTotalTransactionNumber=function(){var t=l(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",[],lt);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=l(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],H);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=l(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],H);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}(h),vt=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}(),gt=function(){function t(t){this.client=new ut(t)}return t.prototype.newTransferCoin=function(){var t=l(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_transferCoin",[e.signer,e.objectId,e.gasPayment,e.gasBudget,e.recipient],nt);case 3:return t.abrupt("return",new s(t.sent.tx_bytes));case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error transferring coin: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),t}(),wt=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var r=e.prototype;return r.getOwnedObjectRefs=function(){var t=l(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getOwnedObjectRefs");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getObjectInfo=function(){var t=l(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getObjectInfo");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getTransaction=function(){var t=l(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=l(b.mark((function t(e){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){return t.apply(this,arguments)}}(),r.getTotalTransactionNumber=function(){var t=l(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=l(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=l(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.newError=function(t){return new Error("Please use a valid provider for "+t)},e}(h),bt=function(){function t(t,e){this.provider=t||new wt;var r="";this.provider instanceof dt&&(r=this.provider.endpoint),this.serializer=e||new gt(r)}var e=t.prototype;return e.signAndExecuteTransaction=function(){var t=l(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({tx_bytes:e.toString(),signature:r.signature.toString(),pub_key: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.transferCoin=function(){var t=l(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.serializer.newTransferCoin(e);case 2:return r=t.sent,t.next=5,this.signAndExecuteTransaction(r);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)}}(),t}(),xt=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=l(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw 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=l(b.mark((function t(e){return b.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}(bt);function mt(t){return"Single"in t.kind?t.kind.Single:void 0}function jt(t){return Tt(t).gas_cost}function Tt(t){return"Success"in t?t.Success:"Failure"in t?t.Failure:(console.error("Unrecognized ExecutionStatus:",t),t[Object.keys(t)[0]])}var Et=function(){function t(t){this.bytePosition=0,this.dataView=new DataView(t.buffer)}var e=t.prototype;return e.shift=function(t){return this.bytePosition+=t,this},e.read8=function(){var t=this.dataView.getUint8(this.bytePosition);return this.shift(1),new n.BN(t,10)},e.read16=function(){var t=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),new n.BN(t,10)},e.read32=function(){var t=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),new n.BN(t,10)},e.read64=function(){var t=this.read32(),e=this.read32().toString(16)+t.toString(16).padStart(8,"0");return new n.BN(e,16)},e.read128=function(){var t=this.read64(),e=this.read64().toString(16)+t.toString(16).padStart(8,"0");return new n.BN(e,16)},e.readBytes=function(t){var e=new Uint8Array(this.dataView.buffer,this.bytePosition+this.dataView.byteOffset,t);return this.shift(t),e},e.readULEB=function(){var t=function(t){for(var e=0,r=0,n=0;;){var o=t[n];if(n+=1,e|=(127&o)<<r,0==(128&o))break;r+=7}return{value:e,length:n}}(new Uint8Array(this.dataView.buffer,this.bytePosition+this.dataView.byteOffset)),e=t.value;return this.shift(t.length),e},e.readVec=function(t){for(var e=this.readULEB(),r=[],n=0;n<e;n++)r.push(t(this,n,e));return r},t}(),St=function(){function t(t){void 0===t&&(t=1024),this.bytePosition=0,this.dataView=new DataView(new ArrayBuffer(t))}t.toBN=function(t){switch(typeof t){case"bigint":return new n.BN(t.toString());default:return new n.BN(t)}};var e=t.prototype;return e.shift=function(t){return this.bytePosition+=t,this},e.write8=function(e){return this.dataView.setUint8(this.bytePosition,+t.toBN(e)),this.shift(1)},e.write16=function(e){return this.dataView.setUint16(this.bytePosition,+t.toBN(e),!0),this.shift(2)},e.write32=function(e){return this.dataView.setUint32(this.bytePosition,+t.toBN(e),!0),this.shift(4)},e.write64=function(e){var r=this;return t.toBN(e).toArray("le",8).forEach((function(t){return r.write8(t)})),this},e.write128=function(e){var r=this;return t.toBN(e).toArray("le",16).forEach((function(t){return r.write8(t)})),this},e.writeULEB=function(t){var e=this;return function(t){var e=[],r=0;if(0===t)return[0];for(;t>0;)e[r]=127&t,(t>>=7)&&(e[r]|=128),r+=1;return e}(t).forEach((function(t){return e.write8(t)})),this},e.writeVec=function(t,e){var r=this;return this.writeULEB(t.length),Array.from(t).forEach((function(n,o){return e(r,n,o,t.length)})),this},e.toBytes=function(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))},e.toString=function(t){switch(t){case"base64":return new s(this.toBytes()).toString();case"hex":return new vt(this.toBytes()).toString();default:throw new Error("Unsupported encoding, supported values are: base64, hex")}},t}(),_t=function(){function t(){}return t.set=function(t,e,r){return void 0===r&&(r=1024),this.getTypeInterface(t).encode(e,r)},t.de=function(t,e){return this.getTypeInterface(t).decode(e)},t.hasType=function(t){return this.types.has(t)},t.registerType=function(t,e,r,n){return void 0===n&&(n=function(){return!0}),this.types.set(t,{encode:function(t,e){return void 0===e&&(e=1024),this._encodeRaw(new St(e),t)},decode:function(t){return this._decodeRaw(new Et(t))},_encodeRaw:function(r,o){if(n(o))return e(r,o);throw new Error("Validation failed for type "+t+", data: "+o)},_decodeRaw:function(t){return r(t)}}),this},t.registerAddressType=function(t,e){return this.registerType(t,(function(t,e){return new vt(e).getData().reduce((function(t,e){return t.write8(e)}),t)}),(function(t){return new vt(t.readBytes(e)).toString()}))},t.registerVectorType=function(e,r){return this.registerType(e,(function(e,n){return e.writeVec(n,(function(e,n){return t.getTypeInterface(r)._encodeRaw(e,n)}))}),(function(e){return e.readVec((function(e){return t.getTypeInterface(r)._decodeRaw(e)}))}))},t.registerStructType=function(e,r){var n=Object.freeze(r),o=Object.keys(n);return this.registerType(e,(function(e,r){for(var i,u=g(o);!(i=u()).done;){var c=i.value;t.getTypeInterface(n[c])._encodeRaw(e,r[c])}return e}),(function(e){for(var r,i={},u=g(o);!(r=u()).done;){var c=r.value;i[c]=t.getTypeInterface(n[c])._decodeRaw(e)}return i}))},t.registerEnumType=function(e,r){var n=Object.freeze(r),o=Object.keys(n);return this.registerType(e,(function(r,i){var u=Object.keys(i)[0];if(void 0===u)throw new Error("Unknown invariant of the enum "+e);var c=o.indexOf(u);if(-1===c)throw new Error("Unknown invariant of the enum "+e+", allowed values: "+o);var a=n[o[c]];return r.write8(c),null!==a?t.getTypeInterface(a)._encodeRaw(r,i[u]):r}),(function(r){var i,u=r.readULEB(),c=o[u],a=n[c];if(-1===u)throw new Error("Decoding type mismatch, expected enum "+e+" invariant index, received "+u);return(i={})[c]=null===a||t.getTypeInterface(a)._decodeRaw(r),i}))},t.getTypeInterface=function(e){var r=t.types.get(e);if(void 0===r)throw new Error("Type "+e+" is not registered");return r},t}();_t.U8="u8",_t.U32="u32",_t.U64="u64",_t.U128="u128",_t.BOOL="bool",_t.VECTOR="vector",_t.ADDRESS="address",_t.STRING="string",_t.types=new Map,_t.registerType(_t.U8,(function(t,e){return t.write8(e)}),(function(t){return t.read8()}),(function(t){return t<256})),_t.registerType(_t.U32,(function(t,e){return t.write32(e)}),(function(t){return t.read32()}),(function(t){return t<4294967296})),_t.registerType(_t.U64,(function(t,e){return t.write64(e)}),(function(t){return t.read64()}),(function(t){return!0})),_t.registerType(_t.U128,(function(t,e){return t.write128(e)}),(function(t){return t.read128()}),(function(t){return!0})),_t.registerType(_t.BOOL,(function(t,e){return t.write8(e)}),(function(t){return"1"==t.read8().toString(10)}),(function(t){return!0})),_t.registerType(_t.STRING,(function(t,e){return t.writeVec(Array.from(e),(function(t,e){return t.write8(e.charCodeAt(0))}))}),(function(t){return t.readVec((function(t){return t.read8()})).map((function(t){return String.fromCharCode(t)})).join("")}),(function(t){return/^[\x00-\x7F]*$/.test(t)})),exports.BCS={__proto__:null,BcsReader:Et,BcsWriter:St,BCS:_t},exports.Base64DataBuffer=s,exports.Ed25519Keypair=p,exports.HexDataBuffer=vt,exports.JsonRpcProvider=dt,exports.PUBLIC_KEY_SIZE=32,exports.Provider=h,exports.PublicKey=f,exports.RawSigner=xt,exports.RpcTxnDataSerializer=gt,exports.SignerWithProvider=bt,exports.getExecutionDetails=Tt,exports.getExecutionStatusType=function(t){return Object.keys(t)[0]},exports.getGasSummary=jt,exports.getMoveCallTransaction=function(t){var e=mt(t);return e&&"Call"in e?e.Call:void 0},exports.getMovePackageContent=function(t){var e=ct(t);if(null!=e)return"movePackage"===e.objectType?e.object.contents:void 0},exports.getObjectContent=at,exports.getObjectExistsResponse=ct,exports.getObjectType=function(t){var e;return null==(e=ct(t))?void 0:e.objectType},exports.getPublishTransaction=function(t){var e=mt(t);return e&&"Publish"in e?e.Publish:void 0},exports.getSingleTransactionKind=mt,exports.getTotalGasUsed=function(t){var e=jt(t);return e?e.computation_cost+e.storage_cost-e.storage_rebate:0},exports.getTransactionKind=function(t){var e=mt(t);return e&&Object.keys(e)[0]},exports.getTransferTransaction=function(t){var e=mt(t);return e&&"Transfer"in e?e.Transfer:void 0},exports.isAuthorityName=function(t,e){return"string"==typeof t},exports.isAuthorityQuorumSignInfo=F,exports.isAuthoritySignature=function(t,e){return"string"==typeof t},exports.isCertifiedTransaction=W,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.isEvent=Z,exports.isExecutionStatus=M,exports.isExecutionStatusDetail=z,exports.isExecutionStatusType=function(t,e){return"Success"===t||"Failure"===t},exports.isGasCostSummary=G,exports.isGatewayTxSeqNumber=function(t,e){return"number"==typeof t},exports.isGetObjectInfoResponse=C,exports.isGetOwnedObjectRefsResponse=I,exports.isGetTxnDigestsResponse=H,exports.isKeypair=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.getPublicKey&&"function"==typeof t.signData},exports.isMoveCall=et,exports.isMoveCallArg=rt,exports.isMoveModulePublish=Q,exports.isMovePackageContent=A,exports.isMoveTypeTag=tt,exports.isObjectContent=_,exports.isObjectContentField=E,exports.isObjectContentFields=S,exports.isObjectDigest=function(t,e){return"string"==typeof t},exports.isObjectExistsInfo=k,exports.isObjectId=function(t,e){return"string"==typeof t},exports.isObjectNotExistsInfo=B,exports.isObjectOwner=j,exports.isObjectRef=T,exports.isObjectStatus=P,exports.isObjectType=R,exports.isOwnedObjectRef=J,exports.isPublicKeyData=x,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)}))||x(t)},exports.isRawAuthoritySignInfo=D,exports.isRawObjectRef=U,exports.isSequenceNumber=L,exports.isSignedTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.tx_bytes)&&m(t.signature)&&m(t.pub_key)},exports.isSingleTransactionKind=q,exports.isStructTag=X,exports.isSuiAddress=function(t,e){return"string"==typeof t},exports.isSuiObject=O,exports.isTransactionBytes=nt,exports.isTransactionData=K,exports.isTransactionDigest=m,exports.isTransactionEffects=Y,exports.isTransactionEffectsResponse=$,exports.isTransactionKind=V,exports.isTransactionKindName=function(t,e){return"Transfer"===t||"Publish"===t||"Call"===t},exports.isTransactionResponse=ot,exports.isTransfer=N,exports.isTransferCoinTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.signer)&&m(t.objectId)&&m(t.gasPayment)&&L(t.gasBudget)&&m(t.recipient)},exports.isTxnDataSerializer=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.newTransferCoin};
"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=require("util"),a=t(require("jayson/lib/client/browser")),s=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 u.TextEncoder).encode("sui validation"),a=e.sign.detached(i,o.secretKey);if(!e.sign.detached.verify(i,a,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}(),h=function(){};function y(t,e,r,n,o,i,u){try{var a=t[i](u),s=a.value}catch(t){return void r(t)}a.done?e(s):Promise.resolve(s).then(n,o)}function l(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){y(i,n,o,u,a,"next",t)}function a(t){y(i,n,o,u,a,"throw",t)}u(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)}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function g(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return v(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(t,void 0):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var w,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 a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var o=Object.create((e&&e.prototype instanceof p?e:p).prototype),i=new j(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 a=x(u,r);if(a){if(a===f)continue;return a}}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 s=c(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.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=s;var f={};function p(){}function h(){}function y(){}var l={};a(l,o,(function(){return this}));var d=Object.getPrototypeOf,v=d&&d(d(E([])));v&&v!==e&&r.call(v,o)&&(l=v);var g=y.prototype=p.prototype=Object.create(l);function w(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;this._invoke=function(o,i){function u(){return new e((function(n,u){!function n(o,i,u,a){var s=c(t[o],t,i);if("throw"!==s.type){var f=s.arg,p=f.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,u,a)}),(function(t){n("throw",t,u,a)})):e.resolve(p).then((function(t){f.value=t,u(f)}),(function(t){return n("throw",t,u,a)}))}a(s.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 T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(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 h.prototype=y,a(g,"constructor",y),a(y,"constructor",h),h.displayName=a(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===h||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,a(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},w(b.prototype),a(b.prototype,i,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var u=new b(s(e,r,n,o),i);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},w(g),a(g,u,"Generator"),a(g,o,(function(){return this})),a(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=E,j.prototype={constructor:j,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(T),!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 a=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(a&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)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),T(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;T(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)}}(w={exports:{}}),w.exports);function x(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&t._bn instanceof n.BN}function m(t,e){return"string"==typeof t}function T(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)||"Shared"===t||"Immutable"===t}function j(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.digest)&&m(t.objectId)&&I(t.version)}function E(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Object.entries(t).every((function(t){return m(t[0])}))}function O(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 S(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&B(t.dataType)&&A(t)||(null!==t&&"object"==typeof t||"function"==typeof t)&&B(t.dataType)&&k(t)}function A(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.type)&&E(t.fields)}function k(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&O(t.disassembled)}function _(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&S(t.data)&&T(t.owner)&&m(t.previousTransaction)&&I(t.storageRebate)&&j(t.reference)}function R(t,e){return"Exists"===t||"NotExists"===t||"Deleted"===t}function B(t,e){return"moveObject"===t||"package"===t}function P(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.objects)&&t.objects.every((function(t){return j(t)}))}function C(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&R(t.status)&&(m(t.details)||j(t.details)||_(t.details))}function I(t,e){return"number"==typeof t}function L(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.recipient)&&j(t.objectRef)}function N(t,e){return Array.isArray(t)&&m(t[0])&&m(t[1])}function D(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&L(t.TransferCoin)||(null!==t&&"object"==typeof t||"function"==typeof t)&&k(t.Publish)||(null!==t&&"object"==typeof t||"function"==typeof t)&&$(t.Call)}function U(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&Array.isArray(t.transactions)&&t.transactions.every((function(t){return D(t)}))&&m(t.sender)&&j(t.gasPayment)&&I(t.gasBudget)}function q(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&I(t.epoch)&&Array.isArray(t.signatures)&&t.signatures.every((function(t){return N(t)}))}function V(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.transactionDigest)&&U(t.data)&&m(t.txSignature)&&q(t.authSignInfo)}function K(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&I(t.computationCost)&&I(t.storageCost)&&I(t.storageRebate)}function G(t,e){return"success"===t||"failure"===t}function W(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&G(t.status)&&K(t.gas_cost)&&(void 0===t.error||m(t.error))}function M(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&T(t.owner)&&j(t.reference)}function z(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&W(t.status)&&(void 0===t.sharedObjects||Array.isArray(t.sharedObjects)&&t.sharedObjects.every((function(t){return j(t)})))&&m(t.transactionDigest)&&(void 0===t.created||Array.isArray(t.created)&&t.created.every((function(t){return M(t)})))&&(void 0===t.mutated||Array.isArray(t.mutated)&&t.mutated.every((function(t){return M(t)})))&&(void 0===t.unwrapped||Array.isArray(t.unwrapped)&&t.unwrapped.every((function(t){return M(t)})))&&(void 0===t.deleted||Array.isArray(t.deleted)&&t.deleted.every((function(t){return j(t)})))&&(void 0===t.wrapped||Array.isArray(t.wrapped)&&t.wrapped.every((function(t){return j(t)})))&&M(t.gasObject)&&(void 0===t.events||Array.isArray(t.events)&&t.events.every((function(t){return J(t)})))&&(void 0===t.dependencies||Array.isArray(t.dependencies)&&t.dependencies.every((function(t){return m(t)})))}function F(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&V(t.certificate)&&z(t.effects)}function Z(t,e){return Array.isArray(t)&&t.every((function(t){return Array.isArray(t)&&I(t[0])&&m(t[1])}))}function J(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.type_)}function $(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&j(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 Y(t)})))}function Y(t,e){return m(t)||I(t)||!1===t||!0===t||Array.isArray(t)&&t.every((function(t){return m(t)||I(t)||!1===t||!0===t}))}function Q(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.txBytes)&&j(t.gas)}function X(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&V(t.certificate)&&_(t.updatedCoin)&&Array.isArray(t.newCoins)&&t.newCoins.every((function(t){return _(t)}))&&_(t.updatedGas)}function H(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&F(t.EffectResponse)||(null!==t&&"object"==typeof t||"function"==typeof t)&&X(t.SplitCoinResponse)}function tt(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"2.0"===t.jsonrpc&&m(t.id)}var et=require("lossless-json"),rt=function(){function t(t,e){this.rpcClient=this.createRpcClient(t,e)}var e=t.prototype;return e.createRpcClient=function(t,e){return new a(function(){var r=l(b.mark((function r(n,o){var i,u,a,c;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:a=r.sent,c=JSON.stringify(et.parse(a,(function(t,e){return"balance"===t?e.toString():e.isLosslessNumber?e.valueOf():e}))),u.ok?o(null,c):o(new Error(u.status+" "+u.statusText+": "+a)),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=l(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(!tt(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=l(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=l(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 tt(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=l(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}(),nt=function(t){return"number"==typeof t},ot=function(t){function e(e){var r;return(r=t.call(this)||this).endpoint=e,r.client=new rt(e),r}d(e,t);var r=e.prototype;return r.getOwnedObjectRefs=function(){var t=l(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_getOwnedObjects",[e],P);case 3:return t.abrupt("return",t.sent.objects);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("Error fetching owned object refs: "+t.t0+" for address "+e);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),r.getObjectInfo=function(){var t=l(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_getObjectInfo",[e],C);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.getObjectInfoBatch=function(){var t=l(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_getObjectInfo",args:[t]}})),t.prev=1,t.next=4,this.client.batchRequestWithType(r,C);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.getTransactionWithEffects=function(){var t=l(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],F);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=l(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,F);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=l(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_executeTransaction",[e,r,n],H);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=l(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",[],nt);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=l(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],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=l(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],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}(h),it=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}(),ut=function(){function t(t){this.client=new rt(t)}return t.prototype.newTransferCoin=function(){var t=l(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_transferCoin",[e.signer,e.objectId,e.gasPayment,e.gasBudget,e.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 coin: "+t.t0);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})));return function(e){return t.apply(this,arguments)}}(),t}(),at=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var r=e.prototype;return r.getOwnedObjectRefs=function(){var t=l(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getOwnedObjectRefs");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getObjectInfo=function(){var t=l(b.mark((function t(e){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw this.newError("getObjectInfo");case 1:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.getTransaction=function(){var t=l(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=l(b.mark((function t(e,r,n){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){return t.apply(this,arguments)}}(),r.getTotalTransactionNumber=function(){var t=l(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=l(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=l(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.newError=function(t){return new Error("Please use a valid provider for "+t)},e}(h),st=function(){function t(t,e){this.provider=t||new at;var r="";this.provider instanceof ot&&(r=this.provider.endpoint),this.serializer=e||new ut(r)}var e=t.prototype;return e.signAndExecuteTransaction=function(){var t=l(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.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.transferCoin=function(){var t=l(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.serializer.newTransferCoin(e);case 2:return r=t.sent,t.next=5,this.signAndExecuteTransaction(r);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)}}(),t}(),ct=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=l(b.mark((function t(){return b.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:throw 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=l(b.mark((function t(e){return b.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}(st),ft=/^(?:[a-zA-Z0-9+\/]{4})*(?:|(?:[a-zA-Z0-9+\/]{3}=)|(?:[a-zA-Z0-9+\/]{2}==)|(?:[a-zA-Z0-9+\/]{1}===))$/;function pt(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 ht(t){return"Exists"!==t.status?void 0:t.details}function yt(t){return"Deleted"!==t.status?void 0:t.details}function lt(t){return"NotExists"!==t.status?void 0:t.details}function dt(t){var e;return(null==(e=ht(t))?void 0:e.reference)||yt(t)}function vt(t){var e;return null==(e=wt(t))?void 0:e.type}function gt(t){var e;return null==(e=wt(t))?void 0:e.fields}function wt(t){var e=ht(t);if("moveObject"===(null==e?void 0:e.data.dataType))return e.data}function bt(t){return t.effects.status}function xt(t){return bt(t).gas_cost}var mt=function(){function t(){}return t.isCoin=function(t){var e,r;return null!=(e=null==(r=vt(t))?void 0:r.startsWith("0x2::Coin::Coin"))&&e},t.getBalance=function(e){var r;if(t.isCoin(e)){var n=null==(r=gt(e))?void 0:r.balance;return new o.BN(n,10)}},t.getZero=function(){return new o.BN("0",10)},t}(),Tt=function(){function t(t){this.bytePosition=0,this.dataView=new DataView(t.buffer)}var e=t.prototype;return e.shift=function(t){return this.bytePosition+=t,this},e.read8=function(){var t=this.dataView.getUint8(this.bytePosition);return this.shift(1),new n.BN(t,10)},e.read16=function(){var t=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),new n.BN(t,10)},e.read32=function(){var t=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),new n.BN(t,10)},e.read64=function(){var t=this.read32(),e=this.read32().toString(16)+t.toString(16).padStart(8,"0");return new n.BN(e,16)},e.read128=function(){var t=this.read64(),e=this.read64().toString(16)+t.toString(16).padStart(8,"0");return new n.BN(e,16)},e.readBytes=function(t){var e=new Uint8Array(this.dataView.buffer,this.bytePosition+this.dataView.byteOffset,t);return this.shift(t),e},e.readULEB=function(){var t=function(t){for(var e=0,r=0,n=0;;){var o=t[n];if(n+=1,e|=(127&o)<<r,0==(128&o))break;r+=7}return{value:e,length:n}}(new Uint8Array(this.dataView.buffer,this.bytePosition+this.dataView.byteOffset)),e=t.value;return this.shift(t.length),e},e.readVec=function(t){for(var e=this.readULEB(),r=[],n=0;n<e;n++)r.push(t(this,n,e));return r},t}(),jt=function(){function t(t){void 0===t&&(t=1024),this.bytePosition=0,this.dataView=new DataView(new ArrayBuffer(t))}t.toBN=function(t){switch(typeof t){case"bigint":return new n.BN(t.toString());default:return new n.BN(t)}};var e=t.prototype;return e.shift=function(t){return this.bytePosition+=t,this},e.write8=function(e){return this.dataView.setUint8(this.bytePosition,+t.toBN(e)),this.shift(1)},e.write16=function(e){return this.dataView.setUint16(this.bytePosition,+t.toBN(e),!0),this.shift(2)},e.write32=function(e){return this.dataView.setUint32(this.bytePosition,+t.toBN(e),!0),this.shift(4)},e.write64=function(e){var r=this;return t.toBN(e).toArray("le",8).forEach((function(t){return r.write8(t)})),this},e.write128=function(e){var r=this;return t.toBN(e).toArray("le",16).forEach((function(t){return r.write8(t)})),this},e.writeULEB=function(t){var e=this;return function(t){var e=[],r=0;if(0===t)return[0];for(;t>0;)e[r]=127&t,(t>>=7)&&(e[r]|=128),r+=1;return e}(t).forEach((function(t){return e.write8(t)})),this},e.writeVec=function(t,e){var r=this;return this.writeULEB(t.length),Array.from(t).forEach((function(n,o){return e(r,n,o,t.length)})),this},e.toBytes=function(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))},e.toString=function(t){switch(t){case"base64":return new c(this.toBytes()).toString();case"hex":return new it(this.toBytes()).toString();default:throw new Error("Unsupported encoding, supported values are: base64, hex")}},t}(),Et=function(){function t(){}return t.set=function(t,e,r){return void 0===r&&(r=1024),this.getTypeInterface(t).encode(e,r)},t.de=function(t,e){return this.getTypeInterface(t).decode(e)},t.hasType=function(t){return this.types.has(t)},t.registerType=function(t,e,r,n){return void 0===n&&(n=function(){return!0}),this.types.set(t,{encode:function(t,e){return void 0===e&&(e=1024),this._encodeRaw(new jt(e),t)},decode:function(t){return this._decodeRaw(new Tt(t))},_encodeRaw:function(r,o){if(n(o))return e(r,o);throw new Error("Validation failed for type "+t+", data: "+o)},_decodeRaw:function(t){return r(t)}}),this},t.registerAddressType=function(t,e){return this.registerType(t,(function(t,e){return new it(e).getData().reduce((function(t,e){return t.write8(e)}),t)}),(function(t){return new it(t.readBytes(e)).toString()}))},t.registerVectorType=function(e,r){return this.registerType(e,(function(e,n){return e.writeVec(n,(function(e,n){return t.getTypeInterface(r)._encodeRaw(e,n)}))}),(function(e){return e.readVec((function(e){return t.getTypeInterface(r)._decodeRaw(e)}))}))},t.registerStructType=function(e,r){var n=Object.freeze(r),o=Object.keys(n);return this.registerType(e,(function(e,r){for(var i,u=g(o);!(i=u()).done;){var a=i.value;t.getTypeInterface(n[a])._encodeRaw(e,r[a])}return e}),(function(e){for(var r,i={},u=g(o);!(r=u()).done;){var a=r.value;i[a]=t.getTypeInterface(n[a])._decodeRaw(e)}return i}))},t.registerEnumType=function(e,r){var n=Object.freeze(r),o=Object.keys(n);return this.registerType(e,(function(r,i){var u=Object.keys(i)[0];if(void 0===u)throw new Error("Unknown invariant of the enum "+e);var a=o.indexOf(u);if(-1===a)throw new Error("Unknown invariant of the enum "+e+", allowed values: "+o);var s=n[o[a]];return r.write8(a),null!==s?t.getTypeInterface(s)._encodeRaw(r,i[u]):r}),(function(r){var i,u=r.readULEB(),a=o[u],s=n[a];if(-1===u)throw new Error("Decoding type mismatch, expected enum "+e+" invariant index, received "+u);return(i={})[a]=null===s||t.getTypeInterface(s)._decodeRaw(r),i}))},t.getTypeInterface=function(e){var r=t.types.get(e);if(void 0===r)throw new Error("Type "+e+" is not registered");return r},t}();Et.U8="u8",Et.U32="u32",Et.U64="u64",Et.U128="u128",Et.BOOL="bool",Et.VECTOR="vector",Et.ADDRESS="address",Et.STRING="string",Et.types=new Map,Et.registerType(Et.U8,(function(t,e){return t.write8(e)}),(function(t){return t.read8()}),(function(t){return t<256})),Et.registerType(Et.U32,(function(t,e){return t.write32(e)}),(function(t){return t.read32()}),(function(t){return t<4294967296})),Et.registerType(Et.U64,(function(t,e){return t.write64(e)}),(function(t){return t.read64()}),(function(t){return!0})),Et.registerType(Et.U128,(function(t,e){return t.write128(e)}),(function(t){return t.read128()}),(function(t){return!0})),Et.registerType(Et.BOOL,(function(t,e){return t.write8(e)}),(function(t){return"1"==t.read8().toString(10)}),(function(t){return!0})),Et.registerType(Et.STRING,(function(t,e){return t.writeVec(Array.from(e),(function(t,e){return t.write8(e.charCodeAt(0))}))}),(function(t){return t.readVec((function(t){return t.read8()})).map((function(t){return String.fromCharCode(t)})).join("")}),(function(t){return/^[\x00-\x7F]*$/.test(t)})),exports.BCS={__proto__:null,BcsReader:Tt,BcsWriter:jt,BCS:Et},exports.Base64DataBuffer=c,exports.Coin=mt,exports.Ed25519Keypair=p,exports.HexDataBuffer=it,exports.JsonRpcProvider=ot,exports.PUBLIC_KEY_SIZE=32,exports.Provider=h,exports.PublicKey=f,exports.RawSigner=ct,exports.RpcTxnDataSerializer=ut,exports.SignerWithProvider=st,exports.getExecutionStatus=bt,exports.getExecutionStatusError=function(t){return bt(t).error},exports.getExecutionStatusGasSummary=xt,exports.getExecutionStatusType=function(t){return bt(t).status},exports.getMoveCallTransaction=function(t){return"Call"in t?t.Call:void 0},exports.getMoveObject=wt,exports.getMoveObjectType=vt,exports.getMovePackageContent=function(t){if("disassembled"in t)return t.disassembled;var e=ht(t);return"package"===(null==e?void 0:e.data.dataType)?e.data.disassembled:void 0},exports.getObjectDeletedResponse=yt,exports.getObjectExistsResponse=ht,exports.getObjectFields=gt,exports.getObjectId=function(t){var e,r;return"objectId"in t?t.objectId:null!=(e=null==(r=dt(t))?void 0:r.objectId)?e:lt(t)},exports.getObjectNotExistsResponse=lt,exports.getObjectOwner=function(t){var e;return null==(e=ht(t))?void 0:e.owner},exports.getObjectPreviousTransactionDigest=function(t){var e;return null==(e=ht(t))?void 0:e.previousTransaction},exports.getObjectReference=dt,exports.getObjectType=function(t){var e;return null==(e=ht(t))?void 0:e.data.dataType},exports.getObjectVersion=function(t){var e;return"version"in t?t.version:null==(e=dt(t))?void 0:e.version},exports.getPublishTransaction=function(t){return"Publish"in t?t.Publish:void 0},exports.getTotalGasUsed=function(t){var e=xt(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.getTransferCoinTransaction=function(t){return"TransferCoin"in t?t.TransferCoin:void 0},exports.isAuthorityName=function(t,e){return"string"==typeof t},exports.isAuthorityQuorumSignInfo=q,exports.isAuthoritySignature=function(t,e){return"string"==typeof t},exports.isCertifiedTransaction=V,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.isEvent=J,exports.isExecutionStatus=W,exports.isExecutionStatusType=G,exports.isGasCostSummary=K,exports.isGatewayTxSeqNumber=function(t,e){return"number"==typeof t},exports.isGetObjectInfoResponse=C,exports.isGetOwnedObjectRefsResponse=P,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.isMoveCall=$,exports.isMovePackageContent=O,exports.isObjectContentFields=E,exports.isObjectDigest=function(t,e){return"string"==typeof t},exports.isObjectId=function(t,e){return"string"==typeof t},exports.isObjectOwner=T,exports.isObjectStatus=R,exports.isObjectType=B,exports.isOwnedObjectRef=M,exports.isPublicKeyData=x,exports.isPublicKeyInitData=function(t,e){return m(t)||I(t)||t instanceof Buffer||t instanceof Uint8Array||Array.isArray(t)&&t.every((function(t){return I(t)}))||x(t)},exports.isRawAuthoritySignInfo=N,exports.isSequenceNumber=I,exports.isSplitCoinResponse=X,exports.isSuiAddress=function(t,e){return"string"==typeof t},exports.isSuiData=S,exports.isSuiJsonValue=Y,exports.isSuiMoveObject=A,exports.isSuiMovePackage=k,exports.isSuiObject=_,exports.isSuiObjectRef=j,exports.isSuiTransactionKind=D,exports.isTransactionBytes=Q,exports.isTransactionData=U,exports.isTransactionDigest=m,exports.isTransactionEffects=z,exports.isTransactionEffectsResponse=F,exports.isTransactionKindName=function(t,e){return"TransferCoin"===t||"Publish"===t||"Call"===t},exports.isTransactionResponse=H,exports.isTransferCoin=L,exports.isTransferCoinTransaction=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&m(t.signer)&&m(t.objectId)&&m(t.gasPayment)&&I(t.gasBudget)&&m(t.recipient)},exports.isTxnDataSerializer=function(t,e){return(null!==t&&"object"==typeof t||"function"==typeof t)&&"function"==typeof t.newTransferCoin},exports.isValidSuiAddress=pt,exports.isValidSuiObjectId=function(t){return pt(t)},exports.isValidTransactionDigest=function(t){return 32===new c(t).getLength()&&ft.test(t)};
//# sourceMappingURL=sui.js.cjs.production.min.js.map

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

/** Base64 string representing the object digest */
export declare type TransactionDigest = string;

@@ -8,1 +9,4 @@ export declare type SuiAddress = string;

} | 'Shared' | 'Immutable';
export declare function isValidTransactionDigest(value: string): value is TransactionDigest;
export declare function isValidSuiAddress(value: string): value is SuiAddress;
export declare function isValidSuiObjectId(value: string): boolean;
export * from './common';
export * from './objects';
export * from './transactions';
export * from './framework';
import { ObjectOwner } from './common';
import { TransactionDigest } from './common';
export declare type ObjectRef = {
export declare type SuiObjectRef = {
/** Base64 string representing the object digest */
digest: TransactionDigest;
/** Hex code as string representing the object id */
objectId: string;
/** Object version */
version: number;
};
export declare type ObjectContentField = ObjectContent | string | boolean | number | number[] | ObjectContent[];
export declare type ObjectContentFields = Record<string, ObjectContentField>;
export declare type ObjectContent = {
export declare type ObjectContentFields = Record<string, any>;
export declare type MovePackageContent = Record<string, string>;
export declare type SuiData = {
dataType: ObjectType;
} & (SuiMoveObject | SuiMovePackage);
export declare type SuiMoveObject = {
/** Move type (e.g., "0x2::Coin::Coin<0x2::SUI::SUI>") */
type: string;
/** Fields and values stored inside the Move object */
fields: ObjectContentFields;
type: string;
};
export declare type MovePackageContent = Record<string, string>;
export declare type SuiMovePackage = {
/** A mapping from module name to disassembled Move bytecode */
disassembled: MovePackageContent;
};
export declare type SuiObject = {
contents: ObjectContent | MovePackageContent;
/** The meat of the object */
data: SuiData;
/** The owner of the object */
owner: ObjectOwner;
tx_digest: TransactionDigest;
/** The digest of the transaction that created or last mutated this object */
previousTransaction: TransactionDigest;
/**
* The amount of SUI we would rebate if this object gets deleted.
* This number is re-calculated each time the object is mutated based on
* the present storage gas price.
*/
storageRebate: number;
reference: SuiObjectRef;
};
export declare type ObjectExistsInfo = {
objectRef: ObjectRef;
objectType: ObjectType;
object: SuiObject;
};
export declare type ObjectNotExistsInfo = {
objectId: ObjectId;
};
export declare type ObjectStatus = 'Exists' | 'NotExists' | 'Deleted';
export declare type ObjectType = 'moveObject' | 'movePackage';
export declare type ObjectType = 'moveObject' | 'package';
export declare type GetOwnedObjectRefsResponse = {
objects: ObjectRef[];
objects: SuiObjectRef[];
};
export declare type GetObjectInfoResponse = {
status: ObjectStatus;
details: ObjectExistsInfo | ObjectNotExistsInfo | ObjectRef;
details: SuiObject | ObjectId | SuiObjectRef;
};

@@ -40,6 +53,14 @@ export declare type ObjectDigest = string;

export declare type SequenceNumber = number;
export declare type RawObjectRef = [ObjectId, SequenceNumber, ObjectDigest];
export declare function getObjectExistsResponse(resp: GetObjectInfoResponse): ObjectExistsInfo | undefined;
export declare function getObjectType(resp: GetObjectInfoResponse): 'moveObject' | 'movePackage' | undefined;
export declare function getObjectContent(resp: GetObjectInfoResponse): ObjectContent | undefined;
export declare function getMovePackageContent(resp: GetObjectInfoResponse): MovePackageContent | undefined;
export declare function getObjectExistsResponse(resp: GetObjectInfoResponse): SuiObject | undefined;
export declare function getObjectDeletedResponse(resp: GetObjectInfoResponse): SuiObjectRef | undefined;
export declare function getObjectNotExistsResponse(resp: GetObjectInfoResponse): ObjectId | undefined;
export declare function getObjectReference(resp: GetObjectInfoResponse): SuiObjectRef | undefined;
export declare function getObjectId(data: GetObjectInfoResponse | SuiObjectRef): ObjectId;
export declare function getObjectVersion(data: GetObjectInfoResponse | SuiObjectRef): number | undefined;
export declare function getObjectType(resp: GetObjectInfoResponse): ObjectType | undefined;
export declare function getObjectPreviousTransactionDigest(resp: GetObjectInfoResponse): TransactionDigest | undefined;
export declare function getObjectOwner(resp: GetObjectInfoResponse): ObjectOwner | undefined;
export declare function getMoveObjectType(resp: GetObjectInfoResponse): string | undefined;
export declare function getObjectFields(resp: GetObjectInfoResponse): ObjectContentFields | undefined;
export declare function getMoveObject(resp: GetObjectInfoResponse): SuiMoveObject | undefined;
export declare function getMovePackageContent(data: GetObjectInfoResponse | SuiMovePackage): MovePackageContent | undefined;
import { ObjectOwner, SuiAddress, TransactionDigest } from './common';
import { ObjectId, RawObjectRef } from './objects';
export declare type Transfer = {
recipient: string;
object_ref: RawObjectRef;
import { SuiMovePackage, SuiObject, SuiObjectRef } from './objects';
export declare type TransferCoin = {
recipient: SuiAddress;
objectRef: SuiObjectRef;
};
export declare type RawAuthoritySignInfo = [AuthorityName, AuthoritySignature];
export declare type TransactionKindName = 'Transfer' | 'Publish' | 'Call';
export declare type SingleTransactionKind = {
Transfer: Transfer;
export declare type TransactionKindName = 'TransferCoin' | 'Publish' | 'Call';
export declare type SuiTransactionKind = {
TransferCoin: TransferCoin;
} | {
Publish: MoveModulePublish;
Publish: SuiMovePackage;
} | {
Call: MoveCall;
};
export declare type TransactionKind = {
Single: SingleTransactionKind;
} | {
Batch: SingleTransactionKind[];
};
export declare type TransactionData = {
kind: TransactionKind;
sender: string;
gas_payment: RawObjectRef;
gas_budget: number;
transactions: SuiTransactionKind[];
sender: SuiAddress;
gasPayment: SuiObjectRef;
gasBudget: number;
};

@@ -33,34 +28,52 @@ export declare type EpochId = number;

export declare type CertifiedTransaction = {
transactionDigest: TransactionDigest;
data: TransactionData;
tx_signature: string;
auth_sign_info: AuthorityQuorumSignInfo;
txSignature: string;
authSignInfo: AuthorityQuorumSignInfo;
};
export declare type GasCostSummary = {
computation_cost: number;
storage_cost: number;
storage_rebate: number;
computationCost: number;
storageCost: number;
storageRebate: number;
};
export declare type ExecutionStatusType = 'Success' | 'Failure';
export declare type ExecutionStatusType = 'success' | 'failure';
export declare type ExecutionStatus = {
Success: ExecutionStatusDetail;
} | {
Failure: ExecutionStatusDetail;
};
export declare type ExecutionStatusDetail = {
status: ExecutionStatusType;
gas_cost: GasCostSummary;
error?: any;
error?: string;
};
export declare type OwnedObjectRef = [RawObjectRef, ObjectOwner];
export declare type OwnedObjectRef = {
owner: ObjectOwner;
reference: SuiObjectRef;
};
export declare type TransactionEffects = {
/** The status of the execution */
status: ExecutionStatus;
shared_objects: RawObjectRef[];
transaction_digest: TransactionDigest;
created: OwnedObjectRef[];
mutated: OwnedObjectRef[];
unwrapped: OwnedObjectRef[];
deleted: RawObjectRef[];
wrapped: RawObjectRef[];
gas_object: OwnedObjectRef;
events: Event[];
dependencies: TransactionDigest[];
/** The object references of the shared objects used in this transaction. Empty if no shared objects were used. */
sharedObjects?: SuiObjectRef[];
/** The transaction digest */
transactionDigest: TransactionDigest;
/** ObjectRef and owner of new objects created */
created?: OwnedObjectRef[];
/** ObjectRef and owner of mutated objects, including gas object */
mutated?: OwnedObjectRef[];
/**
* ObjectRef and owner of objects that are unwrapped in this transaction.
* Unwrapped objects are objects that were wrapped into other objects in the past,
* and just got extracted out.
*/
unwrapped?: OwnedObjectRef[];
/** Object Refs of objects now deleted (the old refs) */
deleted?: SuiObjectRef[];
/** Object refs of objects now wrapped in other objects */
wrapped?: SuiObjectRef[];
/**
* The updated gas object reference. Have a dedicated field for convenient access.
* It's also included in mutated.
*/
gasObject: OwnedObjectRef;
/** The events emitted during execution. Note that only successful transactions emit events */
events?: Event[];
/** The set of transaction digests this transaction depends on */
dependencies?: TransactionDigest[];
};

@@ -73,34 +86,14 @@ export declare type TransactionEffectsResponse = {

export declare type GetTxnDigestsResponse = [GatewayTxSeqNumber, TransactionDigest][];
export declare type MoveModulePublish = {
modules: any;
};
export declare type Event = {
type_: StructTag;
contents: string;
type_: string;
contents: any;
};
export declare type StructTag = {
address: SuiAddress;
module: string;
name: string;
type_args: MoveTypeTag[];
};
export declare type MoveTypeTag = 'bool' | 'u8' | 'u64' | 'u128' | 'address' | 'signer' | {
vector: MoveTypeTag[];
} | {
struct: StructTag;
};
export declare type MoveCall = {
package: RawObjectRef;
package: SuiObjectRef;
module: string;
function: string;
type_arguments: MoveTypeTag[];
arguments: MoveCallArg[];
typeArguments?: string[];
arguments?: SuiJsonValue[];
};
export declare type MoveCallArg = {
Pure: number[];
} | {
ImmOrOwnedObject: RawObjectRef;
} | {
SharedObject: ObjectId;
};
export declare type SuiJsonValue = boolean | number | string | Array<boolean | number | string>;
export declare type EmptySignInfo = object;

@@ -110,20 +103,32 @@ export declare type AuthorityName = string;

export declare type TransactionBytes = {
tx_bytes: string;
txBytes: string;
gas: SuiObjectRef;
};
export declare type SplitCoinResponse = {
certificate: CertifiedTransaction;
updatedCoin: SuiObject;
newCoins: SuiObject[];
updatedGas: SuiObject;
};
export declare type TransactionResponse = {
EffectResponse: TransactionEffectsResponse;
} | {
SplitCoinResponse: SplitCoinResponse;
};
export declare type SignedTransaction = {
tx_bytes: string;
signature: string;
pub_key: string;
};
export declare function getSingleTransactionKind(data: TransactionData): SingleTransactionKind | undefined;
export declare function getTransferTransaction(data: TransactionData): Transfer | undefined;
export declare function getPublishTransaction(data: TransactionData): MoveModulePublish | undefined;
export declare function getMoveCallTransaction(data: TransactionData): MoveCall | undefined;
export declare function getTransactionKind(data: TransactionData): TransactionKindName | undefined;
export declare function getExecutionStatusType(data: ExecutionStatus): ExecutionStatusType;
export declare function getGasSummary(data: ExecutionStatus): GasCostSummary | undefined;
export declare function getTotalGasUsed(data: ExecutionStatus): number;
export declare function getExecutionDetails(data: ExecutionStatus): ExecutionStatusDetail;
export declare function getTransactionDigest(tx: CertifiedTransaction): TransactionDigest;
export declare function getTransactionSignature(tx: CertifiedTransaction): string;
export declare function getTransactionAuthorityQuorumSignInfo(tx: CertifiedTransaction): AuthorityQuorumSignInfo;
export declare function getTransactionData(tx: CertifiedTransaction): TransactionData;
export declare function getTransactionSender(tx: CertifiedTransaction): SuiAddress;
export declare function getTransactionGasObject(tx: CertifiedTransaction): SuiObjectRef;
export declare function getTransactionGasBudget(tx: CertifiedTransaction): number;
export declare function getTransferCoinTransaction(data: SuiTransactionKind): TransferCoin | undefined;
export declare function getPublishTransaction(data: SuiTransactionKind): SuiMovePackage | undefined;
export declare function getMoveCallTransaction(data: SuiTransactionKind): MoveCall | undefined;
export declare function getTransactions(data: CertifiedTransaction): SuiTransactionKind[];
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;
{
"version": "0.1.2",
"version": "0.2.0",
"license": "Apache-2.0",

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

"js-sha3": "^0.8.0",
"lossless-json": "^1.0.5",
"tweetnacl": "^1.0.3",

@@ -73,0 +74,0 @@ "util": "^0.12.4"

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

*/
import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, TransferCoinTransaction, TxnDataSerializer, TransactionDigest, SuiAddress, ObjectOwner, ObjectRef, ObjectContentField, ObjectContentFields, ObjectContent, MovePackageContent, SuiObject, ObjectExistsInfo, ObjectNotExistsInfo, ObjectStatus, ObjectType, GetOwnedObjectRefsResponse, GetObjectInfoResponse, ObjectDigest, ObjectId, SequenceNumber, RawObjectRef, Transfer, RawAuthoritySignInfo, TransactionKindName, SingleTransactionKind, TransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, ExecutionStatusDetail, OwnedObjectRef, TransactionEffects, TransactionEffectsResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, MoveModulePublish, Event, StructTag, MoveTypeTag, MoveCall, MoveCallArg, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, TransactionResponse, SignedTransaction } from "./index";
import { Ed25519KeypairData, Keypair, PublicKeyInitData, PublicKeyData, TransferCoinTransaction, TxnDataSerializer, TransactionDigest, SuiAddress, ObjectOwner, SuiObjectRef, ObjectContentFields, MovePackageContent, SuiData, SuiMoveObject, SuiMovePackage, SuiObject, ObjectStatus, ObjectType, GetOwnedObjectRefsResponse, GetObjectInfoResponse, ObjectDigest, ObjectId, SequenceNumber, TransferCoin, RawAuthoritySignInfo, TransactionKindName, SuiTransactionKind, TransactionData, EpochId, AuthorityQuorumSignInfo, CertifiedTransaction, GasCostSummary, ExecutionStatusType, ExecutionStatus, OwnedObjectRef, TransactionEffects, TransactionEffectsResponse, GatewayTxSeqNumber, GetTxnDigestsResponse, Event, MoveCall, SuiJsonValue, EmptySignInfo, AuthorityName, AuthoritySignature, TransactionBytes, SplitCoinResponse, TransactionResponse } from "./index";
import { BN } from "bn.js";

@@ -104,3 +104,3 @@

export function isObjectRef(obj: any, _argumentName?: string): obj is ObjectRef {
export function isSuiObjectRef(obj: any, _argumentName?: string): obj is SuiObjectRef {
return (

@@ -116,20 +116,2 @@ (obj !== null &&

export function isObjectContentField(obj: any, _argumentName?: string): obj is ObjectContentField {
return (
(isTransactionDigest(obj) as boolean ||
isSequenceNumber(obj) as boolean ||
obj === false ||
obj === true ||
Array.isArray(obj) &&
obj.every((e: any) =>
isSequenceNumber(e) as boolean
) ||
isObjectContent(obj) as boolean ||
Array.isArray(obj) &&
obj.every((e: any) =>
isObjectContent(e) as boolean
))
)
}
export function isObjectContentFields(obj: any, _argumentName?: string): obj is ObjectContentFields {

@@ -141,8 +123,7 @@ return (

Object.entries<any>(obj)
.every(([key, value]) => (isObjectContentField(value) as boolean &&
isTransactionDigest(key) as boolean))
.every(([key, _value]) => (isTransactionDigest(key) as boolean))
)
}
export function isObjectContent(obj: any, _argumentName?: string): obj is ObjectContent {
export function isMovePackageContent(obj: any, _argumentName?: string): obj is MovePackageContent {
return (

@@ -152,19 +133,24 @@ (obj !== null &&

typeof obj === "function") &&
isObjectContentFields(obj.fields) as boolean &&
isTransactionDigest(obj.type) as boolean
Object.entries<any>(obj)
.every(([key, value]) => (isTransactionDigest(value) as boolean &&
isTransactionDigest(key) as boolean))
)
}
export function isMovePackageContent(obj: any, _argumentName?: string): obj is MovePackageContent {
export function isSuiData(obj: any, _argumentName?: string): obj is SuiData {
return (
(obj !== null &&
((obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
Object.entries<any>(obj)
.every(([key, value]) => (isTransactionDigest(value) as boolean &&
isTransactionDigest(key) as boolean))
isObjectType(obj.dataType) as boolean &&
isSuiMoveObject(obj) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isObjectType(obj.dataType) as boolean &&
isSuiMovePackage(obj) as boolean)
)
}
export function isSuiObject(obj: any, _argumentName?: string): obj is SuiObject {
export function isSuiMoveObject(obj: any, _argumentName?: string): obj is SuiMoveObject {
return (

@@ -174,10 +160,8 @@ (obj !== null &&

typeof obj === "function") &&
(isObjectContent(obj.contents) as boolean ||
isMovePackageContent(obj.contents) as boolean) &&
isObjectOwner(obj.owner) as boolean &&
isTransactionDigest(obj.tx_digest) as boolean
isTransactionDigest(obj.type) as boolean &&
isObjectContentFields(obj.fields) as boolean
)
}
export function isObjectExistsInfo(obj: any, _argumentName?: string): obj is ObjectExistsInfo {
export function isSuiMovePackage(obj: any, _argumentName?: string): obj is SuiMovePackage {
return (

@@ -187,9 +171,7 @@ (obj !== null &&

typeof obj === "function") &&
isObjectRef(obj.objectRef) as boolean &&
isObjectType(obj.objectType) as boolean &&
isSuiObject(obj.object) as boolean
isMovePackageContent(obj.disassembled) as boolean
)
}
export function isObjectNotExistsInfo(obj: any, _argumentName?: string): obj is ObjectNotExistsInfo {
export function isSuiObject(obj: any, _argumentName?: string): obj is SuiObject {
return (

@@ -199,3 +181,7 @@ (obj !== null &&

typeof obj === "function") &&
isTransactionDigest(obj.objectId) as boolean
isSuiData(obj.data) as boolean &&
isObjectOwner(obj.owner) as boolean &&
isTransactionDigest(obj.previousTransaction) as boolean &&
isSequenceNumber(obj.storageRebate) as boolean &&
isSuiObjectRef(obj.reference) as boolean
)

@@ -215,3 +201,3 @@ }

(obj === "moveObject" ||
obj === "movePackage")
obj === "package")
)

@@ -227,3 +213,3 @@ }

obj.objects.every((e: any) =>
isObjectRef(e) as boolean
isSuiObjectRef(e) as boolean
)

@@ -239,5 +225,5 @@ )

isObjectStatus(obj.status) as boolean &&
(isObjectRef(obj.details) as boolean ||
isObjectExistsInfo(obj.details) as boolean ||
isObjectNotExistsInfo(obj.details) as boolean)
(isTransactionDigest(obj.details) as boolean ||
isSuiObjectRef(obj.details) as boolean ||
isSuiObject(obj.details) as boolean)
)

@@ -264,13 +250,4 @@ }

export function isRawObjectRef(obj: any, _argumentName?: string): obj is RawObjectRef {
export function isTransferCoin(obj: any, _argumentName?: string): obj is TransferCoin {
return (
Array.isArray(obj) &&
isTransactionDigest(obj[0]) as boolean &&
isSequenceNumber(obj[1]) as boolean &&
isTransactionDigest(obj[2]) as boolean
)
}
export function isTransfer(obj: any, _argumentName?: string): obj is Transfer {
return (
(obj !== null &&

@@ -280,3 +257,3 @@ typeof obj === "object" ||

isTransactionDigest(obj.recipient) as boolean &&
isRawObjectRef(obj.object_ref) as boolean
isSuiObjectRef(obj.objectRef) as boolean
)

@@ -295,3 +272,3 @@ }

return (
(obj === "Transfer" ||
(obj === "TransferCoin" ||
obj === "Publish" ||

@@ -302,3 +279,3 @@ obj === "Call")

export function isSingleTransactionKind(obj: any, _argumentName?: string): obj is SingleTransactionKind {
export function isSuiTransactionKind(obj: any, _argumentName?: string): obj is SuiTransactionKind {
return (

@@ -308,7 +285,7 @@ ((obj !== null &&

typeof obj === "function") &&
isTransfer(obj.Transfer) as boolean ||
isTransferCoin(obj.TransferCoin) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isMoveModulePublish(obj.Publish) as boolean ||
isSuiMovePackage(obj.Publish) as boolean ||
(obj !== null &&

@@ -321,18 +298,2 @@ typeof obj === "object" ||

export function isTransactionKind(obj: any, _argumentName?: string): obj is TransactionKind {
return (
((obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSingleTransactionKind(obj.Single) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
Array.isArray(obj.Batch) &&
obj.Batch.every((e: any) =>
isSingleTransactionKind(e) as boolean
))
)
}
export function isTransactionData(obj: any, _argumentName?: string): obj is TransactionData {

@@ -343,6 +304,9 @@ return (

typeof obj === "function") &&
isTransactionKind(obj.kind) as boolean &&
Array.isArray(obj.transactions) &&
obj.transactions.every((e: any) =>
isSuiTransactionKind(e) as boolean
) &&
isTransactionDigest(obj.sender) as boolean &&
isRawObjectRef(obj.gas_payment) as boolean &&
isSequenceNumber(obj.gas_budget) as boolean
isSuiObjectRef(obj.gasPayment) as boolean &&
isSequenceNumber(obj.gasBudget) as boolean
)

@@ -375,5 +339,6 @@ }

typeof obj === "function") &&
isTransactionDigest(obj.transactionDigest) as boolean &&
isTransactionData(obj.data) as boolean &&
isTransactionDigest(obj.tx_signature) as boolean &&
isAuthorityQuorumSignInfo(obj.auth_sign_info) as boolean
isTransactionDigest(obj.txSignature) as boolean &&
isAuthorityQuorumSignInfo(obj.authSignInfo) as boolean
)

@@ -387,5 +352,5 @@ }

typeof obj === "function") &&
isSequenceNumber(obj.computation_cost) as boolean &&
isSequenceNumber(obj.storage_cost) as boolean &&
isSequenceNumber(obj.storage_rebate) as boolean
isSequenceNumber(obj.computationCost) as boolean &&
isSequenceNumber(obj.storageCost) as boolean &&
isSequenceNumber(obj.storageRebate) as boolean
)

@@ -396,4 +361,4 @@ }

return (
(obj === "Success" ||
obj === "Failure")
(obj === "success" ||
obj === "failure")
)

@@ -404,14 +369,13 @@ }

return (
((obj !== null &&
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isExecutionStatusDetail(obj.Success) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isExecutionStatusDetail(obj.Failure) as boolean)
isExecutionStatusType(obj.status) as boolean &&
isGasCostSummary(obj.gas_cost) as boolean &&
(typeof obj.error === "undefined" ||
isTransactionDigest(obj.error) as boolean)
)
}
export function isExecutionStatusDetail(obj: any, _argumentName?: string): obj is ExecutionStatusDetail {
export function isOwnedObjectRef(obj: any, _argumentName?: string): obj is OwnedObjectRef {
return (

@@ -421,14 +385,7 @@ (obj !== null &&

typeof obj === "function") &&
isGasCostSummary(obj.gas_cost) as boolean
isObjectOwner(obj.owner) as boolean &&
isSuiObjectRef(obj.reference) as boolean
)
}
export function isOwnedObjectRef(obj: any, _argumentName?: string): obj is OwnedObjectRef {
return (
Array.isArray(obj) &&
isRawObjectRef(obj[0]) as boolean &&
isObjectOwner(obj[1]) as boolean
)
}
export function isTransactionEffects(obj: any, _argumentName?: string): obj is TransactionEffects {

@@ -440,36 +397,44 @@ return (

isExecutionStatus(obj.status) as boolean &&
Array.isArray(obj.shared_objects) &&
obj.shared_objects.every((e: any) =>
isRawObjectRef(e) as boolean
) &&
isTransactionDigest(obj.transaction_digest) as boolean &&
Array.isArray(obj.created) &&
obj.created.every((e: any) =>
isOwnedObjectRef(e) as boolean
) &&
Array.isArray(obj.mutated) &&
obj.mutated.every((e: any) =>
isOwnedObjectRef(e) as boolean
) &&
Array.isArray(obj.unwrapped) &&
obj.unwrapped.every((e: any) =>
isOwnedObjectRef(e) as boolean
) &&
Array.isArray(obj.deleted) &&
obj.deleted.every((e: any) =>
isRawObjectRef(e) as boolean
) &&
Array.isArray(obj.wrapped) &&
obj.wrapped.every((e: any) =>
isRawObjectRef(e) as boolean
) &&
isOwnedObjectRef(obj.gas_object) as boolean &&
Array.isArray(obj.events) &&
obj.events.every((e: any) =>
isEvent(e) as boolean
) &&
Array.isArray(obj.dependencies) &&
obj.dependencies.every((e: any) =>
isTransactionDigest(e) as boolean
)
(typeof obj.sharedObjects === "undefined" ||
Array.isArray(obj.sharedObjects) &&
obj.sharedObjects.every((e: any) =>
isSuiObjectRef(e) as boolean
)) &&
isTransactionDigest(obj.transactionDigest) as boolean &&
(typeof obj.created === "undefined" ||
Array.isArray(obj.created) &&
obj.created.every((e: any) =>
isOwnedObjectRef(e) as boolean
)) &&
(typeof obj.mutated === "undefined" ||
Array.isArray(obj.mutated) &&
obj.mutated.every((e: any) =>
isOwnedObjectRef(e) as boolean
)) &&
(typeof obj.unwrapped === "undefined" ||
Array.isArray(obj.unwrapped) &&
obj.unwrapped.every((e: any) =>
isOwnedObjectRef(e) as boolean
)) &&
(typeof obj.deleted === "undefined" ||
Array.isArray(obj.deleted) &&
obj.deleted.every((e: any) =>
isSuiObjectRef(e) as boolean
)) &&
(typeof obj.wrapped === "undefined" ||
Array.isArray(obj.wrapped) &&
obj.wrapped.every((e: any) =>
isSuiObjectRef(e) as boolean
)) &&
isOwnedObjectRef(obj.gasObject) as boolean &&
(typeof obj.events === "undefined" ||
Array.isArray(obj.events) &&
obj.events.every((e: any) =>
isEvent(e) as boolean
)) &&
(typeof obj.dependencies === "undefined" ||
Array.isArray(obj.dependencies) &&
obj.dependencies.every((e: any) =>
isTransactionDigest(e) as boolean
))
)

@@ -505,10 +470,2 @@ }

export function isMoveModulePublish(obj: any, _argumentName?: string): obj is MoveModulePublish {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function")
)
}
export function isEvent(obj: any, _argumentName?: string): obj is Event {

@@ -519,44 +476,6 @@ return (

typeof obj === "function") &&
isStructTag(obj.type_) as boolean &&
isTransactionDigest(obj.contents) as boolean
isTransactionDigest(obj.type_) as boolean
)
}
export function isStructTag(obj: any, _argumentName?: string): obj is StructTag {
return (
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.address) as boolean &&
isTransactionDigest(obj.module) as boolean &&
isTransactionDigest(obj.name) as boolean &&
Array.isArray(obj.type_args) &&
obj.type_args.every((e: any) =>
isMoveTypeTag(e) as boolean
)
)
}
export function isMoveTypeTag(obj: any, _argumentName?: string): obj is MoveTypeTag {
return (
(obj === "bool" ||
obj === "u8" ||
obj === "u64" ||
obj === "u128" ||
obj === "address" ||
obj === "signer" ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
Array.isArray(obj.vector) &&
obj.vector.every((e: any) =>
isMoveTypeTag(e) as boolean
) ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isStructTag(obj.struct) as boolean)
)
}
export function isMoveCall(obj: any, _argumentName?: string): obj is MoveCall {

@@ -567,33 +486,31 @@ return (

typeof obj === "function") &&
isRawObjectRef(obj.package) as boolean &&
isSuiObjectRef(obj.package) as boolean &&
isTransactionDigest(obj.module) as boolean &&
isTransactionDigest(obj.function) as boolean &&
Array.isArray(obj.type_arguments) &&
obj.type_arguments.every((e: any) =>
isMoveTypeTag(e) as boolean
) &&
Array.isArray(obj.arguments) &&
obj.arguments.every((e: any) =>
isMoveCallArg(e) as boolean
)
(typeof obj.typeArguments === "undefined" ||
Array.isArray(obj.typeArguments) &&
obj.typeArguments.every((e: any) =>
isTransactionDigest(e) as boolean
)) &&
(typeof obj.arguments === "undefined" ||
Array.isArray(obj.arguments) &&
obj.arguments.every((e: any) =>
isSuiJsonValue(e) as boolean
))
)
}
export function isMoveCallArg(obj: any, _argumentName?: string): obj is MoveCallArg {
export function isSuiJsonValue(obj: any, _argumentName?: string): obj is SuiJsonValue {
return (
((obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
Array.isArray(obj.Pure) &&
obj.Pure.every((e: any) =>
isSequenceNumber(e) as boolean
) ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isRawObjectRef(obj.ImmOrOwnedObject) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.SharedObject) as boolean)
(isTransactionDigest(obj) as boolean ||
isSequenceNumber(obj) as boolean ||
obj === false ||
obj === true ||
Array.isArray(obj) &&
obj.every((e: any) =>
(isTransactionDigest(e) as boolean ||
isSequenceNumber(e) as boolean ||
e === false ||
e === true)
))
)

@@ -625,7 +542,8 @@ }

typeof obj === "function") &&
isTransactionDigest(obj.tx_bytes) as boolean
isTransactionDigest(obj.txBytes) as boolean &&
isSuiObjectRef(obj.gas) as boolean
)
}
export function isTransactionResponse(obj: any, _argumentName?: string): obj is TransactionResponse {
export function isSplitCoinResponse(obj: any, _argumentName?: string): obj is SplitCoinResponse {
return (

@@ -635,15 +553,23 @@ (obj !== null &&

typeof obj === "function") &&
isTransactionEffectsResponse(obj.EffectResponse) as boolean
isCertifiedTransaction(obj.certificate) as boolean &&
isSuiObject(obj.updatedCoin) as boolean &&
Array.isArray(obj.newCoins) &&
obj.newCoins.every((e: any) =>
isSuiObject(e) as boolean
) &&
isSuiObject(obj.updatedGas) as boolean
)
}
export function isSignedTransaction(obj: any, _argumentName?: string): obj is SignedTransaction {
export function isTransactionResponse(obj: any, _argumentName?: string): obj is TransactionResponse {
return (
(obj !== null &&
((obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isTransactionDigest(obj.tx_bytes) as boolean &&
isTransactionDigest(obj.signature) as boolean &&
isTransactionDigest(obj.pub_key) as boolean
isTransactionEffectsResponse(obj.EffectResponse) as boolean ||
(obj !== null &&
typeof obj === "object" ||
typeof obj === "function") &&
isSplitCoinResponse(obj.SplitCoinResponse) as boolean)
)
}

@@ -14,13 +14,10 @@ // Copyright (c) 2022, Mysten Labs, Inc.

import {
CertifiedTransaction,
GatewayTxSeqNumber,
GetTxnDigestsResponse,
GetObjectInfoResponse,
ObjectRef,
SuiObjectRef,
TransactionDigest,
TransactionEffectsResponse,
SignedTransaction,
TransactionResponse,
} from '../types';
import { transformGetObjectInfoResponse } from '../types/framework/transformer';

@@ -43,3 +40,3 @@ const isNumber = (val: any): val is number => typeof val === 'number';

// Objects
async getOwnedObjectRefs(address: string): Promise<ObjectRef[]> {
async getOwnedObjectRefs(address: string): Promise<SuiObjectRef[]> {
try {

@@ -61,8 +58,7 @@ const resp = await this.client.requestWithType(

try {
const resp = await this.client.requestWithType(
'sui_getObjectTypedInfo',
return await this.client.requestWithType(
'sui_getObjectInfo',
[objectId],
isGetObjectInfoResponse
);
return transformGetObjectInfoResponse(resp);
} catch (err) {

@@ -77,11 +73,10 @@ throw new Error(`Error fetching object info: ${err} for id ${objectId}`);

const requests = objectIds.map(id => ({
method: 'sui_getObjectTypedInfo',
method: 'sui_getObjectInfo',
args: [id],
}));
try {
const responses = await this.client.batchRequestWithType(
return await this.client.batchRequestWithType(
requests,
isGetObjectInfoResponse
);
return responses.map(r => transformGetObjectInfoResponse(r));
} catch (err) {

@@ -130,19 +125,6 @@ throw new Error(`Error fetching object info: ${err} for id ${objectIds}`);

async getTransaction(
digest: TransactionDigest
): Promise<CertifiedTransaction> {
try {
const resp = await this.client.requestWithType(
'sui_getTransaction',
[digest],
isTransactionEffectsResponse
);
return resp.certificate;
} catch (err) {
throw new Error(`Error getting transaction: ${err} for digest ${digest}`);
}
}
async executeTransaction(
txn: SignedTransaction
txnBytes: string,
signature: string,
pubkey: string
): Promise<TransactionResponse> {

@@ -152,3 +134,3 @@ try {

'sui_executeTransaction',
[txn],
[txnBytes, signature, pubkey],
isTransactionResponse

@@ -158,5 +140,3 @@ );

} catch (err) {
throw new Error(
`Error executing transaction: ${err} for txn ${JSON.stringify(txn)}`
);
throw new Error(`Error executing transaction: ${err}}`);
}

@@ -163,0 +143,0 @@ }

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

GetObjectInfoResponse,
ObjectRef,
SuiObjectRef,
GatewayTxSeqNumber,
GetTxnDigestsResponse,
TransactionResponse,
SignedTransaction,
} from '../types';

@@ -21,3 +20,3 @@

*/
abstract getOwnedObjectRefs(address: string): Promise<ObjectRef[]>;
abstract getOwnedObjectRefs(address: string): Promise<SuiObjectRef[]>;

@@ -54,3 +53,5 @@ /**

abstract executeTransaction(
txn: SignedTransaction
txnBytes: string,
signature: string,
pubkey: string
): Promise<TransactionResponse>;

@@ -57,0 +58,0 @@

@@ -9,5 +9,4 @@ // Copyright (c) 2022, Mysten Labs, Inc.

GatewayTxSeqNumber,
ObjectRef,
SuiObjectRef,
GetObjectInfoResponse,
SignedTransaction,
TransactionResponse,

@@ -19,3 +18,3 @@ } from '../types';

// Objects
async getOwnedObjectRefs(_address: string): Promise<ObjectRef[]> {
async getOwnedObjectRefs(_address: string): Promise<SuiObjectRef[]> {
throw this.newError('getOwnedObjectRefs');

@@ -36,3 +35,5 @@ }

async executeTransaction(
_txn: SignedTransaction
_txnBytes: string,
_signature: string,
_pubkey: string
): Promise<TransactionResponse> {

@@ -39,0 +40,0 @@ throw this.newError('executeTransaction');

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

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

@@ -49,4 +50,10 @@ /**

const text = await res.text();
const result = JSON.stringify(LosslessJSON.parse(text, (key : string, value : any) => {
if (key === "balance") return value.toString();
if (value.isLosslessNumber) return value.valueOf();
return value;
}
));
if (res.ok) {
callback(null, text);
callback(null, result);
} else {

@@ -53,0 +60,0 @@ callback(new Error(`${res.status} ${res.statusText}: ${text}`));

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

const sig = await this.signData(txBytes);
return await this.provider.executeTransaction({
tx_bytes: txBytes.toString(),
signature: sig.signature.toString(),
pub_key: sig.pubKey.toString(),
});
return await this.provider.executeTransaction(
txBytes.toString(),
sig.signature.toString(),
sig.pubKey.toString()
);
}

@@ -65,0 +65,0 @@

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

);
return new Base64DataBuffer(resp.tx_bytes);
return new Base64DataBuffer(resp.txBytes);
} catch (err) {

@@ -41,0 +41,0 @@ throw new Error(`Error transferring coin: ${err}`);

// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import { Base64DataBuffer } from "../serialization/base64";
/** Base64 string representing the object digest */
export type TransactionDigest = string;

@@ -11,1 +14,40 @@ export type SuiAddress = string;

| 'Immutable';
// source of truth is
// https://github.com/MystenLabs/sui/blob/acb2b97ae21f47600e05b0d28127d88d0725561d/crates/sui-types/src/base_types.rs#L171
const TX_DIGEST_LENGTH = 32;
// taken from https://rgxdb.com/r/1NUN74O6
const VALID_BASE64_REGEX =
/^(?:[a-zA-Z0-9+\/]{4})*(?:|(?:[a-zA-Z0-9+\/]{3}=)|(?:[a-zA-Z0-9+\/]{2}==)|(?:[a-zA-Z0-9+\/]{1}===))$/;
export function isValidTransactionDigest(value: string): value is TransactionDigest {
return new Base64DataBuffer(value).getLength() === TX_DIGEST_LENGTH
&& VALID_BASE64_REGEX.test(value);
}
// TODO - can we automatically sync this with rust length definition?
// Source of truth is
// https://github.com/MystenLabs/sui/blob/acb2b97ae21f47600e05b0d28127d88d0725561d/crates/sui-types/src/base_types.rs#L67
// which uses the Move account address length
// https://github.com/move-language/move/blob/67ec40dc50c66c34fd73512fcc412f3b68d67235/language/move-core/types/src/account_address.rs#L23 .
const SUI_ADDRESS_LENGTH = 20;
export function isValidSuiAddress(value: string): value is SuiAddress {
return isHex(value) &&
getHexByteLength(value) === SUI_ADDRESS_LENGTH;
}
export function isValidSuiObjectId(value: string): boolean {
return isValidSuiAddress(value);
}
function isHex(value: string): boolean {
return /^(0x|0X)?[a-fA-F0-9]+$/.test(value) && value.length % 2 === 0;
}
function getHexByteLength(value: string): number {
return /^(0x|0X)/.test(value)
? (value.length - 2) / 2
: value.length / 2;
}

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

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

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

export type ObjectRef = {
export type SuiObjectRef = {
/** Base64 string representing the object digest */
digest: TransactionDigest;
/** Hex code as string representing the object id */
objectId: string;
/** Object version */
version: number;
};
export type ObjectContentField =
| ObjectContent
| string
| boolean
| number
| number[]
| ObjectContent[];
export type ObjectContentFields = Record<string, any>;
export type ObjectContentFields = Record<string, ObjectContentField>;
export type MovePackageContent = Record<string, string>;
export type ObjectContent = {
export type SuiData = { dataType: ObjectType } & (
| SuiMoveObject
| SuiMovePackage
);
export type SuiMoveObject = {
/** Move type (e.g., "0x2::Coin::Coin<0x2::SUI::SUI>") */
type: string;
/** Fields and values stored inside the Move object */
fields: ObjectContentFields;
type: string;
};
export type MovePackageContent = Record<string, string>;
export type SuiMovePackage = {
/** A mapping from module name to disassembled Move bytecode */
disassembled: MovePackageContent;
};
export type SuiObject = {
contents: ObjectContent | MovePackageContent;
/** The meat of the object */
data: SuiData;
/** The owner of the object */
owner: ObjectOwner;
tx_digest: TransactionDigest;
/** The digest of the transaction that created or last mutated this object */
previousTransaction: TransactionDigest;
/**
* The amount of SUI we would rebate if this object gets deleted.
* This number is re-calculated each time the object is mutated based on
* the present storage gas price.
*/
storageRebate: number;
reference: SuiObjectRef;
};
export type ObjectExistsInfo = {
objectRef: ObjectRef;
objectType: ObjectType;
object: SuiObject;
};
export type ObjectNotExistsInfo = {
objectId: ObjectId;
};
export type ObjectStatus = 'Exists' | 'NotExists' | 'Deleted';
export type ObjectType = 'moveObject' | 'movePackage';
export type ObjectType = 'moveObject' | 'package';
export type GetOwnedObjectRefsResponse = {
objects: ObjectRef[];
objects: SuiObjectRef[];
};

@@ -56,3 +63,3 @@

status: ObjectStatus;
details: ObjectExistsInfo | ObjectNotExistsInfo | ObjectRef;
details: SuiObject | ObjectId | SuiObjectRef;
};

@@ -64,45 +71,109 @@

// TODO: get rid of this by implementing some conversion logic from ObjectRef
export type RawObjectRef = [ObjectId, SequenceNumber, ObjectDigest];
/* -------------------------------------------------------------------------- */
/* Helper functions */
/* -------------------------------------------------------------------------- */
/* ---------------------------- Helper functions ---------------------------- */
/* -------------------------- GetObjectInfoResponse ------------------------- */
export function getObjectExistsResponse(
resp: GetObjectInfoResponse
): ObjectExistsInfo | undefined {
return resp.status !== 'Exists'
? undefined
: (resp.details as ObjectExistsInfo);
): SuiObject | undefined {
return resp.status !== 'Exists' ? undefined : (resp.details as SuiObject);
}
export function getObjectDeletedResponse(
resp: GetObjectInfoResponse
): SuiObjectRef | undefined {
return resp.status !== 'Deleted' ? undefined : (resp.details as SuiObjectRef);
}
export function getObjectNotExistsResponse(
resp: GetObjectInfoResponse
): ObjectId | undefined {
return resp.status !== 'NotExists' ? undefined : (resp.details as ObjectId);
}
export function getObjectReference(
resp: GetObjectInfoResponse
): SuiObjectRef | undefined {
return (
getObjectExistsResponse(resp)?.reference || getObjectDeletedResponse(resp)
);
}
/* ------------------------------ SuiObjectRef ------------------------------ */
export function getObjectId(
data: GetObjectInfoResponse | SuiObjectRef
): ObjectId {
if ('objectId' in data) {
return data.objectId;
}
return (
getObjectReference(data)?.objectId ?? getObjectNotExistsResponse(data)!
);
}
export function getObjectVersion(
data: GetObjectInfoResponse | SuiObjectRef
): number | undefined {
if ('version' in data) {
return data.version;
}
return getObjectReference(data)?.version;
}
/* -------------------------------- SuiObject ------------------------------- */
export function getObjectType(
resp: GetObjectInfoResponse
): 'moveObject' | 'movePackage' | undefined {
return getObjectExistsResponse(resp)?.objectType;
): ObjectType | undefined {
return getObjectExistsResponse(resp)?.data.dataType;
}
export function getObjectContent(
export function getObjectPreviousTransactionDigest(
resp: GetObjectInfoResponse
): ObjectContent | undefined {
const existsInfo = getObjectExistsResponse(resp);
if (existsInfo == null) {
): TransactionDigest | undefined {
return getObjectExistsResponse(resp)?.previousTransaction;
}
export function getObjectOwner(
resp: GetObjectInfoResponse
): ObjectOwner | undefined {
return getObjectExistsResponse(resp)?.owner;
}
export function getMoveObjectType(
resp: GetObjectInfoResponse
): string | undefined {
return getMoveObject(resp)?.type;
}
export function getObjectFields(
resp: GetObjectInfoResponse
): ObjectContentFields | undefined {
return getMoveObject(resp)?.fields;
}
export function getMoveObject(
resp: GetObjectInfoResponse
): SuiMoveObject | undefined {
const suiObject = getObjectExistsResponse(resp);
if (suiObject?.data.dataType !== 'moveObject') {
return undefined;
}
const { object, objectType } = existsInfo;
return objectType === 'moveObject'
? (object.contents as ObjectContent)
: undefined;
return suiObject.data as SuiMoveObject;
}
export function getMovePackageContent(
resp: GetObjectInfoResponse
data: GetObjectInfoResponse | SuiMovePackage
): MovePackageContent | undefined {
const existsInfo = getObjectExistsResponse(resp);
if (existsInfo == null) {
if ('disassembled' in data) {
return data.disassembled;
}
const suiObject = getObjectExistsResponse(data);
if (suiObject?.data.dataType !== 'package') {
return undefined;
}
const { object, objectType } = existsInfo;
return objectType === 'movePackage'
? (object.contents as MovePackageContent)
: undefined;
return (suiObject.data as SuiMovePackage).disassembled;
}

@@ -5,23 +5,20 @@ // Copyright (c) 2022, Mysten Labs, Inc.

import { ObjectOwner, SuiAddress, TransactionDigest } from './common';
import { ObjectId, RawObjectRef } from './objects';
import { SuiMovePackage, SuiObject, SuiObjectRef } from './objects';
export type Transfer = {
recipient: string;
object_ref: RawObjectRef;
export type TransferCoin = {
recipient: SuiAddress;
objectRef: SuiObjectRef;
};
export type RawAuthoritySignInfo = [AuthorityName, AuthoritySignature];
export type TransactionKindName = 'Transfer' | 'Publish' | 'Call';
export type SingleTransactionKind =
| { Transfer: Transfer }
| { Publish: MoveModulePublish }
export type TransactionKindName = 'TransferCoin' | 'Publish' | 'Call';
export type SuiTransactionKind =
| { TransferCoin: TransferCoin }
| { Publish: SuiMovePackage }
| { Call: MoveCall };
export type TransactionKind =
| { Single: SingleTransactionKind }
| { Batch: SingleTransactionKind[] };
export type TransactionData = {
kind: TransactionKind;
sender: string;
gas_payment: RawObjectRef;
gas_budget: number;
transactions: SuiTransactionKind[];
sender: SuiAddress;
gasPayment: SuiObjectRef;
gasBudget: number;
};

@@ -38,35 +35,57 @@

export type CertifiedTransaction = {
transactionDigest: TransactionDigest;
data: TransactionData;
tx_signature: string;
auth_sign_info: AuthorityQuorumSignInfo;
txSignature: string;
authSignInfo: AuthorityQuorumSignInfo;
};
export type GasCostSummary = {
computation_cost: number;
storage_cost: number;
storage_rebate: number;
computationCost: number;
storageCost: number;
storageRebate: number;
};
export type ExecutionStatusType = 'Success' | 'Failure';
export type ExecutionStatus =
| { Success: ExecutionStatusDetail }
| { Failure: ExecutionStatusDetail };
export type ExecutionStatusType = 'success' | 'failure';
export type ExecutionStatus = {
status: ExecutionStatusType;
gas_cost: GasCostSummary;
error?: string;
};
export type ExecutionStatusDetail = { gas_cost: GasCostSummary; error?: any };
// TODO: change the tuple to struct from the server end
export type OwnedObjectRef = [RawObjectRef, ObjectOwner];
export type OwnedObjectRef = {
owner: ObjectOwner;
reference: SuiObjectRef;
};
export type TransactionEffects = {
/** The status of the execution */
status: ExecutionStatus;
shared_objects: RawObjectRef[];
transaction_digest: TransactionDigest;
created: OwnedObjectRef[];
mutated: OwnedObjectRef[];
unwrapped: OwnedObjectRef[];
deleted: RawObjectRef[];
wrapped: RawObjectRef[];
gas_object: OwnedObjectRef;
events: Event[];
dependencies: TransactionDigest[];
/** The object references of the shared objects used in this transaction. Empty if no shared objects were used. */
sharedObjects?: SuiObjectRef[];
/** The transaction digest */
transactionDigest: TransactionDigest;
/** ObjectRef and owner of new objects created */
created?: OwnedObjectRef[];
/** ObjectRef and owner of mutated objects, including gas object */
mutated?: OwnedObjectRef[];
/**
* ObjectRef and owner of objects that are unwrapped in this transaction.
* Unwrapped objects are objects that were wrapped into other objects in the past,
* and just got extracted out.
*/
unwrapped?: OwnedObjectRef[];
/** Object Refs of objects now deleted (the old refs) */
deleted?: SuiObjectRef[];
/** Object refs of objects now wrapped in other objects */
wrapped?: SuiObjectRef[];
/**
* The updated gas object reference. Have a dedicated field for convenient access.
* It's also included in mutated.
*/
gasObject: OwnedObjectRef;
/** The events emitted during execution. Note that only successful transactions emit events */
events?: Event[];
/** The set of transaction digests this transaction depends on */
dependencies?: TransactionDigest[];
};

@@ -83,40 +102,20 @@

export type MoveModulePublish = {
modules: any;
};
export type Event = {
type_: StructTag;
contents: string;
type_: string;
contents: any;
};
export type StructTag = {
address: SuiAddress;
module: string;
name: string;
type_args: MoveTypeTag[];
};
export type MoveTypeTag =
| 'bool'
| 'u8'
| 'u64'
| 'u128'
| 'address'
| 'signer'
| { vector: MoveTypeTag[] }
| { struct: StructTag };
export type MoveCall = {
package: RawObjectRef;
package: SuiObjectRef;
module: string;
function: string;
type_arguments: MoveTypeTag[];
arguments: MoveCallArg[];
typeArguments?: string[];
arguments?: SuiJsonValue[];
};
export type MoveCallArg =
// TODO: convert to Uint8Array
| { Pure: number[] }
| { ImmOrOwnedObject: RawObjectRef }
| { SharedObject: ObjectId };
export type SuiJsonValue =
| boolean
| number
| string
| Array<boolean | number | string>;

@@ -128,87 +127,127 @@ export type EmptySignInfo = object;

export type TransactionBytes = {
tx_bytes: string;
txBytes: string;
gas: SuiObjectRef;
// TODO: Add input_objects field
};
export type TransactionResponse = {
EffectResponse: TransactionEffectsResponse;
// TODO: Add Publish, MergeCoin, SplitCoin Response
export type SplitCoinResponse = {
certificate: CertifiedTransaction;
updatedCoin: SuiObject;
newCoins: SuiObject[];
updatedGas: SuiObject;
};
export type SignedTransaction = {
tx_bytes: string;
signature: string;
pub_key: string;
};
export type TransactionResponse =
| {
EffectResponse: TransactionEffectsResponse;
// TODO: Add Publish, MergeCoin Response
}
| {
SplitCoinResponse: SplitCoinResponse;
};
/* ---------------------------- Helper functions ---------------------------- */
/* -------------------------------------------------------------------------- */
/* Helper functions */
/* -------------------------------------------------------------------------- */
export function getSingleTransactionKind(
data: TransactionData
): SingleTransactionKind | undefined {
return 'Single' in data.kind ? data.kind.Single : undefined;
/* ---------------------------------- CertifiedTransaction --------------------------------- */
export function getTransactionDigest(
tx: CertifiedTransaction
): TransactionDigest {
return tx.transactionDigest;
}
export function getTransferTransaction(
data: TransactionData
): Transfer | undefined {
const tx = getSingleTransactionKind(data);
return tx && 'Transfer' in tx ? tx.Transfer : undefined;
export function getTransactionSignature(tx: CertifiedTransaction): string {
return tx.txSignature;
}
export function getTransactionAuthorityQuorumSignInfo(
tx: CertifiedTransaction
): AuthorityQuorumSignInfo {
return tx.authSignInfo;
}
export function getTransactionData(tx: CertifiedTransaction): TransactionData {
return tx.data;
}
/* ----------------------------- TransactionData ---------------------------- */
export function getTransactionSender(tx: CertifiedTransaction): SuiAddress {
return tx.data.sender;
}
export function getTransactionGasObject(
tx: CertifiedTransaction
): SuiObjectRef {
return tx.data.gasPayment;
}
export function getTransactionGasBudget(tx: CertifiedTransaction): number {
return tx.data.gasBudget;
}
export function getTransferCoinTransaction(
data: SuiTransactionKind
): TransferCoin | undefined {
return 'TransferCoin' in data ? data.TransferCoin : undefined;
}
export function getPublishTransaction(
data: TransactionData
): MoveModulePublish | undefined {
const tx = getSingleTransactionKind(data);
return tx && 'Publish' in tx ? tx.Publish : undefined;
data: SuiTransactionKind
): SuiMovePackage | undefined {
return 'Publish' in data ? data.Publish : undefined;
}
export function getMoveCallTransaction(
data: TransactionData
data: SuiTransactionKind
): MoveCall | undefined {
const tx = getSingleTransactionKind(data);
return tx && 'Call' in tx ? tx.Call : undefined;
return 'Call' in data ? data.Call : undefined;
}
export function getTransactionKind(
data: TransactionData
): TransactionKindName | undefined {
const tx = getSingleTransactionKind(data);
return tx && (Object.keys(tx)[0] as TransactionKindName);
export function getTransactions(
data: CertifiedTransaction
): SuiTransactionKind[] {
return data.data.transactions;
}
export function getTransactionKindName(
data: SuiTransactionKind
): TransactionKindName {
return Object.keys(data)[0] as TransactionKindName;
}
/* ----------------------------- ExecutionStatus ---------------------------- */
export function getExecutionStatusType(
data: ExecutionStatus
data: TransactionEffectsResponse
): ExecutionStatusType {
return Object.keys(data)[0] as ExecutionStatusType;
return getExecutionStatus(data).status;
}
export function getGasSummary(
data: ExecutionStatus
): GasCostSummary | undefined {
const details = getExecutionDetails(data);
return details.gas_cost;
export function getExecutionStatus(
data: TransactionEffectsResponse
): ExecutionStatus {
return data.effects.status;
}
export function getTotalGasUsed(data: ExecutionStatus): number {
const gasSummary = getGasSummary(data);
if (gasSummary) {
return (
gasSummary.computation_cost +
gasSummary.storage_cost -
gasSummary.storage_rebate
);
}
return 0;
export function getExecutionStatusError(
data: TransactionEffectsResponse
): string | undefined {
return getExecutionStatus(data).error;
}
export function getExecutionDetails(
data: ExecutionStatus
): ExecutionStatusDetail {
if ('Success' in data) {
return data.Success;
} else if ('Failure' in data) {
return data.Failure;
}
console.error('Unrecognized ExecutionStatus:', data);
return data[Object.keys(data)[0]];
export function getExecutionStatusGasSummary(
data: TransactionEffectsResponse
): GasCostSummary {
return getExecutionStatus(data).gas_cost;
}
export function getTotalGasUsed(data: TransactionEffectsResponse): number {
const gasSummary = getExecutionStatusGasSummary(data);
return (
gasSummary.computationCost +
gasSummary.storageCost -
gasSummary.storageRebate
);
}

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