@sentio/sdk-bundle 2.49.2-rc.2 → 2.49.2-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/builtin/0x1.js +1 -1
- package/lib/aptos/builtin/0x3.js +1 -1
- package/lib/aptos/builtin/index.js +1 -1
- package/lib/aptos/ext/index.js +1 -1
- package/lib/aptos/index.js +1 -1
- package/lib/{chunk-AEXPFSZQ.js → chunk-2B2RSH3Y.js} +2 -2
- package/lib/{chunk-TYWY25UG.js → chunk-3GUIO5OF.js} +2 -2
- package/lib/{chunk-3BHU56W3.js → chunk-7PAQ7K22.js} +2 -2
- package/lib/chunk-DKVRT424.js +32 -0
- package/lib/chunk-DKVRT424.js.map +1 -0
- package/lib/{chunk-JVP4PFU3.js → chunk-DWTPG7UW.js} +2 -2
- package/lib/{chunk-KPTDZ23T.js → chunk-EKXFEQWX.js} +2 -2
- package/lib/{chunk-4QKCXVZ6.js → chunk-F4PI3N5U.js} +3 -3
- package/lib/{chunk-4QKCXVZ6.js.map → chunk-F4PI3N5U.js.map} +1 -1
- package/lib/{chunk-YTLGKVK3.js → chunk-JBPAJGUO.js} +2 -2
- package/lib/{chunk-727HJVMP.js → chunk-LQM7SOMQ.js} +2 -2
- package/lib/{chunk-WA73HXRI.js → chunk-OCRFQUIW.js} +2 -2
- package/lib/{chunk-6AGMINR4.js → chunk-SA6HIJSW.js} +2 -2
- package/lib/{chunk-N3ACVYCC.js → chunk-T6AFNQ3Z.js} +2 -2
- package/lib/{chunk-CB3VB5IQ.js → chunk-TVVM3NEA.js} +2 -2
- package/lib/eth/builtin/eacaggregatorproxy.js +1 -1
- package/lib/eth/builtin/erc1155.js +1 -1
- package/lib/eth/builtin/erc20.js +1 -1
- package/lib/eth/builtin/erc721.js +1 -1
- package/lib/eth/builtin/index.js +1 -1
- package/lib/eth/builtin/weth9.js +1 -1
- package/lib/eth/index.js +1 -1
- package/lib/sui/builtin/0x1.js +1 -1
- package/lib/sui/builtin/0x2.js +1 -1
- package/lib/sui/builtin/0x3.js +1 -1
- package/lib/sui/builtin/index.js +1 -1
- package/lib/sui/ext/index.js +1 -1
- package/lib/sui/index.js +1 -1
- package/lib/testing/index.js +1 -1
- package/lib/utils/index.js +1 -1
- package/package.json +2 -2
- package/lib/chunk-MFVR3UY7.js +0 -32
- package/lib/chunk-MFVR3UY7.js.map +0 -1
- /package/lib/{chunk-AEXPFSZQ.js.map → chunk-2B2RSH3Y.js.map} +0 -0
- /package/lib/{chunk-TYWY25UG.js.map → chunk-3GUIO5OF.js.map} +0 -0
- /package/lib/{chunk-3BHU56W3.js.map → chunk-7PAQ7K22.js.map} +0 -0
- /package/lib/{chunk-JVP4PFU3.js.map → chunk-DWTPG7UW.js.map} +0 -0
- /package/lib/{chunk-KPTDZ23T.js.map → chunk-EKXFEQWX.js.map} +0 -0
- /package/lib/{chunk-YTLGKVK3.js.map → chunk-JBPAJGUO.js.map} +0 -0
- /package/lib/{chunk-727HJVMP.js.map → chunk-LQM7SOMQ.js.map} +0 -0
- /package/lib/{chunk-WA73HXRI.js.map → chunk-OCRFQUIW.js.map} +0 -0
- /package/lib/{chunk-6AGMINR4.js.map → chunk-SA6HIJSW.js.map} +0 -0
- /package/lib/{chunk-N3ACVYCC.js.map → chunk-T6AFNQ3Z.js.map} +0 -0
- /package/lib/{chunk-CB3VB5IQ.js.map → chunk-TVVM3NEA.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{a as ve,b as je,c as B,e as xe,f as O,g as A,i as Ae}from"./chunk-JVP4PFU3.js";import{B as ie,C as ye,a as m,d as K,f as R,i as we,m as I,n as H,o as oe,u as Te,v as Ie,w as Y}from"./chunk-MCICASJD.js";import{a as Re}from"./chunk-2NOM7BGS.js";import{D as C,Kd as q,Tc as J,W as Ce,fa as Oe,jd as W,x as j,za as x}from"./chunk-BBD4HNM4.js";import{a,f as D}from"./chunk-G5BIPHMS.js";import{ListStateStorage as Ve,mergeProcessResults as Ue}from"@sentio/runtime";var p=D(W(),1);var Ye="0x0000000000000000000000000000000000000000000000000000000000000000";function f(n){return typeof n!="object"||n==null?!1:n.$kind==="GasCoin"||n.$kind==="Result"||n.$kind==="NestedResult"||n.$kind==="Input"}a(f,"isTransactionArgument");function Ze(n,e){return f(n)?n:e.object(n)}a(Ze,"transactionArgumentOrObject");function ze(n,e){return f(n)?n:typeof n=="string"?e.pure.string(n):e.pure.u64(n)}a(ze,"transactionArgumentOrPure");function Xe(n,e){return f(n)?n:e.pure.address(n)}a(Xe,"transactionArgumentOrPureAddress");function et(n,e){return f(n)?n:e.pure.u8(n)}a(et,"transactionArgumentOrPureU8");function tt(n,e){return f(n)?n:e.pure.u16(n)}a(tt,"transactionArgumentOrPureU16");function nt(n,e){return f(n)?n:e.pure.u32(n)}a(nt,"transactionArgumentOrPureU32");function rt(n,e){return f(n)?n:e.pure.u64(n)}a(rt,"transactionArgumentOrPureU64");function st(n,e){return f(n)?n:e.pure.u128(n)}a(st,"transactionArgumentOrPureU128");function ot(n,e){return f(n)?n:e.pure.u256(n)}a(ot,"transactionArgumentOrPureU256");function it(n,e){return f(n)?n:e.pure.bool(n)}a(it,"transactionArgumentOrPureBool");function at(n,e){return f(n)?n:e.makeMoveVec({elements:n.map(t=>e.object(t))})}a(at,"transactionArgumentOrVec");function Q(n){return{address:n.address,exposedFunctions:Object.entries(n.exposedFunctions).map(([e,t])=>He(e,t)),name:n.name,structs:Object.entries(n.structs).map(([e,t])=>Be(e,t))}}a(Q,"toInternalModule");function He(n,e){let t;switch(e.visibility){case"Private":t=Y.PRIVATE;break;case"Public":t=Y.PUBLIC;break;case"Friend":t=Y.FRIEND;break;default:throw Error("No visibility for function"+n)}return{typeParams:e.typeParameters.map(r=>({constraints:r.abilities})),isEntry:e.isEntry,name:n,params:e.parameters.map(y),return:e.return.map(y),visibility:t}}a(He,"toInternalFunction");function Be(n,e){return{abilities:e.abilities.abilities,fields:e.fields.map(Fe),typeParams:e.typeParameters.map(t=>({constraints:t.constraints.abilities})),isNative:!1,isEvent:!1,name:n}}a(Be,"toInternalStruct");function Fe(n){return{name:n.name,type:y(n.type)}}a(Fe,"toInternalField");function y(n){if(typeof n=="string")return new I(n);if("Struct"in n){let e=[n.Struct.address,n.Struct.module,n.Struct.name].join(m),t=n.Struct.typeArguments.map(y);return new I(e,t)}if("Vector"in n)return new I("Vector",[y(n.Vector)]);if("TypeParameter"in n)return new I("T"+n.TypeParameter);if("Reference"in n){let e=y(n.Reference);return e.reference=!0,e}if("MutableReference"in n){let e=y(n.MutableReference);return e.reference=!0,e.mutable=!0,e}throw new Error("Unexpected sui type")}a(y,"toTypeDescriptor");var Z=class extends Te{static{a(this,"SuiChainAdapter")}async getChainId(){return this.client.getChainIdentifier()}client;constructor(e){super(),this.client=e}async fetchModule(e,t){return await this.client.getNormalizedMoveModule({package:e,module:t})}async fetchModules(e){let t=await this.client.getNormalizedMoveModulesByPackage({package:e});return Object.values(t)}getMeaningfulFunctionParams(e){return e}toInternalModules(e){return Object.values(e).map(Q)}getAllEventStructs(e){let t=new Map;for(let r of e){let s=we(r);for(let o of r.structs){let i=new Set(o.abilities);i.has("Drop")&&i.has("Copy")&&t.set(s+m+o.name,o)}}return t}getType(e){return e.type}getData(e){if(e===void 0)throw Error("val is undefined");return"parsedJson"in e?e.parsedJson:e.dataType==="moveObject"||"fields"in e&&"type"in e&&Object.keys(e).length===2?e.fields:e}};var w=class extends Ie{static{a(this,"MoveCoder")}constructor(e){super(new Z(e))}load(e,t){let r=this.moduleMapping.get(e.address+"::"+e.name),s=this.moduleMapping.get(t+"::"+e.name);return r&&s||(r=Q(e),this.loadInternal(r,t)),r}async decode(e,t){switch(t.qname){case"0x1::ascii::Char":if(e!==void 0&&typeof e!="string"){let s=(await super.decode(e,t)).byte;return String.fromCharCode(s)}case"0x1::ascii::String":if(e!==void 0&&typeof e!="string"){let s=(await super.decode(e,t)).bytes;return new TextDecoder().decode(new Uint8Array(s))}case"0x2::object::ID":if(e!==void 0&&typeof e!="string"){let s=(await super.decode(e,t)).bytes;return je(s)}case"0x2::url::Url":if(e!==void 0&&typeof e!="string")return(await super.decode(e,t)).url;case"0x2::coin::Coin":if(e!==void 0&&typeof e!="string"){let s=(await super.decode(e,t)).id.id.bytes;return new TextDecoder().decode(new Uint8Array(s))}return e;case"0x2::balance::Balance":return e.value?(await super.decode(e,t)).value:BigInt(e);case"0x1::option::Option":if(e===null)return e;if(e.vec){let s=await super.decode(e,t);return s=s.vec,s.length===0?null:s[0]}return this.decode(e,t.typeArgs[0]);case"Address":return ve(e);case"0x1::string::String":if(typeof e!="string")return new TextDecoder().decode(new Uint8Array(e.bytes));default:return super.decode(e,t)}}decodeEvent(e){return this.decodedStruct(e)}filterAndDecodeEvents(e,t){return typeof e=="string"&&(e=H(e)),this.filterAndDecodeStruct(e,t)}async getDynamicFields(e,t=oe,r=oe){let s=new I("0x2::dynamic_field::Field");return s.typeArgs=[t,r],(await this.filterAndDecodeObjects(s,e)).map(i=>i.data_decoded)}filterAndDecodeObjects(e,t){return this.filterAndDecodeStruct(e,t)}async decodeFunctionPayload(e,t){let r=[e.package,e.module,e.function].join(m),s=await this.getMoveFunction(r),o=this.adapter.getMeaningfulFunctionParams(s.params),i=[];for(let c of e.arguments||[]){let d=c;if("Input"in d){let S=d.Input,h=t[S];h.type==="pure"?i.push(h.value):(h.type==="object"||console.error("unexpected function arg value"),i.push(void 0))}else i.push(void 0)}let u=await this.decodeArray(i,o,!1);return{...e,arguments_decoded:u}}bcsRegistered=new Set;bcsRegistry=new Map;async getBCSTypeWithArgs(e,t=[]){let r=e.qname,s=e.getNormalizedSignature(),o=this.bcsRegistry.get(s);if(o)return o;let i=r.toLowerCase();switch(i){case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":case"bool":return B[i]();case"address":return B.Address;case"vector":return B.vector(t[0]);default:if(!r.includes("::"))throw`Unimplemented builtin type ${r}`}let u;try{u=await this.getMoveStruct(r)}catch(d){throw console.error("Invalid move address",r),d}let c={};for(let d of u.fields)if(d.type.qname.startsWith("T")&&t.length){let S=+d.type.qname.slice(1);c[d.name]=t[S]}else d.type.typeArgs.length&&t.length?c[d.name]=await this.getBCSTypeWithArgs(d.type,t):c[d.name]=await this.getBCSType(d.type);return B.struct(r,c)}async getBCSType(e){let t=await Promise.all(e.typeArgs.map(s=>this.getBCSType(s))),r=await this.getBCSTypeWithArgs(e,t);return this.bcsRegistry.set(e.getNormalizedSignature(),r),r}async registerBCSTypes(e){let t=e.getNormalizedSignature();if(this.bcsRegistered.has(t))return;this.bcsRegistered.add(t);let r=await this.getBCSType(e);this.bcsRegistry.set(e.getNormalizedSignature(),r)}async decodeBCS(e,t,r){if(await this.registerBCSTypes(e),typeof t=="string"){let o=Buffer.from(t,r);t=new Uint8Array(o,o.byteOffset,o.byteLength)}return this.bcsRegistry.get(e.getNormalizedSignature())?.parse(t)}async decodeDevInspectResult(e){let t=[];if(e.results!=null)for(let r of e.results)if(r.returnValues)for(let s of r.returnValues){let o=H(s[1]),i=await this.decodeBCS(o,new Uint8Array(s[0])),u=await this.decodedType(i,o);t.push(u)}else t.push(null);return{...e,results_decoded:t}}},_e="https://fullnode.mainnet.sui.io/",Me=new Map;function Ne(n=_e){let e=Me.get(n);return e||(e=new w(new xe({url:n})),Me.set(n,e)),e}a(Ne,"defaultMoveCoder");var Pe=new Map,ae;async function Le(n){let e=Pe.get(n);if(!e){e=new w(n);let t=await n.getChainIdentifier(),r=Ne();ae||(ae=await r.adapter.getChainId()),t===ae&&(e=r),Pe.set(n,e)}return e}a(Le,"getMoveCoder");var ke=new Map;function M(n=O.MAIN_NET){let e=ke.get(n);return e||(e=new w(A(n)),ke.set(n,e)),e}a(M,"defaultMoveCoder");import("node:process").then(n=>n.stdout.write(""));var g=class extends ie{static{a(this,"SuiContext")}moduleName;timestamp;checkpoint;transaction;eventIndex;coder;constructor(e,t,r,s,o,i,u,c){super(c),this.address=r.toLowerCase(),this.network=t,this.moduleName=e,this.timestamp=s,this.checkpoint=o,this.eventIndex=u,this.coder=M(t),i&&(this.transaction=i)}getChainId(){return this.network}getTimestamp(){return this.timestamp.getDate()}getMetaDataInternal(e,t){return{address:this.address,contractName:this.moduleName,blockNumber:this.checkpoint,transactionIndex:0,transactionHash:this.transaction?.digest||"",logIndex:this.eventIndex,chainId:this.getChainId(),name:e,labels:J(t)}}get client(){return A(this.network)}},z=class extends ie{static{a(this,"SuiObjectChangeContext")}timestamp;checkpoint;coder;txDigest;constructor(e,t,r,s,o,i){super(i),this.address=t,this.network=e,this.timestamp=r,this.checkpoint=s,this.txDigest=o,this.coder=M(e)}getChainId(){return this.network}getTimestamp(){return this.timestamp.getDate()}getMetaDataInternal(e,t){return{address:this.address,contractName:"*",blockNumber:this.checkpoint,transactionIndex:-1,transactionHash:this.txDigest,logIndex:0,chainId:this.getChainId(),name:e,labels:J(t)}}get client(){return A(this.network)}},ce=class extends ye{static{a(this,"SuiAddressContext")}address;network;checkpoint;timestamp;coder;contractName="address";constructor(e,t,r,s,o){super(o),this.address=t,this.network=e,this.checkpoint=r,this.timestamp=s,this.coder=M(e)}getChainId(){return this.network}getMetaDataInternal(e,t){return{address:this.address,contractName:this.contractName,blockNumber:this.checkpoint,transactionIndex:0,transactionHash:"",logIndex:0,chainId:this.getChainId(),name:e,labels:J(t)}}get client(){return A(this.network)}getTimestamp(){return this.timestamp.getDate()}},X=class extends ce{static{a(this,"SuiObjectContext")}contractName="object";objectId;constructor(e,t,r,s,o){super(e,t,r,s,o),this.objectId=t}};import("node:process").then(n=>n.stdout.write(""));function Ee(n){let e=n.transaction?.data.transaction;if(!e)return[];let t=e.kind==="ProgrammableTransaction"?e:void 0;return t?t.transactions.flatMap(r=>{if("MoveCall"in r){let s=r.MoveCall;return s.package=K(s.package),[s]}return[]}):[]}a(Ee,"getMoveCalls");import("node:process").then(n=>n.stdout.write(""));var F={resourceChanges:!1,allEvents:!1,inputs:!1};function le(n){return{startCheckpoint:n.startCheckpoint||0n,address:n.address==="*"?"*":R(n.address),network:n.network||O.MAIN_NET,baseLabels:n.baseLabels}}a(le,"configure");var _=class n extends Ve{static{a(this,"SuiProcessorState")}static INSTANCE=new n},L=class{static{a(this,"SuiBaseProcessor")}moduleName;config;eventHandlers=[];callHandlers=[];objectChangeHandlers=[];coder;constructor(e,t){this.moduleName=e,this.config=le(t),_.INSTANCE.addValue(this),this.coder=M(this.config.network)}getChainId(){return this.config.network}onMoveEvent(e,t,r){let s=[],o=x.fromPartial({...F,...r});Array.isArray(t)?s=t:s.push(t);let i=this,u=new Set(s.map(c=>c.type));return this.eventHandlers.push({handler:a(async function(c){if(!c.transaction)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"event is null");let d=c.transaction;if(!d.events||!d.events.length)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"no event in the transactions");let S=[];for(let h of d.events){let k=Number(h.id.eventSeq)||0,[Se,E,se]=H(h.type).qname.split(m);if(!u.has([E,se].join(m)))continue;let $=new g(i.moduleName,i.config.network,i.config.address,c.timestamp||new Date(0),c.slot,d,k,i.config.baseLabels),De=await i.coder.decodeEvent(h);await e(De||h,$),S.push($.stopAndGetResult())}return Ue(S)},"handler"),filters:s,fetchConfig:o}),this}onEntryFunctionCall(e,t,r){let s=[],o=x.fromPartial({...F,...r});Array.isArray(t)?s=t:s.push(t);let i=this,u=new Set(s.map(c=>c.function));return this.callHandlers.push({handler:a(async function(c){if(!c.transaction)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"call is null");let d=c.transaction,S=new g(i.moduleName,i.config.network,i.config.address,c.timestamp||new Date(0),c.slot,d,0,i.config.baseLabels);if(d){let h=Ee(d),k=d.transaction?.data?.transaction;if(!k)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"Unexpected getTransactionKind get empty");let Se=k.kind==="ProgrammableTransaction"?k:void 0;for(let E of h){let se=[E.module,E.function].join(m);if(!u.has(se))continue;let $=await i.coder.decodeFunctionPayload(E,Se?.inputs||[]);await e($,S)}}return S.stopAndGetResult()},"handler"),filters:s,fetchConfig:o}),this}onEvent(e,t){return this.onMoveEvent(e,{type:""},t),this}onTransactionBlock(e,t,r){let s=x.fromPartial({...F,...r}),o=this;return this.callHandlers.push({handler:a(async function(i){if(!i.transaction)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"transaction is null");let u=i.transaction,c=new g(o.moduleName,o.config.network,o.config.address,i.timestamp||new Date(0),i.slot,u,0,o.config.baseLabels);return u&&await e(u,c),c.stopAndGetResult()},"handler"),filters:[{...t,function:""}],fetchConfig:s}),this}onObjectChange(e,t){if(this.config.network===O.TEST_NET)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"object change not supported in testnet");let r=this;return this.objectChangeHandlers.push({handler:a(async function(s){let o=new z(r.config.network,r.config.address,s.timestamp||new Date(0),s.slot,s.txDigest,r.config.baseLabels);return await e(s.changes,o),o.stopAndGetResult()},"handler"),type:t}),this}},ue=class n extends L{static{a(this,"SuiModulesProcessor")}static bind(e){return new n("*",e)}},de=class n extends L{static{a(this,"SuiGlobalProcessor")}static bind(e){return new n("*",{...e,address:"*"})}onTransactionBlock(e,t,r){return super.onTransactionBlock(e,t,r)}onObjectChange(e,t){return super.onObjectChange(e,t)}};import("node:process").then(n=>n.stdout.write(""));import{ListStateStorage as Ge}from"@sentio/runtime";var ee=D(W(),1);var fe={owned:!1},T=class n extends Ge{static{a(this,"SuiAccountProcessorState")}static INSTANCE=new n},P=class{static{a(this,"SuiBaseObjectOrAddressProcessor")}config;ownerType;templateId;objectHandlers=[];constructor(e){e.ownerType===j.TYPE?this.config={startCheckpoint:e.startCheckpoint||0n,address:K(e.address),network:e.network||O.MAIN_NET,baseLabels:e.baseLabels}:this.config=le(e),this.ownerType=e.ownerType,T.INSTANCE.addValue(this)}getChainId(){return this.config.network}onInterval(e,t,r,s,o){let i=this;return this.objectHandlers.push({handler:a(async function(u){let c=new X(i.config.network,i.config.address,u.slot,u.timestamp||new Date(0),i.config.baseLabels);return await i.doHandle(e,u,c),c.stopAndGetResult()},"handler"),timeIntervalInMinutes:t,checkPointInterval:r,type:s,fetchConfig:{...fe,...o}}),this}onTimeInterval(e,t=60,r=240,s,o){return this.onInterval(e,{recentInterval:t,backfillInterval:r},void 0,s,o)}onCheckpointInterval(e,t=1e5,r=4e5,s,o){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:r},s,o)}},v=class n extends P{static{a(this,"SuiAddressProcessor")}callHandlers=[];static bind(e){return new n({...e,ownerType:j.ADDRESS})}async doHandle(e,t,r){return e(t.objects,r)}onTransactionBlock(e,t,r){let s=x.fromPartial({...F,...r}),o={fromAndToAddress:{from:"",to:this.config.address},...t},i=this;return this.callHandlers.push({handler:a(async function(u){if(!u.transaction)throw new ee.ServerError(ee.Status.INVALID_ARGUMENT,"transaction is null");let c=u.transaction,d=new g("object",i.config.network,i.config.address,u.timestamp||new Date(0),u.slot,c,0,i.config.baseLabels);return c&&await e(c,d),d.stopAndGetResult()},"handler"),filters:[{...o,function:""}],fetchConfig:s}),this}},V=class n extends P{static{a(this,"SuiObjectProcessor")}static bind(e){return new n({address:e.objectId,network:e.network,startCheckpoint:e.startCheckpoint,ownerType:j.OBJECT,baseLabels:e.baseLabels})}async doHandle(e,t,r){if(!t.self){console.log(`Sui object not existed in ${r.checkpoint}, please specific a start time`);return}return e(t.self,t.objects,r)}},pe=class n extends P{static{a(this,"SuiObjectTypeProcessor")}objectType;static bind(e){let t=new n({address:e.objectType.qname,network:e.network,startCheckpoint:e.startCheckpoint,ownerType:j.TYPE,baseLabels:e.baseLabels});return t.objectType=e.objectType,t}async doHandle(e,t,r){if(!t.self){console.log(`Sui object not existed in ${r.checkpoint}, please specific a start time`);return}let s=await r.coder.filterAndDecodeObjects(this.objectType,[t.self]);return e(s[0],t.objects,r)}},U=class n extends P{static{a(this,"SuiWrappedObjectProcessor")}static bind(e){return new n({address:e.objectId,network:e.network,startCheckpoint:e.startCheckpoint,ownerType:j.WRAPPED_OBJECT,baseLabels:e.baseLabels})}async doHandle(e,t,r){return e(t.objects,r)}};import("node:process").then(n=>n.stdout.write(""));import{ListStateStorage as $e}from"@sentio/runtime";var b=D(W(),1);var N=class n extends $e{static{a(this,"SuiAccountProcessorTemplateState")}static INSTANCE=new n},G=class{static{a(this,"SuiObjectOrAddressProcessorTemplate")}id;objectHandlers=[];binds=new Set;constructor(){this.id=N.INSTANCE.getValues().length,N.INSTANCE.addValue(this)}bind(e,t){e.network=e.network||t.network,e.startCheckpoint=e.startCheckpoint||t.checkpoint;let r=e.objectId||e.address;if(r==="*")throw new b.ServerError(b.Status.INVALID_ARGUMENT,"can't bind template instance with *");r=R(r);let s=[e.network,r].join("_");if(this.binds.has(s)){console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${s}`);return}this.binds.add(s);let o=this.createProcessor(e);for(let u of this.objectHandlers)o.onInterval(u.handler,u.timeIntervalInMinutes,u.checkpointInterval,u.type,u.fetchConfig);let i=o.config;t.update({states:{configUpdated:!0}}),q.INSTANCE.addValue({templateId:this.id,contract:{name:"",chainId:i.network,address:i.address,abi:""},startBlock:i.startCheckpoint,endBlock:0n,baseLabels:i.baseLabels}),console.log(`successfully bind template ${s}`)}unbind(e,t){e.network=e.network||t.network,e.startCheckpoint=e.startCheckpoint||t.checkpoint;let r=e.objectId||e.address;if(r==="*")throw new b.ServerError(b.Status.INVALID_ARGUMENT,"can't delete template instance bind with *");r=R(r);let s=[e.network,r].join("_");if(!this.binds.has(s)){console.log(`the template instance ${s} not existed or already unbind`);return}this.binds.delete(s);let o=0,i=q.INSTANCE.unregister();for(let c of i){if(c.contract?.chainId===e.network&&c.contract.address==r){o++;continue}q.INSTANCE.addValue(c)}if(o!==1)throw new b.ServerError(b.Status.INVALID_ARGUMENT,`Failed to delete template instance ${s}, deleted ${o} times`);let u=T.INSTANCE.unregister();o=0;for(let c of u){if(c.templateId===this.id&&c.config.network==e.network&&c.config.address===r){o++;continue}T.INSTANCE.addValue(c)}if(o!==1)throw new b.ServerError(b.Status.INVALID_ARGUMENT,`Failed to delete processor for template ${this.id}, ${s}. deleted ${o} times`);console.log(`successfully unbind template ${s}`),t.update({states:{configUpdated:!0}})}onInterval(e,t,r,s,o){return this.objectHandlers.push({handler:e,timeIntervalInMinutes:t,checkpointInterval:r,type:s,fetchConfig:{...fe,...o}}),this}onTimeInterval(e,t=60,r=240,s,o){return this.onInterval(e,{recentInterval:t,backfillInterval:r},void 0,s,o)}onCheckpointInterval(e,t=1e5,r=4e5,s,o){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:r},s,o)}};var he=class extends G{static{a(this,"SuiAddressProcessorTemplate")}handlers=[];createProcessor(e){let t=v.bind(e);for(let r of this.handlers)t.onTransactionBlock(r.handler,r.filter,r.fetchConfig);return t.templateId=this.id,t}onTransactionBlock(e,t,r){return this.handlers.push({handler:e,filter:t,fetchConfig:r}),this}},me=class extends G{static{a(this,"SuiObjectProcessorTemplate")}createProcessor(e){let t=V.bind(e);return t.templateId=this.id,t}},ge=class extends G{static{a(this,"SuiWrappedObjectProcessorTemplate")}createProcessor(e){let t=U.bind(e);return t.templateId=this.id,t}};import("node:process").then(n=>n.stdout.write(""));import("node:process").then(n=>n.stdout.write(""));import{errorString as te,mergeProcessResults as ne,Plugin as Je,PluginManager as We,USER_PROCESSOR as qe}from"@sentio/runtime";var l=D(W(),1);var be=D(Re(),1);var re=class extends Je{static{a(this,"SuiPlugin")}name="SuiPlugin";handlers={suiCallHandlers:[],suiEventHandlers:[],suiObjectHandlers:[],suiObjectChangeHandlers:[]};async start(e){await Ae(),console.log("total instances:",e.templateInstances.length);let t=new Set(Object.values(be.SuiChainId));for(let r of e.templateInstances){if(!t.has(r.contract?.chainId||""))continue;console.log("start template instance",r.templateId),N.INSTANCE.getValues()[r.templateId].bind({address:r.contract?.address||"",objectId:r.contract?.address||"",network:r.contract?.chainId||O.MAIN_NET,startCheckpoint:r.startBlock||0n,baseLabels:r.baseLabels},Ke)}}async configure(e){let t={suiCallHandlers:[],suiEventHandlers:[],suiObjectHandlers:[],suiObjectChangeHandlers:[]};for(let r of _.INSTANCE.getValues()){let s=Ce.fromPartial({transactionConfig:[],processorType:qe,contract:{name:r.moduleName,chainId:r.config.network,address:r.config.address,abi:""},startBlock:r.config.startCheckpoint});for(let o of r.eventHandlers){let i=t.suiEventHandlers.push(o.handler)-1,u={filters:o.filters.map(c=>({type:c.type,account:c.account||""})),fetchConfig:o.fetchConfig,handlerId:i};s.moveEventConfigs.push(u)}for(let o of r.callHandlers){let i=t.suiCallHandlers.push(o.handler)-1,u={filters:o.filters.map(c=>({function:c.function,typeArguments:c.typeArguments||[],withTypeArguments:!!c.typeArguments,includeFailed:c.includeFailed||!1,publicKeyPrefix:c.publicKeyPrefix||"",fromAndToAddress:c.fromAndToAddress})),fetchConfig:o.fetchConfig,handlerId:i};s.moveCallConfigs.push(u)}for(let o of r.objectChangeHandlers){let i=t.suiObjectChangeHandlers.push(o.handler)-1,u={type:o.type,handlerId:i};s.moveResourceChangeConfigs.push(u)}e.contractConfigs.push(s)}for(let r of T.INSTANCE.getValues()){let s=Oe.fromPartial({address:r.config.address,chainId:r.getChainId(),startBlock:r.config.startCheckpoint});for(let o of r.objectHandlers){let i=t.suiObjectHandlers.push(o.handler)-1;s.moveIntervalConfigs.push({intervalConfig:{handlerId:i,minutes:0,minutesInterval:o.timeIntervalInMinutes,slot:0,slotInterval:o.checkPointInterval,fetchConfig:void 0},type:o.type||"",ownerType:r.ownerType,fetchConfig:o.fetchConfig})}if(r instanceof v)for(let o of r.callHandlers){let i=t.suiCallHandlers.push(o.handler)-1,u={filters:o.filters.map(c=>({function:c.function,typeArguments:c.typeArguments||[],withTypeArguments:!!c.typeArguments,includeFailed:c.includeFailed||!1,publicKeyPrefix:c.publicKeyPrefix||"",fromAndToAddress:c.fromAndToAddress})),fetchConfig:o.fetchConfig,handlerId:i};s.moveCallConfigs.push(u)}e.accountConfigs.push(s)}this.handlers=t}async processSuiEvent(e){if(!e.data?.suiEvent)throw new l.ServerError(l.Status.INVALID_ARGUMENT,"Event can't be empty");let t=[],r=e.data.suiEvent;for(let s of e.handlerIds)t.push(this.handlers.suiEventHandlers[s](r).catch(o=>{throw new l.ServerError(l.Status.INTERNAL,"error processing event: "+JSON.stringify(r)+`
|
|
2
|
+
import{a as ve,b as je,c as B,e as xe,f as O,g as A,i as Ae}from"./chunk-DWTPG7UW.js";import{B as ie,C as ye,a as m,d as K,f as R,i as we,m as I,n as H,o as oe,u as Te,v as Ie,w as Y}from"./chunk-MCICASJD.js";import{a as Re}from"./chunk-2NOM7BGS.js";import{D as C,Kd as q,Tc as J,W as Ce,fa as Oe,jd as W,x as j,za as x}from"./chunk-BBD4HNM4.js";import{a,f as D}from"./chunk-G5BIPHMS.js";import{ListStateStorage as Ve,mergeProcessResults as Ue}from"@sentio/runtime";var p=D(W(),1);var Ye="0x0000000000000000000000000000000000000000000000000000000000000000";function f(n){return typeof n!="object"||n==null?!1:n.$kind==="GasCoin"||n.$kind==="Result"||n.$kind==="NestedResult"||n.$kind==="Input"}a(f,"isTransactionArgument");function Ze(n,e){return f(n)?n:e.object(n)}a(Ze,"transactionArgumentOrObject");function ze(n,e){return f(n)?n:typeof n=="string"?e.pure.string(n):e.pure.u64(n)}a(ze,"transactionArgumentOrPure");function Xe(n,e){return f(n)?n:e.pure.address(n)}a(Xe,"transactionArgumentOrPureAddress");function et(n,e){return f(n)?n:e.pure.u8(n)}a(et,"transactionArgumentOrPureU8");function tt(n,e){return f(n)?n:e.pure.u16(n)}a(tt,"transactionArgumentOrPureU16");function nt(n,e){return f(n)?n:e.pure.u32(n)}a(nt,"transactionArgumentOrPureU32");function rt(n,e){return f(n)?n:e.pure.u64(n)}a(rt,"transactionArgumentOrPureU64");function st(n,e){return f(n)?n:e.pure.u128(n)}a(st,"transactionArgumentOrPureU128");function ot(n,e){return f(n)?n:e.pure.u256(n)}a(ot,"transactionArgumentOrPureU256");function it(n,e){return f(n)?n:e.pure.bool(n)}a(it,"transactionArgumentOrPureBool");function at(n,e){return f(n)?n:e.makeMoveVec({elements:n.map(t=>e.object(t))})}a(at,"transactionArgumentOrVec");function Q(n){return{address:n.address,exposedFunctions:Object.entries(n.exposedFunctions).map(([e,t])=>He(e,t)),name:n.name,structs:Object.entries(n.structs).map(([e,t])=>Be(e,t))}}a(Q,"toInternalModule");function He(n,e){let t;switch(e.visibility){case"Private":t=Y.PRIVATE;break;case"Public":t=Y.PUBLIC;break;case"Friend":t=Y.FRIEND;break;default:throw Error("No visibility for function"+n)}return{typeParams:e.typeParameters.map(r=>({constraints:r.abilities})),isEntry:e.isEntry,name:n,params:e.parameters.map(y),return:e.return.map(y),visibility:t}}a(He,"toInternalFunction");function Be(n,e){return{abilities:e.abilities.abilities,fields:e.fields.map(Fe),typeParams:e.typeParameters.map(t=>({constraints:t.constraints.abilities})),isNative:!1,isEvent:!1,name:n}}a(Be,"toInternalStruct");function Fe(n){return{name:n.name,type:y(n.type)}}a(Fe,"toInternalField");function y(n){if(typeof n=="string")return new I(n);if("Struct"in n){let e=[n.Struct.address,n.Struct.module,n.Struct.name].join(m),t=n.Struct.typeArguments.map(y);return new I(e,t)}if("Vector"in n)return new I("Vector",[y(n.Vector)]);if("TypeParameter"in n)return new I("T"+n.TypeParameter);if("Reference"in n){let e=y(n.Reference);return e.reference=!0,e}if("MutableReference"in n){let e=y(n.MutableReference);return e.reference=!0,e.mutable=!0,e}throw new Error("Unexpected sui type")}a(y,"toTypeDescriptor");var Z=class extends Te{static{a(this,"SuiChainAdapter")}async getChainId(){return this.client.getChainIdentifier()}client;constructor(e){super(),this.client=e}async fetchModule(e,t){return await this.client.getNormalizedMoveModule({package:e,module:t})}async fetchModules(e){let t=await this.client.getNormalizedMoveModulesByPackage({package:e});return Object.values(t)}getMeaningfulFunctionParams(e){return e}toInternalModules(e){return Object.values(e).map(Q)}getAllEventStructs(e){let t=new Map;for(let r of e){let s=we(r);for(let o of r.structs){let i=new Set(o.abilities);i.has("Drop")&&i.has("Copy")&&t.set(s+m+o.name,o)}}return t}getType(e){return e.type}getData(e){if(e===void 0)throw Error("val is undefined");return"parsedJson"in e?e.parsedJson:e.dataType==="moveObject"||"fields"in e&&"type"in e&&Object.keys(e).length===2?e.fields:e}};var w=class extends Ie{static{a(this,"MoveCoder")}constructor(e){super(new Z(e))}load(e,t){let r=this.moduleMapping.get(e.address+"::"+e.name),s=this.moduleMapping.get(t+"::"+e.name);return r&&s||(r=Q(e),this.loadInternal(r,t)),r}async decode(e,t){switch(t.qname){case"0x1::ascii::Char":if(e!==void 0&&typeof e!="string"){let s=(await super.decode(e,t)).byte;return String.fromCharCode(s)}case"0x1::ascii::String":if(e!==void 0&&typeof e!="string"){let s=(await super.decode(e,t)).bytes;return new TextDecoder().decode(new Uint8Array(s))}case"0x2::object::ID":if(e!==void 0&&typeof e!="string"){let s=(await super.decode(e,t)).bytes;return je(s)}case"0x2::url::Url":if(e!==void 0&&typeof e!="string")return(await super.decode(e,t)).url;case"0x2::coin::Coin":if(e!==void 0&&typeof e!="string"){let s=(await super.decode(e,t)).id.id.bytes;return new TextDecoder().decode(new Uint8Array(s))}return e;case"0x2::balance::Balance":return e.value?(await super.decode(e,t)).value:BigInt(e);case"0x1::option::Option":if(e===null)return e;if(e.vec){let s=await super.decode(e,t);return s=s.vec,s.length===0?null:s[0]}return this.decode(e,t.typeArgs[0]);case"Address":return ve(e);case"0x1::string::String":if(typeof e!="string")return new TextDecoder().decode(new Uint8Array(e.bytes));default:return super.decode(e,t)}}decodeEvent(e){return this.decodedStruct(e)}filterAndDecodeEvents(e,t){return typeof e=="string"&&(e=H(e)),this.filterAndDecodeStruct(e,t)}async getDynamicFields(e,t=oe,r=oe){let s=new I("0x2::dynamic_field::Field");return s.typeArgs=[t,r],(await this.filterAndDecodeObjects(s,e)).map(i=>i.data_decoded)}filterAndDecodeObjects(e,t){return this.filterAndDecodeStruct(e,t)}async decodeFunctionPayload(e,t){let r=[e.package,e.module,e.function].join(m),s=await this.getMoveFunction(r),o=this.adapter.getMeaningfulFunctionParams(s.params),i=[];for(let c of e.arguments||[]){let d=c;if("Input"in d){let S=d.Input,h=t[S];h.type==="pure"?i.push(h.value):(h.type==="object"||console.error("unexpected function arg value"),i.push(void 0))}else i.push(void 0)}let u=await this.decodeArray(i,o,!1);return{...e,arguments_decoded:u}}bcsRegistered=new Set;bcsRegistry=new Map;async getBCSTypeWithArgs(e,t=[]){let r=e.qname,s=e.getNormalizedSignature(),o=this.bcsRegistry.get(s);if(o)return o;let i=r.toLowerCase();switch(i){case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":case"bool":return B[i]();case"address":return B.Address;case"vector":return B.vector(t[0]);default:if(!r.includes("::"))throw`Unimplemented builtin type ${r}`}let u;try{u=await this.getMoveStruct(r)}catch(d){throw console.error("Invalid move address",r),d}let c={};for(let d of u.fields)if(d.type.qname.startsWith("T")&&t.length){let S=+d.type.qname.slice(1);c[d.name]=t[S]}else d.type.typeArgs.length&&t.length?c[d.name]=await this.getBCSTypeWithArgs(d.type,t):c[d.name]=await this.getBCSType(d.type);return B.struct(r,c)}async getBCSType(e){let t=await Promise.all(e.typeArgs.map(s=>this.getBCSType(s))),r=await this.getBCSTypeWithArgs(e,t);return this.bcsRegistry.set(e.getNormalizedSignature(),r),r}async registerBCSTypes(e){let t=e.getNormalizedSignature();if(this.bcsRegistered.has(t))return;this.bcsRegistered.add(t);let r=await this.getBCSType(e);this.bcsRegistry.set(e.getNormalizedSignature(),r)}async decodeBCS(e,t,r){if(await this.registerBCSTypes(e),typeof t=="string"){let o=Buffer.from(t,r);t=new Uint8Array(o,o.byteOffset,o.byteLength)}return this.bcsRegistry.get(e.getNormalizedSignature())?.parse(t)}async decodeDevInspectResult(e){let t=[];if(e.results!=null)for(let r of e.results)if(r.returnValues)for(let s of r.returnValues){let o=H(s[1]),i=await this.decodeBCS(o,new Uint8Array(s[0])),u=await this.decodedType(i,o);t.push(u)}else t.push(null);return{...e,results_decoded:t}}},_e="https://fullnode.mainnet.sui.io/",Me=new Map;function Ne(n=_e){let e=Me.get(n);return e||(e=new w(new xe({url:n})),Me.set(n,e)),e}a(Ne,"defaultMoveCoder");var Pe=new Map,ae;async function Le(n){let e=Pe.get(n);if(!e){e=new w(n);let t=await n.getChainIdentifier(),r=Ne();ae||(ae=await r.adapter.getChainId()),t===ae&&(e=r),Pe.set(n,e)}return e}a(Le,"getMoveCoder");var ke=new Map;function M(n=O.MAIN_NET){let e=ke.get(n);return e||(e=new w(A(n)),ke.set(n,e)),e}a(M,"defaultMoveCoder");import("node:process").then(n=>n.stdout.write(""));var g=class extends ie{static{a(this,"SuiContext")}moduleName;timestamp;checkpoint;transaction;eventIndex;coder;constructor(e,t,r,s,o,i,u,c){super(c),this.address=r.toLowerCase(),this.network=t,this.moduleName=e,this.timestamp=s,this.checkpoint=o,this.eventIndex=u,this.coder=M(t),i&&(this.transaction=i)}getChainId(){return this.network}getTimestamp(){return this.timestamp.getDate()}getMetaDataInternal(e,t){return{address:this.address,contractName:this.moduleName,blockNumber:this.checkpoint,transactionIndex:0,transactionHash:this.transaction?.digest||"",logIndex:this.eventIndex,chainId:this.getChainId(),name:e,labels:J(t)}}get client(){return A(this.network)}},z=class extends ie{static{a(this,"SuiObjectChangeContext")}timestamp;checkpoint;coder;txDigest;constructor(e,t,r,s,o,i){super(i),this.address=t,this.network=e,this.timestamp=r,this.checkpoint=s,this.txDigest=o,this.coder=M(e)}getChainId(){return this.network}getTimestamp(){return this.timestamp.getDate()}getMetaDataInternal(e,t){return{address:this.address,contractName:"*",blockNumber:this.checkpoint,transactionIndex:-1,transactionHash:this.txDigest,logIndex:0,chainId:this.getChainId(),name:e,labels:J(t)}}get client(){return A(this.network)}},ce=class extends ye{static{a(this,"SuiAddressContext")}address;network;checkpoint;timestamp;coder;contractName="address";constructor(e,t,r,s,o){super(o),this.address=t,this.network=e,this.checkpoint=r,this.timestamp=s,this.coder=M(e)}getChainId(){return this.network}getMetaDataInternal(e,t){return{address:this.address,contractName:this.contractName,blockNumber:this.checkpoint,transactionIndex:0,transactionHash:"",logIndex:0,chainId:this.getChainId(),name:e,labels:J(t)}}get client(){return A(this.network)}getTimestamp(){return this.timestamp.getDate()}},X=class extends ce{static{a(this,"SuiObjectContext")}contractName="object";objectId;constructor(e,t,r,s,o){super(e,t,r,s,o),this.objectId=t}};import("node:process").then(n=>n.stdout.write(""));function Ee(n){let e=n.transaction?.data.transaction;if(!e)return[];let t=e.kind==="ProgrammableTransaction"?e:void 0;return t?t.transactions.flatMap(r=>{if("MoveCall"in r){let s=r.MoveCall;return s.package=K(s.package),[s]}return[]}):[]}a(Ee,"getMoveCalls");import("node:process").then(n=>n.stdout.write(""));var F={resourceChanges:!1,allEvents:!1,inputs:!1};function le(n){return{startCheckpoint:n.startCheckpoint||0n,address:n.address==="*"?"*":R(n.address),network:n.network||O.MAIN_NET,baseLabels:n.baseLabels}}a(le,"configure");var _=class n extends Ve{static{a(this,"SuiProcessorState")}static INSTANCE=new n},L=class{static{a(this,"SuiBaseProcessor")}moduleName;config;eventHandlers=[];callHandlers=[];objectChangeHandlers=[];coder;constructor(e,t){this.moduleName=e,this.config=le(t),_.INSTANCE.addValue(this),this.coder=M(this.config.network)}getChainId(){return this.config.network}onMoveEvent(e,t,r){let s=[],o=x.fromPartial({...F,...r});Array.isArray(t)?s=t:s.push(t);let i=this,u=new Set(s.map(c=>c.type));return this.eventHandlers.push({handler:a(async function(c){if(!c.transaction)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"event is null");let d=c.transaction;if(!d.events||!d.events.length)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"no event in the transactions");let S=[];for(let h of d.events){let k=Number(h.id.eventSeq)||0,[Se,E,se]=H(h.type).qname.split(m);if(!u.has([E,se].join(m)))continue;let $=new g(i.moduleName,i.config.network,i.config.address,c.timestamp||new Date(0),c.slot,d,k,i.config.baseLabels),De=await i.coder.decodeEvent(h);await e(De||h,$),S.push($.stopAndGetResult())}return Ue(S)},"handler"),filters:s,fetchConfig:o}),this}onEntryFunctionCall(e,t,r){let s=[],o=x.fromPartial({...F,...r});Array.isArray(t)?s=t:s.push(t);let i=this,u=new Set(s.map(c=>c.function));return this.callHandlers.push({handler:a(async function(c){if(!c.transaction)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"call is null");let d=c.transaction,S=new g(i.moduleName,i.config.network,i.config.address,c.timestamp||new Date(0),c.slot,d,0,i.config.baseLabels);if(d){let h=Ee(d),k=d.transaction?.data?.transaction;if(!k)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"Unexpected getTransactionKind get empty");let Se=k.kind==="ProgrammableTransaction"?k:void 0;for(let E of h){let se=[E.module,E.function].join(m);if(!u.has(se))continue;let $=await i.coder.decodeFunctionPayload(E,Se?.inputs||[]);await e($,S)}}return S.stopAndGetResult()},"handler"),filters:s,fetchConfig:o}),this}onEvent(e,t){return this.onMoveEvent(e,{type:""},t),this}onTransactionBlock(e,t,r){let s=x.fromPartial({...F,...r}),o=this;return this.callHandlers.push({handler:a(async function(i){if(!i.transaction)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"transaction is null");let u=i.transaction,c=new g(o.moduleName,o.config.network,o.config.address,i.timestamp||new Date(0),i.slot,u,0,o.config.baseLabels);return u&&await e(u,c),c.stopAndGetResult()},"handler"),filters:[{...t,function:""}],fetchConfig:s}),this}onObjectChange(e,t){if(this.config.network===O.TEST_NET)throw new p.ServerError(p.Status.INVALID_ARGUMENT,"object change not supported in testnet");let r=this;return this.objectChangeHandlers.push({handler:a(async function(s){let o=new z(r.config.network,r.config.address,s.timestamp||new Date(0),s.slot,s.txDigest,r.config.baseLabels);return await e(s.changes,o),o.stopAndGetResult()},"handler"),type:t}),this}},ue=class n extends L{static{a(this,"SuiModulesProcessor")}static bind(e){return new n("*",e)}},de=class n extends L{static{a(this,"SuiGlobalProcessor")}static bind(e){return new n("*",{...e,address:"*"})}onTransactionBlock(e,t,r){return super.onTransactionBlock(e,t,r)}onObjectChange(e,t){return super.onObjectChange(e,t)}};import("node:process").then(n=>n.stdout.write(""));import{ListStateStorage as Ge}from"@sentio/runtime";var ee=D(W(),1);var fe={owned:!1},T=class n extends Ge{static{a(this,"SuiAccountProcessorState")}static INSTANCE=new n},P=class{static{a(this,"SuiBaseObjectOrAddressProcessor")}config;ownerType;templateId;objectHandlers=[];constructor(e){e.ownerType===j.TYPE?this.config={startCheckpoint:e.startCheckpoint||0n,address:K(e.address),network:e.network||O.MAIN_NET,baseLabels:e.baseLabels}:this.config=le(e),this.ownerType=e.ownerType,T.INSTANCE.addValue(this)}getChainId(){return this.config.network}onInterval(e,t,r,s,o){let i=this;return this.objectHandlers.push({handler:a(async function(u){let c=new X(i.config.network,i.config.address,u.slot,u.timestamp||new Date(0),i.config.baseLabels);return await i.doHandle(e,u,c),c.stopAndGetResult()},"handler"),timeIntervalInMinutes:t,checkPointInterval:r,type:s,fetchConfig:{...fe,...o}}),this}onTimeInterval(e,t=60,r=240,s,o){return this.onInterval(e,{recentInterval:t,backfillInterval:r},void 0,s,o)}onCheckpointInterval(e,t=1e5,r=4e5,s,o){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:r},s,o)}},v=class n extends P{static{a(this,"SuiAddressProcessor")}callHandlers=[];static bind(e){return new n({...e,ownerType:j.ADDRESS})}async doHandle(e,t,r){return e(t.objects,r)}onTransactionBlock(e,t,r){let s=x.fromPartial({...F,...r}),o={fromAndToAddress:{from:"",to:this.config.address},...t},i=this;return this.callHandlers.push({handler:a(async function(u){if(!u.transaction)throw new ee.ServerError(ee.Status.INVALID_ARGUMENT,"transaction is null");let c=u.transaction,d=new g("object",i.config.network,i.config.address,u.timestamp||new Date(0),u.slot,c,0,i.config.baseLabels);return c&&await e(c,d),d.stopAndGetResult()},"handler"),filters:[{...o,function:""}],fetchConfig:s}),this}},V=class n extends P{static{a(this,"SuiObjectProcessor")}static bind(e){return new n({address:e.objectId,network:e.network,startCheckpoint:e.startCheckpoint,ownerType:j.OBJECT,baseLabels:e.baseLabels})}async doHandle(e,t,r){if(!t.self){console.log(`Sui object not existed in ${r.checkpoint}, please specific a start time`);return}return e(t.self,t.objects,r)}},pe=class n extends P{static{a(this,"SuiObjectTypeProcessor")}objectType;static bind(e){let t=new n({address:e.objectType.qname,network:e.network,startCheckpoint:e.startCheckpoint,ownerType:j.TYPE,baseLabels:e.baseLabels});return t.objectType=e.objectType,t}async doHandle(e,t,r){if(!t.self){console.log(`Sui object not existed in ${r.checkpoint}, please specific a start time`);return}let s=await r.coder.filterAndDecodeObjects(this.objectType,[t.self]);return e(s[0],t.objects,r)}},U=class n extends P{static{a(this,"SuiWrappedObjectProcessor")}static bind(e){return new n({address:e.objectId,network:e.network,startCheckpoint:e.startCheckpoint,ownerType:j.WRAPPED_OBJECT,baseLabels:e.baseLabels})}async doHandle(e,t,r){return e(t.objects,r)}};import("node:process").then(n=>n.stdout.write(""));import{ListStateStorage as $e}from"@sentio/runtime";var b=D(W(),1);var N=class n extends $e{static{a(this,"SuiAccountProcessorTemplateState")}static INSTANCE=new n},G=class{static{a(this,"SuiObjectOrAddressProcessorTemplate")}id;objectHandlers=[];binds=new Set;constructor(){this.id=N.INSTANCE.getValues().length,N.INSTANCE.addValue(this)}bind(e,t){e.network=e.network||t.network,e.startCheckpoint=e.startCheckpoint||t.checkpoint;let r=e.objectId||e.address;if(r==="*")throw new b.ServerError(b.Status.INVALID_ARGUMENT,"can't bind template instance with *");r=R(r);let s=[e.network,r].join("_");if(this.binds.has(s)){console.log(`Same object id can be bind to one template only once, ignore duplicate bind: ${s}`);return}this.binds.add(s);let o=this.createProcessor(e);for(let u of this.objectHandlers)o.onInterval(u.handler,u.timeIntervalInMinutes,u.checkpointInterval,u.type,u.fetchConfig);let i=o.config;t.update({states:{configUpdated:!0}}),q.INSTANCE.addValue({templateId:this.id,contract:{name:"",chainId:i.network,address:i.address,abi:""},startBlock:i.startCheckpoint,endBlock:0n,baseLabels:i.baseLabels}),console.log(`successfully bind template ${s}`)}unbind(e,t){e.network=e.network||t.network,e.startCheckpoint=e.startCheckpoint||t.checkpoint;let r=e.objectId||e.address;if(r==="*")throw new b.ServerError(b.Status.INVALID_ARGUMENT,"can't delete template instance bind with *");r=R(r);let s=[e.network,r].join("_");if(!this.binds.has(s)){console.log(`the template instance ${s} not existed or already unbind`);return}this.binds.delete(s);let o=0,i=q.INSTANCE.unregister();for(let c of i){if(c.contract?.chainId===e.network&&c.contract.address==r){o++;continue}q.INSTANCE.addValue(c)}if(o!==1)throw new b.ServerError(b.Status.INVALID_ARGUMENT,`Failed to delete template instance ${s}, deleted ${o} times`);let u=T.INSTANCE.unregister();o=0;for(let c of u){if(c.templateId===this.id&&c.config.network==e.network&&c.config.address===r){o++;continue}T.INSTANCE.addValue(c)}if(o!==1)throw new b.ServerError(b.Status.INVALID_ARGUMENT,`Failed to delete processor for template ${this.id}, ${s}. deleted ${o} times`);console.log(`successfully unbind template ${s}`),t.update({states:{configUpdated:!0}})}onInterval(e,t,r,s,o){return this.objectHandlers.push({handler:e,timeIntervalInMinutes:t,checkpointInterval:r,type:s,fetchConfig:{...fe,...o}}),this}onTimeInterval(e,t=60,r=240,s,o){return this.onInterval(e,{recentInterval:t,backfillInterval:r},void 0,s,o)}onCheckpointInterval(e,t=1e5,r=4e5,s,o){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:r},s,o)}};var he=class extends G{static{a(this,"SuiAddressProcessorTemplate")}handlers=[];createProcessor(e){let t=v.bind(e);for(let r of this.handlers)t.onTransactionBlock(r.handler,r.filter,r.fetchConfig);return t.templateId=this.id,t}onTransactionBlock(e,t,r){return this.handlers.push({handler:e,filter:t,fetchConfig:r}),this}},me=class extends G{static{a(this,"SuiObjectProcessorTemplate")}createProcessor(e){let t=V.bind(e);return t.templateId=this.id,t}},ge=class extends G{static{a(this,"SuiWrappedObjectProcessorTemplate")}createProcessor(e){let t=U.bind(e);return t.templateId=this.id,t}};import("node:process").then(n=>n.stdout.write(""));import("node:process").then(n=>n.stdout.write(""));import{errorString as te,mergeProcessResults as ne,Plugin as Je,PluginManager as We,USER_PROCESSOR as qe}from"@sentio/runtime";var l=D(W(),1);var be=D(Re(),1);var re=class extends Je{static{a(this,"SuiPlugin")}name="SuiPlugin";handlers={suiCallHandlers:[],suiEventHandlers:[],suiObjectHandlers:[],suiObjectChangeHandlers:[]};async start(e){await Ae(),console.log("total instances:",e.templateInstances.length);let t=new Set(Object.values(be.SuiChainId));for(let r of e.templateInstances){if(!t.has(r.contract?.chainId||""))continue;console.log("start template instance",r.templateId),N.INSTANCE.getValues()[r.templateId].bind({address:r.contract?.address||"",objectId:r.contract?.address||"",network:r.contract?.chainId||O.MAIN_NET,startCheckpoint:r.startBlock||0n,baseLabels:r.baseLabels},Ke)}}async configure(e){let t={suiCallHandlers:[],suiEventHandlers:[],suiObjectHandlers:[],suiObjectChangeHandlers:[]};for(let r of _.INSTANCE.getValues()){let s=Ce.fromPartial({transactionConfig:[],processorType:qe,contract:{name:r.moduleName,chainId:r.config.network,address:r.config.address,abi:""},startBlock:r.config.startCheckpoint});for(let o of r.eventHandlers){let i=t.suiEventHandlers.push(o.handler)-1,u={filters:o.filters.map(c=>({type:c.type,account:c.account||""})),fetchConfig:o.fetchConfig,handlerId:i};s.moveEventConfigs.push(u)}for(let o of r.callHandlers){let i=t.suiCallHandlers.push(o.handler)-1,u={filters:o.filters.map(c=>({function:c.function,typeArguments:c.typeArguments||[],withTypeArguments:!!c.typeArguments,includeFailed:c.includeFailed||!1,publicKeyPrefix:c.publicKeyPrefix||"",fromAndToAddress:c.fromAndToAddress})),fetchConfig:o.fetchConfig,handlerId:i};s.moveCallConfigs.push(u)}for(let o of r.objectChangeHandlers){let i=t.suiObjectChangeHandlers.push(o.handler)-1,u={type:o.type,handlerId:i};s.moveResourceChangeConfigs.push(u)}e.contractConfigs.push(s)}for(let r of T.INSTANCE.getValues()){let s=Oe.fromPartial({address:r.config.address,chainId:r.getChainId(),startBlock:r.config.startCheckpoint});for(let o of r.objectHandlers){let i=t.suiObjectHandlers.push(o.handler)-1;s.moveIntervalConfigs.push({intervalConfig:{handlerId:i,minutes:0,minutesInterval:o.timeIntervalInMinutes,slot:0,slotInterval:o.checkPointInterval,fetchConfig:void 0},type:o.type||"",ownerType:r.ownerType,fetchConfig:o.fetchConfig})}if(r instanceof v)for(let o of r.callHandlers){let i=t.suiCallHandlers.push(o.handler)-1,u={filters:o.filters.map(c=>({function:c.function,typeArguments:c.typeArguments||[],withTypeArguments:!!c.typeArguments,includeFailed:c.includeFailed||!1,publicKeyPrefix:c.publicKeyPrefix||"",fromAndToAddress:c.fromAndToAddress})),fetchConfig:o.fetchConfig,handlerId:i};s.moveCallConfigs.push(u)}e.accountConfigs.push(s)}this.handlers=t}async processSuiEvent(e){if(!e.data?.suiEvent)throw new l.ServerError(l.Status.INVALID_ARGUMENT,"Event can't be empty");let t=[],r=e.data.suiEvent;for(let s of e.handlerIds)t.push(this.handlers.suiEventHandlers[s](r).catch(o=>{throw new l.ServerError(l.Status.INTERNAL,"error processing event: "+JSON.stringify(r)+`
|
|
3
3
|
`+te(o))}));return ne(await Promise.all(t))}async processSuiFunctionCall(e){if(!e.data?.suiCall)throw new l.ServerError(l.Status.INVALID_ARGUMENT,"Call can't be empty");let t=e.data.suiCall,r=[];for(let s of e.handlerIds){let o=this.handlers.suiCallHandlers[s](t).catch(i=>{throw new l.ServerError(l.Status.INTERNAL,"error processing call: "+JSON.stringify(t)+`
|
|
4
4
|
`+te(i))});r.push(o)}return ne(await Promise.all(r))}async processSuiObject(e){if(!e.data?.suiObject)throw new l.ServerError(l.Status.INVALID_ARGUMENT,"Object can't be empty");let t=e.data.suiObject,r=[];for(let s of e.handlerIds)r.push(this.handlers.suiObjectHandlers[s](t).catch(o=>{throw new l.ServerError(l.Status.INTERNAL,"error processing object: "+JSON.stringify(t)+`
|
|
5
5
|
`+te(o))}));return ne(await Promise.all(r))}async processSuiObjectChange(e){if(!e.data?.suiObjectChange)throw new l.ServerError(l.Status.INVALID_ARGUMENT,"Object change can't be empty");let t=e.data.suiObjectChange,r=[];for(let s of e.handlerIds)r.push(this.handlers.suiObjectChangeHandlers[s](t).catch(o=>{throw new l.ServerError(l.Status.INTERNAL,"error processing object change: "+JSON.stringify(t)+`
|
|
6
6
|
`+te(o))}));return ne(await Promise.all(r))}supportedHandlers=[C.SUI_EVENT,C.SUI_CALL,C.SUI_OBJECT,C.SUI_OBJECT_CHANGE];processBinding(e){switch(e.handlerType){case C.SUI_EVENT:return this.processSuiEvent(e);case C.SUI_CALL:return this.processSuiFunctionCall(e);case C.SUI_OBJECT:return this.processSuiObject(e);case C.SUI_OBJECT_CHANGE:return this.processSuiObjectChange(e);default:throw new l.ServerError(l.Status.INVALID_ARGUMENT,"No handle type registered "+e.handlerType)}}};We.INSTANCE.register(new re);var Ke=new g("",be.SuiChainId.SUI_MAINNET,"",new Date,0n,{},0,{});import("node:process").then(n=>n.stdout.write(""));import("node:process").then(n=>n.stdout.write(""));export{Ye as a,Ze as b,ze as c,Xe as d,et as e,tt as f,nt as g,rt as h,st as i,ot as j,it as k,at as l,w as m,Le as n,M as o,g as p,z as q,ce as r,X as s,Ee as t,L as u,ue as v,de as w,v as x,V as y,pe as z,U as A,he as B,me as C,ge as D,re as E};
|
|
7
|
-
//# sourceMappingURL=chunk-
|
|
7
|
+
//# sourceMappingURL=chunk-JBPAJGUO.js.map
|