@sentio/sdk-bundle 2.63.0 → 2.63.1
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/0x4.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-RWNFJKBC.js → chunk-3UW3O4RI.js} +2 -2
- package/lib/{chunk-INM2JQXV.js → chunk-3XOMJPOV.js} +2 -2
- package/lib/{chunk-MEXIWEPZ.js → chunk-4CH3FO2Y.js} +2 -2
- package/lib/{chunk-MEXIWEPZ.js.map → chunk-4CH3FO2Y.js.map} +1 -1
- package/lib/chunk-67VWORXP.js +7 -0
- package/lib/chunk-67VWORXP.js.map +1 -0
- package/lib/{chunk-57B2QEFU.js → chunk-ATNNVLSV.js} +2 -2
- package/lib/{chunk-CIT277G3.js → chunk-CQUCT4WO.js} +2 -2
- package/lib/{chunk-MV77KZ7X.js → chunk-D2UTA6NP.js} +3 -3
- package/lib/{chunk-MV77KZ7X.js.map → chunk-D2UTA6NP.js.map} +1 -1
- package/lib/{chunk-NF7SQC5T.js → chunk-DCBB6WSY.js} +2 -2
- package/lib/{chunk-IRMT3JAE.js → chunk-E32G76ZD.js} +2 -2
- package/lib/{chunk-45NSVYWS.js → chunk-HYBAVEVS.js} +2 -2
- package/lib/{chunk-EDLEFVHW.js → chunk-MEWILSVR.js} +2 -2
- package/lib/{chunk-33Y7LZTL.js → chunk-OSRVBU5W.js} +2 -2
- package/lib/{chunk-XCZJCPWS.js → chunk-PJJSNY3A.js} +2 -2
- package/lib/{chunk-VG7IARUK.js → chunk-STFYLBQW.js} +2 -2
- package/lib/{chunk-RFTTBMZW.js → chunk-US7CSPMG.js} +2 -2
- package/lib/{chunk-TLJXINOL.js → chunk-WESN5VPX.js} +2 -2
- package/lib/{chunk-JWIM4IJV.js → chunk-WS3R3PHZ.js} +2 -2
- package/lib/{chunk-XMZYAXTX.js → chunk-ZXTBG7Q4.js} +2 -2
- package/lib/{chunk-VGSWB3RH.js → chunk-ZXUK2KRA.js} +2 -2
- package/lib/core/index.js +1 -1
- 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/fuel/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/iota/builtin/0x1.js +1 -1
- package/lib/iota/builtin/0x2.js +1 -1
- package/lib/iota/builtin/0x3.js +1 -1
- package/lib/iota/builtin/index.js +1 -1
- package/lib/iota/ext/index.js +1 -1
- package/lib/iota/index.js +1 -1
- package/lib/move/index.js +1 -1
- package/lib/solana/builtin/index.js +1 -1
- package/lib/solana/index.js +1 -1
- package/lib/stark/index.js +1 -1
- package/lib/store/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-V7ONVBT4.js +0 -7
- package/lib/chunk-V7ONVBT4.js.map +0 -1
- /package/lib/{chunk-RWNFJKBC.js.map → chunk-3UW3O4RI.js.map} +0 -0
- /package/lib/{chunk-INM2JQXV.js.map → chunk-3XOMJPOV.js.map} +0 -0
- /package/lib/{chunk-57B2QEFU.js.map → chunk-ATNNVLSV.js.map} +0 -0
- /package/lib/{chunk-CIT277G3.js.map → chunk-CQUCT4WO.js.map} +0 -0
- /package/lib/{chunk-NF7SQC5T.js.map → chunk-DCBB6WSY.js.map} +0 -0
- /package/lib/{chunk-IRMT3JAE.js.map → chunk-E32G76ZD.js.map} +0 -0
- /package/lib/{chunk-45NSVYWS.js.map → chunk-HYBAVEVS.js.map} +0 -0
- /package/lib/{chunk-EDLEFVHW.js.map → chunk-MEWILSVR.js.map} +0 -0
- /package/lib/{chunk-33Y7LZTL.js.map → chunk-OSRVBU5W.js.map} +0 -0
- /package/lib/{chunk-XCZJCPWS.js.map → chunk-PJJSNY3A.js.map} +0 -0
- /package/lib/{chunk-VG7IARUK.js.map → chunk-STFYLBQW.js.map} +0 -0
- /package/lib/{chunk-RFTTBMZW.js.map → chunk-US7CSPMG.js.map} +0 -0
- /package/lib/{chunk-TLJXINOL.js.map → chunk-WESN5VPX.js.map} +0 -0
- /package/lib/{chunk-JWIM4IJV.js.map → chunk-WS3R3PHZ.js.map} +0 -0
- /package/lib/{chunk-XMZYAXTX.js.map → chunk-ZXTBG7Q4.js.map} +0 -0
- /package/lib/{chunk-VGSWB3RH.js.map → chunk-ZXUK2KRA.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
|
|
2
|
-
import{a as I,b,d as lt}from"./chunk-TTG5P3RD.js";import{Ac as W,Bc as rt,Bd as it,Cc as nt,Dc as ot,Dd as E,E as m,Ec as $,Fd as Q,Hd as ct,Ic as at,Yb as A,ja as tt,oc as F,pc as K,qc as et,rc as B,sc as R,tc as L,uc as O,vc as z}from"./chunk-MEXIWEPZ.js";import{b as st}from"./chunk-T2GZNU62.js";import{a as u,f as q}from"./chunk-G5BIPHMS.js";import{errorString as M,GLOBAL_CONFIG as Y,mergeProcessResults as Z,Plugin as xt,PluginManager as wt,USER_PROCESSOR as Nt}from"@sentio/runtime";var h=q(st(),1);import{MapStateStorage as It}from"@sentio/runtime";var T=class r extends It{static{u(this,"FuelProcessorState")}static INSTANCE=new r};import("node:process").then(r=>r.stdout.write(""));import{FuelChainId as dt}from"@sentio/chain";import{Endpoints as Ct}from"@sentio/runtime";var Tt={MAIN_NET:dt.FUEL_MAINNET,TEST_NET:dt.FUEL_TESTNET};function bt(r){switch(r){case Tt.TEST_NET:return"https://testnet.fuel.network/v1/graphql"}return"https://mainnet.fuel.network/v1/graphql"}u(bt,"getRpcEndpoint");async function H(r){let t=Ct.INSTANCE.chainServer.get(r);return t||(t=bt(r)),new ot(t)}u(H,"getProvider");import("node:process").then(r=>r.stdout.write(""));var S=class{constructor(t,e,n,s,l){this.args=s;this.logs=l}static{u(this,"FuelCall")}},y=class extends it{constructor(e,n,s,l,o,c){super({});this.chainId=e;this.contractAddress=n;this.contractName=s;this.timestamp=l;this.transaction=o;this.block=c}static{u(this,"FuelContext")}logIndex=-1;getChainId(){return this.chainId}setLogIndex(e){this.logIndex=e}getMetaDataInternal(e,n){return{address:this.contractAddress,contractName:this.contractName,blockNumber:BigInt(this.block?.height?.toString()??(this.transaction?.blockNumber||0)),transactionIndex:0,transactionHash:this.transaction?.id||"",chainId:this.getChainId(),name:e,logIndex:this.logIndex,labels:at(n)}}},N=class extends y{constructor(e,n,s,l,o,c,a){super(e,n?.id?.toString()??s,l,o,c,a);this.contract=n}static{u(this,"FuelContractContext")}get provider(){return this.contract?.provider}};import("node:process").then(r=>r.stdout.write(""));var v={includeFailed:!1};function ut(r,t){for(let e of r||[])if(e.type==R.Coin&&e.assetId==t)return e.owner}u(ut,"findSenderFromInputs");async function x(r,t){let e=K(r.rawPayload),n=r?.status.receipts?.map(W)||[],s;try{let[P]=new z().decode(e,0);s=P}catch(P){throw console.error("Failed to decode transaction payload:",P,"payload",Buffer.from(e).toString("hex")),P}let{gasCosts:l,feeParameters:o,txParameters:c,baseAssetId:a}=(await t.getChain()).consensusParameters,i=r.status?.block?.header?.height,{gasPriceFactor:d,gasPerByte:f}=o,{maxInputs:g,maxGasPerTx:C}=c,p={type:r.status?.__typename,...r.status};return{...rt({id:r.id,receipts:n,transaction:s,transactionBytes:e,gqlTransactionStatus:p,gasPerByte:F(f),gasPriceFactor:F(d),maxInputs:g,gasCosts:l,gasPrice:F(r.gasPrice),maxGasPerTx:C,baseAssetId:a}),blockNumber:i,sender:ut(s.inputs,a)}}u(x,"decodeFuelTransaction");function _(r,t){try{if(r&&(r.type===O.LogData||r.type===O.Log)){let e=new B(t),n=r.type===O.Log?new et("u64").encode(r.val0):r.data,s=r.rb.toString(),[l]=e.decodeLog(n,s);return{logId:s,data:l}}return null}catch(e){throw console.error("Failed to decode log",e,"Please make sure you provide the correct abi.",e,"receipt",r,"abi",t),e}}u(_,"decodeLog");async function D(r,t,e){let n=K(r.rawPayload),[s]=new z().decode(n,0),l=r?.status.receipts?.map(W)||[],o={type:r.status?.__typename,...r.status},c=o?.block?.header?.height,a=Object.values(t)[0],i=[];l.forEach((g,C)=>{try{let p=_(g,a);p&&i.push({...p,receiptIndex:C})}catch(p){console.warn("Failed to decode log",p)}});let d=new nt(r.status.transactionId,e,await e.getChainId(),{main:Object.values(t)[0],otherContractsAbis:{}});return d.gqlTransaction={...r,status:o},{...await d.getTransactionSummary(),blockNumber:c,logs:i,sender:ut(s.inputs,(await e.getChain()).consensusParameters.baseAssetId)}}u(D,"decodeFuelTransactionWithAbi");import("node:process").then(r=>r.stdout.write(""));var V=q(st(),1);var k=class r{constructor(t){this.config=t;return b(this)}static{u(this,"FuelProcessor")}txHandlers=[];blockHandlers=[];receiptHandlers=[];provider;static bind(t){let e=new r(t);return Pt(t,e),e}latestGasPrice;async configure(){this.provider=await H(this.config.chainId),this.provider.getLatestGasPrice=async()=>{if(this.latestGasPrice)return F(this.latestGasPrice);let{latestGasPrice:t}=await this.provider.operations.getLatestGasPrice();return this.latestGasPrice=t?.gasPrice,F(t.gasPrice)},this.config.address}getContract(t){let e,n=t?.transaction?.inputContract?.contractID;if(!n){for(let s of t?.transaction?.inputs??[])if(s.type==R.Contract){n=s.contractID;break}}return n?e=new $(n,this.config.abi,this.provider):this.config.address!="*"&&(e=new $(this.config.address,this.config.abi,this.provider)),e}onTransaction(t,e,n=I()){let s={handlerName:n,handler:u(async l=>{let o=this.config.abi?{[this.config.address]:this.config.abi}:{},c=await D(l.transaction,o,this.provider),a=new N(this.config.chainId,this.getContract(c),this.config.address,this.config.name??this.config.address,l.timestamp||new Date(0),c,null);return await t(c,a),a.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...e},partitionHandler:u(async l=>{let o=e?.partitionKey;if(o){if(typeof o=="function"){let c=this.config.abi?{[this.config.address]:this.config.abi}:{},a=await D(l.transaction,c,this.provider);return o(a)}return o}},"partitionHandler")};return this.txHandlers.push(s),this}onCall(t,e,n=v){let s=new Set(Array.isArray(t)?t:[t]);if(!this.config.abi)throw new Error("ABI must be provided to use onCall");let l=this.config.abi,o={},c=new B(l);for(let i of s)try{let d=c.functions[i],f=F(d.selector,"hex").toString();o[d.name]={function:f,includeFailed:!!n.includeFailed}}catch(d){console.error(d)}let a={handlerName:I(),handler:u(async i=>{try{let d=i.transaction,f=await D(d,{[this.config.address]:l},this.provider),g=new y(this.config.chainId,this.config.address,this.config.name??this.config.address,i.timestamp||new Date(0),f,null);for(let C of f.operations)for(let p of C.calls||[])if(s.has(p.functionName)){let P=this.getContract(f)?.functions[p.functionName];if(!P)continue;let gt=Object.values(p.argumentsProvided||{}),mt=P(...gt),Ft=new S(mt,f,!1,p.argumentsProvided,f.logs);await e(Ft,g)}return g.stopAndGetResult()}catch(d){return console.error(d),A.fromPartial({})}},"handler"),fetchConfig:{filters:Object.values(o)}};return this.txHandlers.push(a),this}onLog(t,e,n,s=I()){let l=new Set(Array.isArray(t)?t:[t]),o={handlerName:s,handler:u(async({transaction:c,receiptIndex:a,timestamp:i})=>{try{let d=await x(c,this.provider),f=Number(a),g=d.receipts[f],C=_(g,this.config.abi);if(C){let p=new N(this.config.chainId,this.getContract(d),this.config.address,this.config.name??this.config.address,i||new Date(0),d,null);return p.setLogIndex(f),await e({receiptIndex:f,...C},p),p.stopAndGetResult()}else console.error(`Log with receipt index ${a} not found in tx`)}catch(d){console.error(d)}return A.fromPartial({})},"handler"),receiptConfig:{log:{logIds:Array.from(l)}},partitionHandler:u(async c=>{let a=n?.partitionKey;if(a){if(typeof a=="function"){try{let i=await x(c.transaction,this.provider),d=Number(c.receiptIndex),f=i.receipts[d],g=_(f,this.config.abi);if(g)return a({receiptIndex:d,...g})}catch(i){console.error(i)}return}return a}},"partitionHandler")};return this.receiptHandlers.push(o),this}onTransfer(t,e,n){let{from:s,to:l,assetId:o}=t,c={handlerName:I(),handler:u(async({transaction:a,receiptIndex:i,timestamp:d})=>{try{let f=await x(a,this.provider),g=Number(i),C=f.receipts[g],p=new N(this.config.chainId,this.getContract(f),this.config.address,this.config.name??this.config.address,d||new Date(0),f,null);p.setLogIndex(g),await e(C,p)}catch(f){console.error(f)}return A.fromPartial({})},"handler"),receiptConfig:{transfer:{from:s,to:l,assetId:o}},partitionHandler:u(async a=>{let i=n?.partitionKey;if(i){if(typeof i=="function"){try{let d=await x(a.transaction,this.provider),f=Number(a.receiptIndex),g=d.receipts[f];return i(g)}catch(d){console.error(d)}return}return i}},"partitionHandler")};return this.receiptHandlers.push(c),this}onInterval(t,e,n,s,l=I()){e&&e.backfillInterval<e.recentInterval&&(e.backfillInterval=e.recentInterval);let o=this;return this.blockHandlers.push({blockInterval:n,timeIntervalInMinutes:e,handlerName:l,handler:u(async function(c){let a=c.block;if(!a)throw new V.ServerError(V.Status.INVALID_ARGUMENT,"Block is empty");let i={id:a.id,height:F(a.height),time:a.time,header:{applicationHash:a.applicationHash,daHeight:F(a.daHeight),eventInboxRoot:a.eventInboxRoot,messageOutboxRoot:a.messageOutboxRoot,prevRoot:a.prevRoot,stateTransitionBytecodeVersion:a.stateTransitionBytecodeVersion,transactionsCount:a.transactionsCount,transactionsRoot:a.transactionsRoot}},d=o.getContract(),f=new N(o.config.chainId,d,o.config.address,o.config.name??o.config.address,c.timestamp||new Date(0),null,i);return await t(i,f),f.stopAndGetResult()},"handler"),partitionHandler:u(async c=>{let a=s?.partitionKey;if(a){if(typeof a=="function"){let i=c.block;if(!i)return;let d={id:i.id,height:F(i.height),time:i.time,header:{applicationHash:i.applicationHash,daHeight:F(i.daHeight),eventInboxRoot:i.eventInboxRoot,messageOutboxRoot:i.messageOutboxRoot,prevRoot:i.prevRoot,stateTransitionBytecodeVersion:i.stateTransitionBytecodeVersion,transactionsCount:i.transactionsCount,transactionsRoot:i.transactionsRoot}};return a(d)}return a}},"partitionHandler")}),this}onBlockInterval(t,e=250,n=1e3,s){return this.onInterval(t,void 0,{recentInterval:e,backfillInterval:n},s)}onTimeInterval(t,e=60,n=240,s){return this.onInterval(t,{recentInterval:e,backfillInterval:n},void 0,s)}};function w(r){let t=[r.address];return r.chainId&&t.push(r.chainId),r.name&&t.push(r.name),r.startBlock&&t.push(r.startBlock.toString()),r.endBlock&&t.push(r.endBlock.toString()),t.join("_")}u(w,"getOptionsSignature");function Te(r){let t=w(r);return T.INSTANCE.getValue(t)}u(Te,"getFuelProcessor");function Pt(r,t){let e=w(r);T.INSTANCE.getOrSetValue(e,t)}u(Pt,"addFuelProcessor");import("node:process").then(r=>r.stdout.write(""));var U=class r{constructor(t){this.config=t;return b(this)}static{u(this,"FuelAssetProcessor")}txHandlers=[];blockHandlers=[];provider;static bind(t){let e=new r(t),n="assets_"+w({...t,address:"*"});return T.INSTANCE.getOrSetValue(n,e),e}async configure(){this.provider=await H(this.config.chainId)}onTransfer(t,e){let n=[],s=X(t.assetId),l=X(t.from),o=X(t.to);for(let a of s)for(let i of l)for(let d of o)n.push({assetId:a,fromAddress:i,toAddress:d});let c={handlerName:I(),handler:u(async a=>{let i=a.transaction,d=await x(i,this.provider),f={from:[],to:[]},g="";for(let p of d.transaction.inputs||[])p.type==R.Coin&&(f.from.push({address:p.owner,assetId:p.assetId,amount:BigInt(p.amount.toString(10))}),g=p.assetId);for(let p of d.transaction.outputs||[])switch(p.type){case L.Change:case L.Coin:case L.Variable:let P=p.amount.toString(10);f.to.push({address:p.to,amount:BigInt(P),assetId:p.assetId}),g==""&&(g=p.assetId)}let C=new y(this.config.chainId,g,this.config.name??"",a.timestamp||new Date(0),d,null);return await e(f,C),C.stopAndGetResult()},"handler"),assetConfig:{filters:n}};return this.txHandlers.push(c),this}};function X(r){return r?Array.isArray(r)?r.length>0?r:[void 0]:[r]:[void 0]}u(X,"arrayify");import("node:process").then(r=>r.stdout.write(""));import{mergeProcessResults as yt}from"@sentio/runtime";var G=class r{constructor(t){this.config=t;return b(this)}static{u(this,"FuelGlobalProcessor")}txHandlers=[];blockHandlers=[];provider;static bind(t){let e=new r(t),n="global_"+w({...t,address:Q});return T.INSTANCE.getOrSetValue(n,e),e}async configure(){this.provider=await H(this.config.chainId)}onTransaction(t,e=v){let n={handlerName:I(),handler:u(async s=>{let l;try{l=await x(s.transaction,this.provider)}catch(a){return console.error("error decoding transaction",a),yt([])}let o=s.transaction?.status.block.header,c=new y(this.config.chainId,Q,this.config.name??"*",s.timestamp||new Date(0),l,o?{header:{daHeight:F(o.daHeight)}}:null);return await t(l,c),c.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...e}};return this.txHandlers.push(n),this}};import("node:process").then(r=>r.stdout.write(""));var j=class extends xt{static{u(this,"FuelPlugin")}name="FuelPlugin";handlerRegister=new lt;partitionManager=new ct;async init(t){for(let e of T.INSTANCE.getValues()){let n=e.config.chainId;t.chainIds.push(n)}}async configure(t,e){this.handlerRegister.clear(e);for(let n of T.INSTANCE.getValues()){let s=n.config.chainId;if(e!==void 0&&e!==s.toString())continue;let l=n.config,o=tt.fromPartial({processorType:Nt,contract:{name:l.name,chainId:l.chainId.toString(),address:l.address||"*",abi:""},startBlock:l.startBlock,endBlock:l.endBlock});for(let c of n.txHandlers){let a=this.handlerRegister.register(c.handler,s);this.partitionManager.registerPartitionHandler(m.FUEL_TRANSACTION,a,c.partitionHandler);let i=c.handlerName;if(n instanceof k){let d={handlerId:a,handlerName:i};o.fuelTransactionConfigs.push(d)}else if(n instanceof U){let d=c.assetConfig;o.assetConfigs.push({filters:d?.filters||[],handlerId:a,handlerName:i})}else if(n instanceof G){let d={handlerId:a,handlerName:i,filters:[]};o.fuelTransactionConfigs.push(d),o.contract.address="*"}}for(let c of n.receiptHandlers??[]){let a=this.handlerRegister.register(c.handler,s);this.partitionManager.registerPartitionHandler(m.FUEL_RECEIPT,a,c.partitionHandler);let i=c.handlerName;n instanceof k&&o.fuelReceiptConfigs.push({...c.receiptConfig,handlerId:a,handlerName:i})}for(let c of n.blockHandlers){let a=this.handlerRegister.register(c.handler,s);this.partitionManager.registerPartitionHandler(m.FUEL_BLOCK,a,c.partitionHandler),o.intervalConfigs.push({slot:0,slotInterval:c.blockInterval,minutes:0,minutesInterval:c.timeIntervalInMinutes,handlerId:a,handlerName:c.handlerName,fetchConfig:void 0})}t.contractConfigs.push(o)}}supportedHandlers=[m.FUEL_TRANSACTION,m.FUEL_RECEIPT,m.FUEL_CALL,m.FUEL_BLOCK];processBinding(t){switch(t.handlerType){case m.FUEL_TRANSACTION:return this.processTransaction(t);case m.FUEL_RECEIPT:return this.processReceipt(t);case m.FUEL_BLOCK:return this.processBlock(t);default:throw new h.ServerError(h.Status.INVALID_ARGUMENT,"No handle type registered "+t.handlerType)}}async partition(t){let e;switch(t.handlerType){case m.FUEL_TRANSACTION:if(!t.data?.fuelTransaction)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"fuelTransaction can't be empty");e=t.data.fuelTransaction;break;case m.FUEL_RECEIPT:if(!t.data?.fuelLog)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"fuelReceipt can't be empty");e=t.data.fuelLog;break;case m.FUEL_BLOCK:if(!t.data?.fuelBlock)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"fuelBlock can't be empty");e=t.data.fuelBlock;break;case m.FUEL_CALL:if(!t.data?.fuelTransaction)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"fuelTransaction can't be empty for FUEL_CALL");e=t.data.fuelTransaction;break;default:throw new h.ServerError(h.Status.INVALID_ARGUMENT,"No handle type registered "+t.handlerType)}return{partitions:await this.partitionManager.processPartitionForHandlerType(t.handlerType,t.handlerIds,e)}}async start(t){try{for(let e of T.INSTANCE.getValues())await e.configure()}catch(e){throw new h.ServerError(h.Status.INTERNAL,"error starting FuelPlugin: "+M(e))}}stateDiff(t){return E.INSTANCE.getValues().length!==t.templateInstances.length}async processReceipt(t){let e=t?.data?.fuelLog;if(!e?.transaction)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"transaction can't be null");let n=[];for(let s of t.handlerIds){let l=this.handlerRegister.getHandlerById(t.chainId,s)(e).catch(o=>{throw new h.ServerError(h.Status.INTERNAL,"error processing transaction: "+JSON.stringify(e)+`
|
|
2
|
+
import{a as I,b,d as lt}from"./chunk-TTG5P3RD.js";import{Ac as W,Bc as rt,Bd as it,Cc as nt,Dc as ot,Dd as E,E as m,Ec as $,Fd as Q,Hd as ct,Ic as at,Yb as A,ja as tt,oc as F,pc as K,qc as et,rc as B,sc as R,tc as L,uc as O,vc as z}from"./chunk-4CH3FO2Y.js";import{b as st}from"./chunk-T2GZNU62.js";import{a as u,f as q}from"./chunk-G5BIPHMS.js";import{errorString as M,GLOBAL_CONFIG as Y,mergeProcessResults as Z,Plugin as xt,PluginManager as wt,USER_PROCESSOR as Nt}from"@sentio/runtime";var h=q(st(),1);import{MapStateStorage as It}from"@sentio/runtime";var T=class r extends It{static{u(this,"FuelProcessorState")}static INSTANCE=new r};import("node:process").then(r=>r.stdout.write(""));import{FuelChainId as dt}from"@sentio/chain";import{Endpoints as Ct}from"@sentio/runtime";var Tt={MAIN_NET:dt.FUEL_MAINNET,TEST_NET:dt.FUEL_TESTNET};function bt(r){switch(r){case Tt.TEST_NET:return"https://testnet.fuel.network/v1/graphql"}return"https://mainnet.fuel.network/v1/graphql"}u(bt,"getRpcEndpoint");async function H(r){let t=Ct.INSTANCE.chainServer.get(r);return t||(t=bt(r)),new ot(t)}u(H,"getProvider");import("node:process").then(r=>r.stdout.write(""));var S=class{constructor(t,e,n,s,l){this.args=s;this.logs=l}static{u(this,"FuelCall")}},y=class extends it{constructor(e,n,s,l,o,c){super({});this.chainId=e;this.contractAddress=n;this.contractName=s;this.timestamp=l;this.transaction=o;this.block=c}static{u(this,"FuelContext")}logIndex=-1;getChainId(){return this.chainId}setLogIndex(e){this.logIndex=e}getMetaDataInternal(e,n){return{address:this.contractAddress,contractName:this.contractName,blockNumber:BigInt(this.block?.height?.toString()??(this.transaction?.blockNumber||0)),transactionIndex:0,transactionHash:this.transaction?.id||"",chainId:this.getChainId(),name:e,logIndex:this.logIndex,labels:at(n)}}},N=class extends y{constructor(e,n,s,l,o,c,a){super(e,n?.id?.toString()??s,l,o,c,a);this.contract=n}static{u(this,"FuelContractContext")}get provider(){return this.contract?.provider}};import("node:process").then(r=>r.stdout.write(""));var v={includeFailed:!1};function ut(r,t){for(let e of r||[])if(e.type==R.Coin&&e.assetId==t)return e.owner}u(ut,"findSenderFromInputs");async function x(r,t){let e=K(r.rawPayload),n=r?.status.receipts?.map(W)||[],s;try{let[P]=new z().decode(e,0);s=P}catch(P){throw console.error("Failed to decode transaction payload:",P,"payload",Buffer.from(e).toString("hex")),P}let{gasCosts:l,feeParameters:o,txParameters:c,baseAssetId:a}=(await t.getChain()).consensusParameters,i=r.status?.block?.header?.height,{gasPriceFactor:d,gasPerByte:f}=o,{maxInputs:g,maxGasPerTx:C}=c,p={type:r.status?.__typename,...r.status};return{...rt({id:r.id,receipts:n,transaction:s,transactionBytes:e,gqlTransactionStatus:p,gasPerByte:F(f),gasPriceFactor:F(d),maxInputs:g,gasCosts:l,gasPrice:F(r.gasPrice),maxGasPerTx:C,baseAssetId:a}),blockNumber:i,sender:ut(s.inputs,a)}}u(x,"decodeFuelTransaction");function _(r,t){try{if(r&&(r.type===O.LogData||r.type===O.Log)){let e=new B(t),n=r.type===O.Log?new et("u64").encode(r.val0):r.data,s=r.rb.toString(),[l]=e.decodeLog(n,s);return{logId:s,data:l}}return null}catch(e){throw console.error("Failed to decode log",e,"Please make sure you provide the correct abi.",e,"receipt",r,"abi",t),e}}u(_,"decodeLog");async function D(r,t,e){let n=K(r.rawPayload),[s]=new z().decode(n,0),l=r?.status.receipts?.map(W)||[],o={type:r.status?.__typename,...r.status},c=o?.block?.header?.height,a=Object.values(t)[0],i=[];l.forEach((g,C)=>{try{let p=_(g,a);p&&i.push({...p,receiptIndex:C})}catch(p){console.warn("Failed to decode log",p)}});let d=new nt(r.status.transactionId,e,await e.getChainId(),{main:Object.values(t)[0],otherContractsAbis:{}});return d.gqlTransaction={...r,status:o},{...await d.getTransactionSummary(),blockNumber:c,logs:i,sender:ut(s.inputs,(await e.getChain()).consensusParameters.baseAssetId)}}u(D,"decodeFuelTransactionWithAbi");import("node:process").then(r=>r.stdout.write(""));var V=q(st(),1);var k=class r{constructor(t){this.config=t;return b(this)}static{u(this,"FuelProcessor")}txHandlers=[];blockHandlers=[];receiptHandlers=[];provider;static bind(t){let e=new r(t);return Pt(t,e),e}latestGasPrice;async configure(){this.provider=await H(this.config.chainId),this.provider.getLatestGasPrice=async()=>{if(this.latestGasPrice)return F(this.latestGasPrice);let{latestGasPrice:t}=await this.provider.operations.getLatestGasPrice();return this.latestGasPrice=t?.gasPrice,F(t.gasPrice)},this.config.address}getContract(t){let e,n=t?.transaction?.inputContract?.contractID;if(!n){for(let s of t?.transaction?.inputs??[])if(s.type==R.Contract){n=s.contractID;break}}return n?e=new $(n,this.config.abi,this.provider):this.config.address!="*"&&(e=new $(this.config.address,this.config.abi,this.provider)),e}onTransaction(t,e,n=I()){let s={handlerName:n,handler:u(async l=>{let o=this.config.abi?{[this.config.address]:this.config.abi}:{},c=await D(l.transaction,o,this.provider),a=new N(this.config.chainId,this.getContract(c),this.config.address,this.config.name??this.config.address,l.timestamp||new Date(0),c,null);return await t(c,a),a.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...e},partitionHandler:u(async l=>{let o=e?.partitionKey;if(o){if(typeof o=="function"){let c=this.config.abi?{[this.config.address]:this.config.abi}:{},a=await D(l.transaction,c,this.provider);return o(a)}return o}},"partitionHandler")};return this.txHandlers.push(s),this}onCall(t,e,n=v){let s=new Set(Array.isArray(t)?t:[t]);if(!this.config.abi)throw new Error("ABI must be provided to use onCall");let l=this.config.abi,o={},c=new B(l);for(let i of s)try{let d=c.functions[i],f=F(d.selector,"hex").toString();o[d.name]={function:f,includeFailed:!!n.includeFailed}}catch(d){console.error(d)}let a={handlerName:I(),handler:u(async i=>{try{let d=i.transaction,f=await D(d,{[this.config.address]:l},this.provider),g=new y(this.config.chainId,this.config.address,this.config.name??this.config.address,i.timestamp||new Date(0),f,null);for(let C of f.operations)for(let p of C.calls||[])if(s.has(p.functionName)){let P=this.getContract(f)?.functions[p.functionName];if(!P)continue;let gt=Object.values(p.argumentsProvided||{}),mt=P(...gt),Ft=new S(mt,f,!1,p.argumentsProvided,f.logs);await e(Ft,g)}return g.stopAndGetResult()}catch(d){return console.error(d),A.fromPartial({})}},"handler"),fetchConfig:{filters:Object.values(o)}};return this.txHandlers.push(a),this}onLog(t,e,n,s=I()){let l=new Set(Array.isArray(t)?t:[t]),o={handlerName:s,handler:u(async({transaction:c,receiptIndex:a,timestamp:i})=>{try{let d=await x(c,this.provider),f=Number(a),g=d.receipts[f],C=_(g,this.config.abi);if(C){let p=new N(this.config.chainId,this.getContract(d),this.config.address,this.config.name??this.config.address,i||new Date(0),d,null);return p.setLogIndex(f),await e({receiptIndex:f,...C},p),p.stopAndGetResult()}else console.error(`Log with receipt index ${a} not found in tx`)}catch(d){console.error(d)}return A.fromPartial({})},"handler"),receiptConfig:{log:{logIds:Array.from(l)}},partitionHandler:u(async c=>{let a=n?.partitionKey;if(a){if(typeof a=="function"){try{let i=await x(c.transaction,this.provider),d=Number(c.receiptIndex),f=i.receipts[d],g=_(f,this.config.abi);if(g)return a({receiptIndex:d,...g})}catch(i){console.error(i)}return}return a}},"partitionHandler")};return this.receiptHandlers.push(o),this}onTransfer(t,e,n){let{from:s,to:l,assetId:o}=t,c={handlerName:I(),handler:u(async({transaction:a,receiptIndex:i,timestamp:d})=>{try{let f=await x(a,this.provider),g=Number(i),C=f.receipts[g],p=new N(this.config.chainId,this.getContract(f),this.config.address,this.config.name??this.config.address,d||new Date(0),f,null);p.setLogIndex(g),await e(C,p)}catch(f){console.error(f)}return A.fromPartial({})},"handler"),receiptConfig:{transfer:{from:s,to:l,assetId:o}},partitionHandler:u(async a=>{let i=n?.partitionKey;if(i){if(typeof i=="function"){try{let d=await x(a.transaction,this.provider),f=Number(a.receiptIndex),g=d.receipts[f];return i(g)}catch(d){console.error(d)}return}return i}},"partitionHandler")};return this.receiptHandlers.push(c),this}onInterval(t,e,n,s,l=I()){e&&e.backfillInterval<e.recentInterval&&(e.backfillInterval=e.recentInterval);let o=this;return this.blockHandlers.push({blockInterval:n,timeIntervalInMinutes:e,handlerName:l,handler:u(async function(c){let a=c.block;if(!a)throw new V.ServerError(V.Status.INVALID_ARGUMENT,"Block is empty");let i={id:a.id,height:F(a.height),time:a.time,header:{applicationHash:a.applicationHash,daHeight:F(a.daHeight),eventInboxRoot:a.eventInboxRoot,messageOutboxRoot:a.messageOutboxRoot,prevRoot:a.prevRoot,stateTransitionBytecodeVersion:a.stateTransitionBytecodeVersion,transactionsCount:a.transactionsCount,transactionsRoot:a.transactionsRoot}},d=o.getContract(),f=new N(o.config.chainId,d,o.config.address,o.config.name??o.config.address,c.timestamp||new Date(0),null,i);return await t(i,f),f.stopAndGetResult()},"handler"),partitionHandler:u(async c=>{let a=s?.partitionKey;if(a){if(typeof a=="function"){let i=c.block;if(!i)return;let d={id:i.id,height:F(i.height),time:i.time,header:{applicationHash:i.applicationHash,daHeight:F(i.daHeight),eventInboxRoot:i.eventInboxRoot,messageOutboxRoot:i.messageOutboxRoot,prevRoot:i.prevRoot,stateTransitionBytecodeVersion:i.stateTransitionBytecodeVersion,transactionsCount:i.transactionsCount,transactionsRoot:i.transactionsRoot}};return a(d)}return a}},"partitionHandler")}),this}onBlockInterval(t,e=250,n=1e3,s){return this.onInterval(t,void 0,{recentInterval:e,backfillInterval:n},s)}onTimeInterval(t,e=60,n=240,s){return this.onInterval(t,{recentInterval:e,backfillInterval:n},void 0,s)}};function w(r){let t=[r.address];return r.chainId&&t.push(r.chainId),r.name&&t.push(r.name),r.startBlock&&t.push(r.startBlock.toString()),r.endBlock&&t.push(r.endBlock.toString()),t.join("_")}u(w,"getOptionsSignature");function Te(r){let t=w(r);return T.INSTANCE.getValue(t)}u(Te,"getFuelProcessor");function Pt(r,t){let e=w(r);T.INSTANCE.getOrSetValue(e,t)}u(Pt,"addFuelProcessor");import("node:process").then(r=>r.stdout.write(""));var U=class r{constructor(t){this.config=t;return b(this)}static{u(this,"FuelAssetProcessor")}txHandlers=[];blockHandlers=[];provider;static bind(t){let e=new r(t),n="assets_"+w({...t,address:"*"});return T.INSTANCE.getOrSetValue(n,e),e}async configure(){this.provider=await H(this.config.chainId)}onTransfer(t,e){let n=[],s=X(t.assetId),l=X(t.from),o=X(t.to);for(let a of s)for(let i of l)for(let d of o)n.push({assetId:a,fromAddress:i,toAddress:d});let c={handlerName:I(),handler:u(async a=>{let i=a.transaction,d=await x(i,this.provider),f={from:[],to:[]},g="";for(let p of d.transaction.inputs||[])p.type==R.Coin&&(f.from.push({address:p.owner,assetId:p.assetId,amount:BigInt(p.amount.toString(10))}),g=p.assetId);for(let p of d.transaction.outputs||[])switch(p.type){case L.Change:case L.Coin:case L.Variable:let P=p.amount.toString(10);f.to.push({address:p.to,amount:BigInt(P),assetId:p.assetId}),g==""&&(g=p.assetId)}let C=new y(this.config.chainId,g,this.config.name??"",a.timestamp||new Date(0),d,null);return await e(f,C),C.stopAndGetResult()},"handler"),assetConfig:{filters:n}};return this.txHandlers.push(c),this}};function X(r){return r?Array.isArray(r)?r.length>0?r:[void 0]:[r]:[void 0]}u(X,"arrayify");import("node:process").then(r=>r.stdout.write(""));import{mergeProcessResults as yt}from"@sentio/runtime";var G=class r{constructor(t){this.config=t;return b(this)}static{u(this,"FuelGlobalProcessor")}txHandlers=[];blockHandlers=[];provider;static bind(t){let e=new r(t),n="global_"+w({...t,address:Q});return T.INSTANCE.getOrSetValue(n,e),e}async configure(){this.provider=await H(this.config.chainId)}onTransaction(t,e=v){let n={handlerName:I(),handler:u(async s=>{let l;try{l=await x(s.transaction,this.provider)}catch(a){return console.error("error decoding transaction",a),yt([])}let o=s.transaction?.status.block.header,c=new y(this.config.chainId,Q,this.config.name??"*",s.timestamp||new Date(0),l,o?{header:{daHeight:F(o.daHeight)}}:null);return await t(l,c),c.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...e}};return this.txHandlers.push(n),this}};import("node:process").then(r=>r.stdout.write(""));var j=class extends xt{static{u(this,"FuelPlugin")}name="FuelPlugin";handlerRegister=new lt;partitionManager=new ct;async init(t){for(let e of T.INSTANCE.getValues()){let n=e.config.chainId;t.chainIds.push(n)}}async configure(t,e){this.handlerRegister.clear(e);for(let n of T.INSTANCE.getValues()){let s=n.config.chainId;if(e!==void 0&&e!==s.toString())continue;let l=n.config,o=tt.fromPartial({processorType:Nt,contract:{name:l.name,chainId:l.chainId.toString(),address:l.address||"*",abi:""},startBlock:l.startBlock,endBlock:l.endBlock});for(let c of n.txHandlers){let a=this.handlerRegister.register(c.handler,s);this.partitionManager.registerPartitionHandler(m.FUEL_TRANSACTION,a,c.partitionHandler);let i=c.handlerName;if(n instanceof k){let d={handlerId:a,handlerName:i};o.fuelTransactionConfigs.push(d)}else if(n instanceof U){let d=c.assetConfig;o.assetConfigs.push({filters:d?.filters||[],handlerId:a,handlerName:i})}else if(n instanceof G){let d={handlerId:a,handlerName:i,filters:[]};o.fuelTransactionConfigs.push(d),o.contract.address="*"}}for(let c of n.receiptHandlers??[]){let a=this.handlerRegister.register(c.handler,s);this.partitionManager.registerPartitionHandler(m.FUEL_RECEIPT,a,c.partitionHandler);let i=c.handlerName;n instanceof k&&o.fuelReceiptConfigs.push({...c.receiptConfig,handlerId:a,handlerName:i})}for(let c of n.blockHandlers){let a=this.handlerRegister.register(c.handler,s);this.partitionManager.registerPartitionHandler(m.FUEL_BLOCK,a,c.partitionHandler),o.intervalConfigs.push({slot:0,slotInterval:c.blockInterval,minutes:0,minutesInterval:c.timeIntervalInMinutes,handlerId:a,handlerName:c.handlerName,fetchConfig:void 0})}t.contractConfigs.push(o)}}supportedHandlers=[m.FUEL_TRANSACTION,m.FUEL_RECEIPT,m.FUEL_CALL,m.FUEL_BLOCK];processBinding(t){switch(t.handlerType){case m.FUEL_TRANSACTION:return this.processTransaction(t);case m.FUEL_RECEIPT:return this.processReceipt(t);case m.FUEL_BLOCK:return this.processBlock(t);default:throw new h.ServerError(h.Status.INVALID_ARGUMENT,"No handle type registered "+t.handlerType)}}async partition(t){let e;switch(t.handlerType){case m.FUEL_TRANSACTION:if(!t.data?.fuelTransaction)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"fuelTransaction can't be empty");e=t.data.fuelTransaction;break;case m.FUEL_RECEIPT:if(!t.data?.fuelLog)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"fuelReceipt can't be empty");e=t.data.fuelLog;break;case m.FUEL_BLOCK:if(!t.data?.fuelBlock)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"fuelBlock can't be empty");e=t.data.fuelBlock;break;case m.FUEL_CALL:if(!t.data?.fuelTransaction)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"fuelTransaction can't be empty for FUEL_CALL");e=t.data.fuelTransaction;break;default:throw new h.ServerError(h.Status.INVALID_ARGUMENT,"No handle type registered "+t.handlerType)}return{partitions:await this.partitionManager.processPartitionForHandlerType(t.handlerType,t.handlerIds,e)}}async start(t){try{for(let e of T.INSTANCE.getValues())await e.configure()}catch(e){throw new h.ServerError(h.Status.INTERNAL,"error starting FuelPlugin: "+M(e))}}stateDiff(t){return E.INSTANCE.getValues().length!==t.templateInstances.length}async processReceipt(t){let e=t?.data?.fuelLog;if(!e?.transaction)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"transaction can't be null");let n=[];for(let s of t.handlerIds){let l=this.handlerRegister.getHandlerById(t.chainId,s)(e).catch(o=>{throw new h.ServerError(h.Status.INTERNAL,"error processing transaction: "+JSON.stringify(e)+`
|
|
3
3
|
`+M(o))});Y.execution.sequential&&await l,n.push(l)}return Z(await Promise.all(n))}async processTransaction(t){if(!t.data?.fuelTransaction?.transaction)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"transaction can't be null");let e=t.data.fuelTransaction,n=[];for(let s of t.handlerIds){let l=this.handlerRegister.getHandlerById(t.chainId,s)(e).catch(o=>{throw new h.ServerError(h.Status.INTERNAL,"error processing transaction: "+JSON.stringify(e.transaction)+`
|
|
4
4
|
`+M(o))});Y.execution.sequential&&await l,n.push(l)}return Z(await Promise.all(n))}async processBlock(t){if(!t.data?.fuelBlock?.block)throw new h.ServerError(h.Status.INVALID_ARGUMENT,"Block can't be empty");let e=t.data.fuelBlock,n=[];for(let s of t.handlerIds){let l=this.handlerRegister.getHandlerById(t.chainId,s)(e).catch(o=>{throw console.error("error processing block: ",o),new h.ServerError(h.Status.INTERNAL,"error processing block: "+e.block?.height+`
|
|
5
5
|
`+M(o))});Y.execution.sequential&&await l,n.push(l)}return Z(await Promise.all(n))}};wt.INSTANCE.register(new j);import("node:process").then(r=>r.stdout.write(""));import{ListStateStorage as kt}from"@sentio/runtime";var J=class r extends kt{static{u(this,"FuelProcessorTemplateProcessorState")}static INSTANCE=new r},ft=class{static{u(this,"FuelBaseProcessorTemplate")}id;binds=new Set;blockHandlers=[];logHandlers=[];transactionHandlers=[];constructor(){return this.id=J.INSTANCE.getValues().length,J.INSTANCE.addValue(this),b(this)}bind(t,e){let n=w({address:t.address,chainId:e.chainId});if(this.binds.has(n)){console.log(`Same address can be bind to one template only once, ignore duplicate bind: ${n}`);return}this.binds.add(n);let s=this.bindInternal({...t,chainId:e.chainId});for(let o of this.logHandlers)s.onLog(o.logIdFilter,o.handler,o.handlerOptions,o.handlerName);for(let o of this.blockHandlers)s.onInterval(o.handler,o.timeIntervalInMinutes,o.blockInterval,o.handlerOptions,o.handlerName);for(let o of this.transactionHandlers)s.onTransaction(o.handler,o.handlerOptions,o.handlerName);let l={templateId:this.id,contract:{address:t.address,name:t.name||"",chainId:e.chainId,abi:""},startBlock:BigInt(t.startBlock||0),endBlock:BigInt(t.endBlock||0),baseLabels:{}};E.INSTANCE.addValue(l),e.update({states:{configUpdated:!0}})}onLog(t,e,n={}){return this.logHandlers.push({logIdFilter:t,handlerName:I(),handler:e,handlerOptions:n}),this}onBlockInterval(t,e=1e3,n=4e3){return this.onInterval(t,void 0,{recentInterval:e,backfillInterval:n})}onTimeInterval(t,e=60,n=240){return this.onInterval(t,{recentInterval:e,backfillInterval:n},void 0)}onInterval(t,e,n,s={}){return this.blockHandlers.push({handlerName:I(),handler:t,timeIntervalInMinutes:e,blockInterval:n,handlerOptions:s}),this}onTransaction(t,e=v){return this.transactionHandlers.push({handlerName:I(),handler:t,handlerOptions:e}),this}};import("node:process").then(r=>r.stdout.write(""));import{FuelChainId as Rt}from"@sentio/chain";var pt=class extends k{static{u(this,"FuelAbstractProcessor")}constructor(t,e){return e||(e={chainId:Rt.FUEL_MAINNET,address:"*"}),super({...e,abi:t}),b(this)}},ht=class{static{u(this,"TypedCall")}args;returnValue;argsObject;logs};import("node:process").then(r=>r.stdout.write(""));import("node:process").then(r=>r.stdout.write(""));export{T as a,Tt as b,bt as c,H as d,S as e,y as f,N as g,v as h,x as i,_ as j,D as k,k as l,w as m,Te as n,Pt as o,U as p,G as q,j as r,J as s,ft as t,pt as u,ht as v};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-PJJSNY3A.js.map
|