@sentio/sdk-bundle 2.57.6 → 2.57.7-rc.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/btc/index.js +1 -1
- package/lib/{chunk-OSGWCETR.js → chunk-47ROPUTI.js} +2 -2
- package/lib/{chunk-AH5F7424.js → chunk-7LRLMZ2R.js} +2 -2
- package/lib/{chunk-MXGFKFWL.js → chunk-CGAPKM4X.js} +2 -2
- package/lib/chunk-DS2LOABN.js +3 -0
- package/lib/chunk-DS2LOABN.js.map +1 -0
- package/lib/{chunk-FKVU72SD.js → chunk-EKY3AYVC.js} +2 -2
- package/lib/{chunk-T5ZWWDR3.js → chunk-EOYTRF5D.js} +2 -2
- package/lib/{chunk-AFT43SGS.js → chunk-JDXUKJQ4.js} +2 -2
- package/lib/{chunk-QXO44PWW.js → chunk-KIESPDK2.js} +2 -2
- package/lib/chunk-KNV3FDUD.js +32 -0
- package/lib/chunk-KNV3FDUD.js.map +1 -0
- package/lib/{chunk-GY56IKIO.js → chunk-MHTDLKHZ.js} +2 -2
- package/lib/{chunk-Y2L3VTNW.js → chunk-NK2D7BI5.js} +2 -2
- package/lib/{chunk-WPZZ3ADX.js → chunk-NSA57BNP.js} +2 -2
- package/lib/{chunk-DDVYPPD6.js → chunk-NYKX56LS.js} +2 -2
- package/lib/{chunk-2YQIIWLW.js → chunk-RLXGQEGB.js} +2 -2
- package/lib/{chunk-QIPKYK5K.js → chunk-RMM5W53S.js} +2 -2
- package/lib/{chunk-KJEKGUSP.js → chunk-ULGQYWKO.js} +2 -2
- package/lib/{chunk-2AL4DHUZ.js → chunk-X4DAYPSG.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/fuel/index.js +1 -1
- package/lib/stark/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-4WNGQ3EZ.js +0 -3
- package/lib/chunk-4WNGQ3EZ.js.map +0 -1
- package/lib/chunk-UUYHTLBU.js +0 -32
- package/lib/chunk-UUYHTLBU.js.map +0 -1
- /package/lib/{chunk-OSGWCETR.js.map → chunk-47ROPUTI.js.map} +0 -0
- /package/lib/{chunk-AH5F7424.js.map → chunk-7LRLMZ2R.js.map} +0 -0
- /package/lib/{chunk-MXGFKFWL.js.map → chunk-CGAPKM4X.js.map} +0 -0
- /package/lib/{chunk-FKVU72SD.js.map → chunk-EKY3AYVC.js.map} +0 -0
- /package/lib/{chunk-T5ZWWDR3.js.map → chunk-EOYTRF5D.js.map} +0 -0
- /package/lib/{chunk-AFT43SGS.js.map → chunk-JDXUKJQ4.js.map} +0 -0
- /package/lib/{chunk-QXO44PWW.js.map → chunk-KIESPDK2.js.map} +0 -0
- /package/lib/{chunk-GY56IKIO.js.map → chunk-MHTDLKHZ.js.map} +0 -0
- /package/lib/{chunk-Y2L3VTNW.js.map → chunk-NK2D7BI5.js.map} +0 -0
- /package/lib/{chunk-WPZZ3ADX.js.map → chunk-NSA57BNP.js.map} +0 -0
- /package/lib/{chunk-DDVYPPD6.js.map → chunk-NYKX56LS.js.map} +0 -0
- /package/lib/{chunk-2YQIIWLW.js.map → chunk-RLXGQEGB.js.map} +0 -0
- /package/lib/{chunk-QIPKYK5K.js.map → chunk-RMM5W53S.js.map} +0 -0
- /package/lib/{chunk-KJEKGUSP.js.map → chunk-ULGQYWKO.js.map} +0 -0
- /package/lib/{chunk-2AL4DHUZ.js.map → chunk-X4DAYPSG.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 g,b as T}from"./chunk-4WNGQ3EZ.js";import{a as le}from"./chunk-HRZJHNIM.js";import{Ac as R,Bc as A,Cc as te,Cd as K,D as b,Dc as B,Dd as re,Ec as j,Ed as ne,Fd as oe,Gd as se,Ib as M,Ld as ae,W as q,Yb as I,Zb as J,Zd as ie,ce,he as L,je as W,zc as ee}from"./chunk-LZ2L3BVP.js";import{a as c,f as w}from"./chunk-G5BIPHMS.js";import{errorString as O,GLOBAL_CONFIG as Y,mergeProcessResults as Z,Plugin as ye,PluginManager as ke,USER_PROCESSOR as Ne}from"@sentio/runtime";var m=w(ie(),1);import{MapStateStorage as Ce}from"@sentio/runtime";var C=class r extends Ce{static{c(this,"FuelProcessorState")}static INSTANCE=new r};import("node:process").then(r=>r.stdout.write(""));var $=w(le(),1);import{Endpoints as Ie}from"@sentio/runtime";var Te={MAIN_NET:$.FuelChainId.FUEL_MAINNET,TEST_NET:$.FuelChainId.FUEL_TESTNET};function Pe(r){switch(r){case Te.TEST_NET:return"https://testnet.fuel.network/v1/graphql"}return"https://mainnet.fuel.network/v1/graphql"}c(Pe,"getRpcEndpoint");function H(r){let e=Ie.INSTANCE.chainServer.get(r);return e||(e=Pe(r)),oe.create(e)}c(H,"getProvider");import("node:process").then(r=>r.stdout.write(""));var S=class{constructor(e,t,n,a,s){this.args=a;this.logs=s}static{c(this,"FuelCall")}},P=class extends ce{constructor(t,n,a,s,o,i){super({});this.chainId=t;this.contractAddress=n;this.contractName=a;this.timestamp=s;this.transaction=o;this.block=i}static{c(this,"FuelContext")}logIndex=-1;getChainId(){return this.chainId}setLogIndex(t){this.logIndex=t}getMetaDataInternal(t,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:t,logIndex:this.logIndex,labels:ae(n)}}},y=class extends P{constructor(t,n,a,s,o,i,l){super(t,a,s,o,i,l);this.chainId=t;this.contract=n;this.contractAddress=a;this.contractName=s;this.timestamp=o;this.transaction=i;this.block=l}static{c(this,"FuelContractContext")}get provider(){return this.contract.provider}};import("node:process").then(r=>r.stdout.write(""));var k={includeFailed:!1};function de(r,e){for(let t of r||[])if(t.type==A.Coin&&t.assetId==e)return t.owner}c(de,"findSenderFromInputs");function N(r,e){let t=J(r.rawPayload),n=r?.status.receipts?.map(K)||[],[a]=new j().decode(t,0),{gasCosts:s,feeParameters:o,txParameters:i,baseAssetId:l}=e.getChain().consensusParameters,d=r.status?.block?.header?.height,{gasPriceFactor:u,gasPerByte:p}=o,{maxInputs:F,maxGasPerTx:h}=i,f={type:r.status?.__typename,...r.status};return{...re({id:r.id,receipts:n,transaction:a,transactionBytes:t,gqlTransactionStatus:f,gasPerByte:I(p),gasPriceFactor:I(u),maxInputs:F,gasCosts:s,gasPrice:I(r.gasPrice),maxGasPerTx:h,baseAssetId:l}),blockNumber:d,sender:de(a.inputs,l)}}c(N,"decodeFuelTransaction");function z(r,e){if(r&&(r.type===B.LogData||r.type===B.Log)){let t=new R(e),n=r.type===B.Log?new ee("u64").encode(r.val0):r.data,a=r.val1.toString(),[s]=t.decodeLog(n,a);return{logId:a,data:s}}return null}c(z,"decodeLog");async function Q(r,e,t){let n=J(r.rawPayload),[a]=new j().decode(n,0),s=r?.status.receipts?.map(K)||[],o={type:r.status?.__typename,...r.status},i=o?.block?.header?.height,l=Object.values(e)[0],d=[];s.forEach((F,h)=>{try{let f=z(F,l);f&&d.push({...f,receiptIndex:h})}catch(f){console.warn("Failed to decode log",f)}});let u=new ne(r.status.transactionId,t,{main:Object.values(e)[0],otherContractsAbis:{}});return u.gqlTransaction={...r,status:o},{...await u.getTransactionSummary(),blockNumber:i,logs:d,sender:de(a.inputs,t.getChain().consensusParameters.baseAssetId)}}c(Q,"decodeFuelTransactionWithAbi");import("node:process").then(r=>r.stdout.write(""));var E=w(ie(),1);var v=class r{constructor(e){this.config=e;return T(this)}static{c(this,"FuelProcessor")}txHandlers=[];blockHandlers=[];receiptHandlers=[];provider;contract;static bind(e){let t=new r(e);return be(e,t),t}latestGasPrice;async configure(){this.provider=await H(this.config.chainId),this.provider.getLatestGasPrice=async()=>{if(this.latestGasPrice)return I(this.latestGasPrice);let{latestGasPrice:e}=await this.provider.operations.getLatestGasPrice();return this.latestGasPrice=e?.gasPrice,I(e.gasPrice)},this.contract=new se(this.config.address,this.config.abi,this.provider)}onTransaction(e,t=k,n=g()){let a={handlerName:n,handler:c(async s=>{let o=this.config.abi?{[this.config.address]:this.config.abi}:{},i=await Q(s.transaction,o,this.provider),l=new y(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,s.timestamp||new Date(0),i,null);return await e(i,l),l.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...t}};return this.txHandlers.push(a),this}onCall(e,t,n=k){let a=new Set(Array.isArray(e)?e:[e]);if(!this.config.abi)throw new Error("ABI must be provided to use onCall");let s=this.config.abi,o={},i=new R(s);for(let d of a)try{let u=i.functions[d],p=I(u.selector,"hex").toString();o[u.name]={function:p,includeFailed:!!n.includeFailed}}catch(u){console.error(u)}let l={handlerName:g(),handler:c(async d=>{try{let u=d.transaction,p=await Q(u,{[this.config.address]:s},this.provider),F=new P(this.config.chainId,this.config.address,this.config.name??this.config.address,d.timestamp||new Date(0),p,null);for(let h of p.operations)for(let f of h.calls||[])if(a.has(f.functionName)){let U=this.contract.functions[f.functionName],he=Object.values(f.argumentsProvided||{}),ge=U(...he),Fe=new S(ge,p,!1,f.argumentsProvided,p.logs);await t(Fe,F)}return F.stopAndGetResult()}catch(u){return console.error(u),{gauges:[],counters:[],events:[],exports:[],states:{configUpdated:!1}}}},"handler"),fetchConfig:{filters:Object.values(o)}};return this.txHandlers.push(l),this}onLog(e,t,n=g()){let a=new Set(Array.isArray(e)?e:[e]),s={handlerName:n,handler:c(async({transaction:o,receiptIndex:i,timestamp:l})=>{try{let d=N(o,this.provider),u=Number(i),p=d.receipts[u],F=z(p,this.config.abi);if(F){let h=new y(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,l||new Date(0),d,null);return h.setLogIndex(u),await t({receiptIndex:u,...F},h),h.stopAndGetResult()}else console.error(`Log with receipt index ${i} not found in tx`)}catch(d){console.error(d)}return M.fromPartial({})},"handler"),receiptConfig:{log:{logIds:Array.from(a)}}};return this.receiptHandlers.push(s),this}onTransfer(e,t){let{from:n,to:a,assetId:s}=e,o={handlerName:g(),handler:c(async({transaction:i,receiptIndex:l,timestamp:d})=>{try{let u=N(i,this.provider),p=Number(l),F=u.receipts[p],h=new y(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,d||new Date(0),u,null);h.setLogIndex(p),await t(F,h)}catch(u){console.error(u)}return M.fromPartial({})},"handler"),receiptConfig:{transfer:{from:n,to:a,assetId:s}}};return this.receiptHandlers.push(o),this}onInterval(e,t,n,a=g()){t&&t.backfillInterval<t.recentInterval&&(t.backfillInterval=t.recentInterval);let s=this;return this.blockHandlers.push({blockInterval:n,timeIntervalInMinutes:t,handlerName:a,handler:c(async function(o){let i=o.block;if(!i)throw new E.ServerError(E.Status.INVALID_ARGUMENT,"Block is empty");let l={id:i.id,height:I(i.height),time:i.time,header:{applicationHash:i.applicationHash,daHeight:I(i.daHeight),eventInboxRoot:i.eventInboxRoot,messageOutboxRoot:i.messageOutboxRoot,prevRoot:i.prevRoot,stateTransitionBytecodeVersion:i.stateTransitionBytecodeVersion,transactionsCount:i.transactionsCount,transactionsRoot:i.transactionsRoot}},d=new y(s.config.chainId,s.contract,s.config.address,s.config.name??s.config.address,o.timestamp||new Date(0),null,l);return await e(l,d),d.stopAndGetResult()},"handler")}),this}onBlockInterval(e,t=250,n=1e3){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:n})}onTimeInterval(e,t=60,n=240){return this.onInterval(e,{recentInterval:t,backfillInterval:n},void 0)}};function x(r){let e=[r.address];return r.chainId&&e.push(r.chainId),r.name&&e.push(r.name),r.startBlock&&e.push(r.startBlock.toString()),r.endBlock&&e.push(r.endBlock.toString()),e.join("_")}c(x,"getOptionsSignature");function Ct(r){let e=x(r);return C.INSTANCE.getValue(e)}c(Ct,"getFuelProcessor");function be(r,e){let t=x(r);C.INSTANCE.getOrSetValue(t,e)}c(be,"addFuelProcessor");import("node:process").then(r=>r.stdout.write(""));var _=class r{constructor(e){this.config=e;return T(this)}static{c(this,"FuelAssetProcessor")}txHandlers=[];blockHandlers=[];provider;static bind(e){let t=new r(e),n="assets_"+x({...e,address:"*"});return C.INSTANCE.getOrSetValue(n,t),t}async configure(){this.provider=await H(this.config.chainId)}onTransfer(e,t){let n=[],a=X(e.assetId),s=X(e.from),o=X(e.to);for(let l of a)for(let d of s)for(let u of o)n.push({assetId:l,fromAddress:d,toAddress:u});let i={handlerName:g(),handler:c(async l=>{let d=l.transaction,u=N(d,this.provider),p={from:[],to:[]};for(let f of u.transaction.inputs||[])f.type==A.Coin&&p.from.push({address:f.owner,assetId:f.assetId,amount:BigInt(f.amount.toString(10))});for(let f of u.transaction.outputs||[])if(f.type==te.Coin){let U=f.amount.toString(10);p.to.push({address:f.to,amount:BigInt(U),assetId:f.assetId})}let F=p.from[0].assetId||"",h=new P(this.config.chainId,F,this.config.name??"",l.timestamp||new Date(0),u,null);return await t(p,h),h.stopAndGetResult()},"handler"),assetConfig:{filters:n}};return this.txHandlers.push(i),this}};function X(r){return r?Array.isArray(r)?r.length>0?r:[void 0]:[r]:[void 0]}c(X,"arrayify");import("node:process").then(r=>r.stdout.write(""));import{mergeProcessResults as xe}from"@sentio/runtime";var D=class r{constructor(e){this.config=e;return T(this)}static{c(this,"FuelGlobalProcessor")}txHandlers=[];blockHandlers=[];provider;static bind(e){let t=new r(e),n="global_"+x({...e,address:W});return C.INSTANCE.getOrSetValue(n,t),t}async configure(){this.provider=await H(this.config.chainId)}onTransaction(e,t=k){let n={handlerName:g(),handler:c(async a=>{let s;try{s=N(a.transaction,this.provider)}catch(i){return console.error("error decoding transaction",i),xe([])}let o=new P(this.config.chainId,W,this.config.name??"*",a.timestamp||new Date(0),s,null);return await e(s,o),o.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...t}};return this.txHandlers.push(n),this}};import("node:process").then(r=>r.stdout.write(""));var V=class extends ye{static{c(this,"FuelPlugin")}name="FuelPlugin";handlers={transactionHandlers:[],blockHandlers:[],receiptHandlers:[]};async configure(e){let t={transactionHandlers:[],blockHandlers:[],receiptHandlers:[]};for(let n of C.INSTANCE.getValues()){let a=n.config,s=q.fromPartial({processorType:Ne,contract:{name:a.name,chainId:a.chainId.toString(),address:a.address||"*",abi:""},startBlock:a.startBlock,endBlock:a.endBlock});for(let o of n.txHandlers){let i=t.transactionHandlers.push(o.handler)-1,l=o.handlerName;if(n instanceof v){let d={handlerId:i,handlerName:l};s.fuelTransactionConfigs.push(d)}else if(n instanceof _){let d=o.assetConfig;s.assetConfigs.push({filters:d?.filters||[],handlerId:i,handlerName:l})}else if(n instanceof D){let d={handlerId:i,handlerName:l,filters:[]};s.fuelTransactionConfigs.push(d),s.contract.address="*"}}for(let o of n.receiptHandlers??[]){let i=t.receiptHandlers.push(o.handler)-1,l=o.handlerName;n instanceof v&&s.fuelReceiptConfigs.push({...o.receiptConfig,handlerId:i,handlerName:l})}for(let o of n.blockHandlers){let i=t.blockHandlers.push(o.handler)-1;s.intervalConfigs.push({slot:0,slotInterval:o.blockInterval,minutes:0,minutesInterval:o.timeIntervalInMinutes,handlerId:i,handlerName:o.handlerName,fetchConfig:void 0})}e.contractConfigs.push(s)}this.handlers=t}supportedHandlers=[b.FUEL_TRANSACTION,b.FUEL_RECEIPT,b.FUEL_CALL,b.FUEL_BLOCK];processBinding(e){switch(e.handlerType){case b.FUEL_TRANSACTION:return this.processTransaction(e);case b.FUEL_RECEIPT:return this.processReceipt(e);case b.FUEL_BLOCK:return this.processBlock(e);default:throw new m.ServerError(m.Status.INVALID_ARGUMENT,"No handle type registered "+e.handlerType)}}async start(e){try{for(let t of C.INSTANCE.getValues())await t.configure()}catch(t){throw new m.ServerError(m.Status.INTERNAL,"error starting FuelPlugin: "+O(t))}}stateDiff(e){return L.INSTANCE.getValues().length!==e.templateInstances.length}async processReceipt(e){let t=e?.data?.fuelLog;if(!t?.transaction)throw new m.ServerError(m.Status.INVALID_ARGUMENT,"transaction can't be null");let n=[];for(let a of e.handlerIds){let s=this.handlers.receiptHandlers[a](t).catch(o=>{throw new m.ServerError(m.Status.INTERNAL,"error processing transaction: "+JSON.stringify(t)+`
|
|
2
|
+
import{a as g,b as T}from"./chunk-DS2LOABN.js";import{a as le}from"./chunk-HRZJHNIM.js";import{Ac as R,Bc as A,Cc as te,Cd as K,D as b,Dc as B,Dd as re,Ec as j,Ed as ne,Fd as oe,Gd as se,Ib as M,Ld as ae,W as q,Yb as I,Zb as J,Zd as ie,ce,he as L,je as W,zc as ee}from"./chunk-LZ2L3BVP.js";import{a as c,f as w}from"./chunk-G5BIPHMS.js";import{errorString as O,GLOBAL_CONFIG as Y,mergeProcessResults as Z,Plugin as ye,PluginManager as ke,USER_PROCESSOR as Ne}from"@sentio/runtime";var m=w(ie(),1);import{MapStateStorage as Ce}from"@sentio/runtime";var C=class r extends Ce{static{c(this,"FuelProcessorState")}static INSTANCE=new r};import("node:process").then(r=>r.stdout.write(""));var $=w(le(),1);import{Endpoints as Ie}from"@sentio/runtime";var Te={MAIN_NET:$.FuelChainId.FUEL_MAINNET,TEST_NET:$.FuelChainId.FUEL_TESTNET};function Pe(r){switch(r){case Te.TEST_NET:return"https://testnet.fuel.network/v1/graphql"}return"https://mainnet.fuel.network/v1/graphql"}c(Pe,"getRpcEndpoint");function H(r){let e=Ie.INSTANCE.chainServer.get(r);return e||(e=Pe(r)),oe.create(e)}c(H,"getProvider");import("node:process").then(r=>r.stdout.write(""));var S=class{constructor(e,t,n,a,s){this.args=a;this.logs=s}static{c(this,"FuelCall")}},P=class extends ce{constructor(t,n,a,s,o,i){super({});this.chainId=t;this.contractAddress=n;this.contractName=a;this.timestamp=s;this.transaction=o;this.block=i}static{c(this,"FuelContext")}logIndex=-1;getChainId(){return this.chainId}setLogIndex(t){this.logIndex=t}getMetaDataInternal(t,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:t,logIndex:this.logIndex,labels:ae(n)}}},y=class extends P{constructor(t,n,a,s,o,i,l){super(t,a,s,o,i,l);this.chainId=t;this.contract=n;this.contractAddress=a;this.contractName=s;this.timestamp=o;this.transaction=i;this.block=l}static{c(this,"FuelContractContext")}get provider(){return this.contract.provider}};import("node:process").then(r=>r.stdout.write(""));var k={includeFailed:!1};function de(r,e){for(let t of r||[])if(t.type==A.Coin&&t.assetId==e)return t.owner}c(de,"findSenderFromInputs");function N(r,e){let t=J(r.rawPayload),n=r?.status.receipts?.map(K)||[],[a]=new j().decode(t,0),{gasCosts:s,feeParameters:o,txParameters:i,baseAssetId:l}=e.getChain().consensusParameters,d=r.status?.block?.header?.height,{gasPriceFactor:u,gasPerByte:p}=o,{maxInputs:F,maxGasPerTx:h}=i,f={type:r.status?.__typename,...r.status};return{...re({id:r.id,receipts:n,transaction:a,transactionBytes:t,gqlTransactionStatus:f,gasPerByte:I(p),gasPriceFactor:I(u),maxInputs:F,gasCosts:s,gasPrice:I(r.gasPrice),maxGasPerTx:h,baseAssetId:l}),blockNumber:d,sender:de(a.inputs,l)}}c(N,"decodeFuelTransaction");function z(r,e){if(r&&(r.type===B.LogData||r.type===B.Log)){let t=new R(e),n=r.type===B.Log?new ee("u64").encode(r.val0):r.data,a=r.val1.toString(),[s]=t.decodeLog(n,a);return{logId:a,data:s}}return null}c(z,"decodeLog");async function Q(r,e,t){let n=J(r.rawPayload),[a]=new j().decode(n,0),s=r?.status.receipts?.map(K)||[],o={type:r.status?.__typename,...r.status},i=o?.block?.header?.height,l=Object.values(e)[0],d=[];s.forEach((F,h)=>{try{let f=z(F,l);f&&d.push({...f,receiptIndex:h})}catch(f){console.warn("Failed to decode log",f)}});let u=new ne(r.status.transactionId,t,{main:Object.values(e)[0],otherContractsAbis:{}});return u.gqlTransaction={...r,status:o},{...await u.getTransactionSummary(),blockNumber:i,logs:d,sender:de(a.inputs,t.getChain().consensusParameters.baseAssetId)}}c(Q,"decodeFuelTransactionWithAbi");import("node:process").then(r=>r.stdout.write(""));var E=w(ie(),1);var v=class r{constructor(e){this.config=e;return T(this)}static{c(this,"FuelProcessor")}txHandlers=[];blockHandlers=[];receiptHandlers=[];provider;contract;static bind(e){let t=new r(e);return be(e,t),t}latestGasPrice;async configure(){this.provider=await H(this.config.chainId),this.provider.getLatestGasPrice=async()=>{if(this.latestGasPrice)return I(this.latestGasPrice);let{latestGasPrice:e}=await this.provider.operations.getLatestGasPrice();return this.latestGasPrice=e?.gasPrice,I(e.gasPrice)},this.contract=new se(this.config.address,this.config.abi,this.provider)}onTransaction(e,t=k,n=g()){let a={handlerName:n,handler:c(async s=>{let o=this.config.abi?{[this.config.address]:this.config.abi}:{},i=await Q(s.transaction,o,this.provider),l=new y(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,s.timestamp||new Date(0),i,null);return await e(i,l),l.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...t}};return this.txHandlers.push(a),this}onCall(e,t,n=k){let a=new Set(Array.isArray(e)?e:[e]);if(!this.config.abi)throw new Error("ABI must be provided to use onCall");let s=this.config.abi,o={},i=new R(s);for(let d of a)try{let u=i.functions[d],p=I(u.selector,"hex").toString();o[u.name]={function:p,includeFailed:!!n.includeFailed}}catch(u){console.error(u)}let l={handlerName:g(),handler:c(async d=>{try{let u=d.transaction,p=await Q(u,{[this.config.address]:s},this.provider),F=new P(this.config.chainId,this.config.address,this.config.name??this.config.address,d.timestamp||new Date(0),p,null);for(let h of p.operations)for(let f of h.calls||[])if(a.has(f.functionName)){let U=this.contract.functions[f.functionName],he=Object.values(f.argumentsProvided||{}),ge=U(...he),Fe=new S(ge,p,!1,f.argumentsProvided,p.logs);await t(Fe,F)}return F.stopAndGetResult()}catch(u){return console.error(u),{gauges:[],counters:[],events:[],exports:[],states:{configUpdated:!1}}}},"handler"),fetchConfig:{filters:Object.values(o)}};return this.txHandlers.push(l),this}onLog(e,t,n=g()){let a=new Set(Array.isArray(e)?e:[e]),s={handlerName:n,handler:c(async({transaction:o,receiptIndex:i,timestamp:l})=>{try{let d=N(o,this.provider),u=Number(i),p=d.receipts[u],F=z(p,this.config.abi);if(F){let h=new y(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,l||new Date(0),d,null);return h.setLogIndex(u),await t({receiptIndex:u,...F},h),h.stopAndGetResult()}else console.error(`Log with receipt index ${i} not found in tx`)}catch(d){console.error(d)}return M.fromPartial({})},"handler"),receiptConfig:{log:{logIds:Array.from(a)}}};return this.receiptHandlers.push(s),this}onTransfer(e,t){let{from:n,to:a,assetId:s}=e,o={handlerName:g(),handler:c(async({transaction:i,receiptIndex:l,timestamp:d})=>{try{let u=N(i,this.provider),p=Number(l),F=u.receipts[p],h=new y(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,d||new Date(0),u,null);h.setLogIndex(p),await t(F,h)}catch(u){console.error(u)}return M.fromPartial({})},"handler"),receiptConfig:{transfer:{from:n,to:a,assetId:s}}};return this.receiptHandlers.push(o),this}onInterval(e,t,n,a=g()){t&&t.backfillInterval<t.recentInterval&&(t.backfillInterval=t.recentInterval);let s=this;return this.blockHandlers.push({blockInterval:n,timeIntervalInMinutes:t,handlerName:a,handler:c(async function(o){let i=o.block;if(!i)throw new E.ServerError(E.Status.INVALID_ARGUMENT,"Block is empty");let l={id:i.id,height:I(i.height),time:i.time,header:{applicationHash:i.applicationHash,daHeight:I(i.daHeight),eventInboxRoot:i.eventInboxRoot,messageOutboxRoot:i.messageOutboxRoot,prevRoot:i.prevRoot,stateTransitionBytecodeVersion:i.stateTransitionBytecodeVersion,transactionsCount:i.transactionsCount,transactionsRoot:i.transactionsRoot}},d=new y(s.config.chainId,s.contract,s.config.address,s.config.name??s.config.address,o.timestamp||new Date(0),null,l);return await e(l,d),d.stopAndGetResult()},"handler")}),this}onBlockInterval(e,t=250,n=1e3){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:n})}onTimeInterval(e,t=60,n=240){return this.onInterval(e,{recentInterval:t,backfillInterval:n},void 0)}};function x(r){let e=[r.address];return r.chainId&&e.push(r.chainId),r.name&&e.push(r.name),r.startBlock&&e.push(r.startBlock.toString()),r.endBlock&&e.push(r.endBlock.toString()),e.join("_")}c(x,"getOptionsSignature");function Ct(r){let e=x(r);return C.INSTANCE.getValue(e)}c(Ct,"getFuelProcessor");function be(r,e){let t=x(r);C.INSTANCE.getOrSetValue(t,e)}c(be,"addFuelProcessor");import("node:process").then(r=>r.stdout.write(""));var _=class r{constructor(e){this.config=e;return T(this)}static{c(this,"FuelAssetProcessor")}txHandlers=[];blockHandlers=[];provider;static bind(e){let t=new r(e),n="assets_"+x({...e,address:"*"});return C.INSTANCE.getOrSetValue(n,t),t}async configure(){this.provider=await H(this.config.chainId)}onTransfer(e,t){let n=[],a=X(e.assetId),s=X(e.from),o=X(e.to);for(let l of a)for(let d of s)for(let u of o)n.push({assetId:l,fromAddress:d,toAddress:u});let i={handlerName:g(),handler:c(async l=>{let d=l.transaction,u=N(d,this.provider),p={from:[],to:[]};for(let f of u.transaction.inputs||[])f.type==A.Coin&&p.from.push({address:f.owner,assetId:f.assetId,amount:BigInt(f.amount.toString(10))});for(let f of u.transaction.outputs||[])if(f.type==te.Coin){let U=f.amount.toString(10);p.to.push({address:f.to,amount:BigInt(U),assetId:f.assetId})}let F=p.from[0].assetId||"",h=new P(this.config.chainId,F,this.config.name??"",l.timestamp||new Date(0),u,null);return await t(p,h),h.stopAndGetResult()},"handler"),assetConfig:{filters:n}};return this.txHandlers.push(i),this}};function X(r){return r?Array.isArray(r)?r.length>0?r:[void 0]:[r]:[void 0]}c(X,"arrayify");import("node:process").then(r=>r.stdout.write(""));import{mergeProcessResults as xe}from"@sentio/runtime";var D=class r{constructor(e){this.config=e;return T(this)}static{c(this,"FuelGlobalProcessor")}txHandlers=[];blockHandlers=[];provider;static bind(e){let t=new r(e),n="global_"+x({...e,address:W});return C.INSTANCE.getOrSetValue(n,t),t}async configure(){this.provider=await H(this.config.chainId)}onTransaction(e,t=k){let n={handlerName:g(),handler:c(async a=>{let s;try{s=N(a.transaction,this.provider)}catch(i){return console.error("error decoding transaction",i),xe([])}let o=new P(this.config.chainId,W,this.config.name??"*",a.timestamp||new Date(0),s,null);return await e(s,o),o.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...t}};return this.txHandlers.push(n),this}};import("node:process").then(r=>r.stdout.write(""));var V=class extends ye{static{c(this,"FuelPlugin")}name="FuelPlugin";handlers={transactionHandlers:[],blockHandlers:[],receiptHandlers:[]};async configure(e){let t={transactionHandlers:[],blockHandlers:[],receiptHandlers:[]};for(let n of C.INSTANCE.getValues()){let a=n.config,s=q.fromPartial({processorType:Ne,contract:{name:a.name,chainId:a.chainId.toString(),address:a.address||"*",abi:""},startBlock:a.startBlock,endBlock:a.endBlock});for(let o of n.txHandlers){let i=t.transactionHandlers.push(o.handler)-1,l=o.handlerName;if(n instanceof v){let d={handlerId:i,handlerName:l};s.fuelTransactionConfigs.push(d)}else if(n instanceof _){let d=o.assetConfig;s.assetConfigs.push({filters:d?.filters||[],handlerId:i,handlerName:l})}else if(n instanceof D){let d={handlerId:i,handlerName:l,filters:[]};s.fuelTransactionConfigs.push(d),s.contract.address="*"}}for(let o of n.receiptHandlers??[]){let i=t.receiptHandlers.push(o.handler)-1,l=o.handlerName;n instanceof v&&s.fuelReceiptConfigs.push({...o.receiptConfig,handlerId:i,handlerName:l})}for(let o of n.blockHandlers){let i=t.blockHandlers.push(o.handler)-1;s.intervalConfigs.push({slot:0,slotInterval:o.blockInterval,minutes:0,minutesInterval:o.timeIntervalInMinutes,handlerId:i,handlerName:o.handlerName,fetchConfig:void 0})}e.contractConfigs.push(s)}this.handlers=t}supportedHandlers=[b.FUEL_TRANSACTION,b.FUEL_RECEIPT,b.FUEL_CALL,b.FUEL_BLOCK];processBinding(e){switch(e.handlerType){case b.FUEL_TRANSACTION:return this.processTransaction(e);case b.FUEL_RECEIPT:return this.processReceipt(e);case b.FUEL_BLOCK:return this.processBlock(e);default:throw new m.ServerError(m.Status.INVALID_ARGUMENT,"No handle type registered "+e.handlerType)}}async start(e){try{for(let t of C.INSTANCE.getValues())await t.configure()}catch(t){throw new m.ServerError(m.Status.INTERNAL,"error starting FuelPlugin: "+O(t))}}stateDiff(e){return L.INSTANCE.getValues().length!==e.templateInstances.length}async processReceipt(e){let t=e?.data?.fuelLog;if(!t?.transaction)throw new m.ServerError(m.Status.INVALID_ARGUMENT,"transaction can't be null");let n=[];for(let a of e.handlerIds){let s=this.handlers.receiptHandlers[a](t).catch(o=>{throw new m.ServerError(m.Status.INTERNAL,"error processing transaction: "+JSON.stringify(t)+`
|
|
3
3
|
`+O(o))});Y.execution.sequential&&await s,n.push(s)}return Z(await Promise.all(n))}async processTransaction(e){if(!e.data?.fuelTransaction?.transaction)throw new m.ServerError(m.Status.INVALID_ARGUMENT,"transaction can't be null");let t=e.data.fuelTransaction,n=[];for(let a of e.handlerIds){let s=this.handlers.transactionHandlers[a](t).catch(o=>{throw new m.ServerError(m.Status.INTERNAL,"error processing transaction: "+JSON.stringify(t.transaction)+`
|
|
4
4
|
`+O(o))});Y.execution.sequential&&await s,n.push(s)}return Z(await Promise.all(n))}async processBlock(e){if(!e.data?.fuelBlock?.block)throw new m.ServerError(m.Status.INVALID_ARGUMENT,"Block can't be empty");let t=e.data.fuelBlock,n=[];for(let a of e.handlerIds){let s=this.handlers.blockHandlers[a](t).catch(o=>{throw console.error("error processing block: ",o),new m.ServerError(m.Status.INTERNAL,"error processing block: "+t.block?.height+`
|
|
5
5
|
`+O(o))});Y.execution.sequential&&await s,n.push(s)}return Z(await Promise.all(n))}};ke.INSTANCE.register(new V);import("node:process").then(r=>r.stdout.write(""));import{ListStateStorage as ve}from"@sentio/runtime";var G=class r extends ve{static{c(this,"FuelProcessorTemplateProcessorState")}static INSTANCE=new r},ue=class{static{c(this,"FuelBaseProcessorTemplate")}id;binds=new Set;blockHandlers=[];logHandlers=[];transactionHandlers=[];constructor(){return this.id=G.INSTANCE.getValues().length,G.INSTANCE.addValue(this),T(this)}bind(e,t){let n=x({address:e.address,chainId:t.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 a=this.bindInternal({...e,chainId:t.chainId});for(let o of this.logHandlers)a.onLog(o.logIdFilter,o.handler,o.handlerName);for(let o of this.blockHandlers)a.onInterval(o.handler,o.timeIntervalInMinutes,o.blockInterval,o.handlerName);for(let o of this.transactionHandlers)a.onTransaction(o.handler,void 0,o.handlerName);let s={templateId:this.id,contract:{address:e.address,name:e.name||"",chainId:t.chainId,abi:""},startBlock:BigInt(e.startBlock||0),endBlock:BigInt(e.endBlock||0),baseLabels:{}};L.INSTANCE.addValue(s),t.update({states:{configUpdated:!0}})}onLog(e,t){return this.logHandlers.push({logIdFilter:e,handlerName:g(),handler:t}),this}onBlockInterval(e,t=1e3,n=4e3){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:n})}onTimeInterval(e,t=60,n=240){return this.onInterval(e,{recentInterval:t,backfillInterval:n},void 0)}onInterval(e,t,n){return this.blockHandlers.push({handlerName:g(),handler:e,timeIntervalInMinutes:t,blockInterval:n}),this}onTransaction(e,t=k){return this.transactionHandlers.push({handlerName:g(),handler:e,fetchConfig:t}),this}};import("node:process").then(r=>r.stdout.write(""));var me=w(le(),1);var fe=class extends v{static{c(this,"FuelAbstractProcessor")}constructor(e,t){return t||(t={chainId:me.FuelChainId.FUEL_MAINNET,address:"*"}),super({...t,abi:e}),T(this)}},pe=class{static{c(this,"TypedCall")}args;returnValue;argsObject;logs};import("node:process").then(r=>r.stdout.write(""));import("node:process").then(r=>r.stdout.write(""));export{C as a,Te as b,Pe as c,H as d,S as e,P as f,y as g,k as h,N as i,z as j,Q as k,v as l,x as m,Ct as n,be as o,_ as p,D as q,V as r,G as s,ue as t,fe as u,pe as v};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-NK2D7BI5.js.map
|