@sentio/sdk-bundle 2.54.0-rc.8 → 2.54.0
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-542NJB43.js → chunk-2AZ3DDYW.js} +2 -2
- package/lib/{chunk-CXGSRLW3.js → chunk-2SDXZNMS.js} +2 -2
- package/lib/{chunk-OW7PNQXI.js → chunk-4EPXEM2C.js} +2 -2
- package/lib/{chunk-WL2T4PIX.js → chunk-4R3P3DNX.js} +2 -2
- package/lib/{chunk-3KEEWCG3.js → chunk-C2Q4CM5A.js} +2 -2
- package/lib/{chunk-M6HSLAJ4.js → chunk-D4BGG4V2.js} +2 -2
- package/lib/{chunk-RFZC5JYC.js → chunk-DSXBXRSC.js} +2 -2
- package/lib/{chunk-4GQKFZWS.js → chunk-HYNPEPEK.js} +2 -2
- package/lib/{chunk-OVKYD5BL.js → chunk-ISDMCYZJ.js} +2 -2
- package/lib/{chunk-2JVSMCLK.js → chunk-JIW4UTB3.js} +2 -2
- package/lib/{chunk-GU4TPSPR.js → chunk-KBR5XLLQ.js} +2 -2
- package/lib/{chunk-65MPQCTW.js → chunk-M4IWP4I2.js} +184 -184
- package/lib/{chunk-65MPQCTW.js.map → chunk-M4IWP4I2.js.map} +1 -1
- package/lib/{chunk-XA5HI7QM.js → chunk-MWNHHNKW.js} +2 -2
- package/lib/{chunk-L4QQFA2V.js → chunk-NM2HNEFL.js} +2 -2
- package/lib/{chunk-5UWWL2KX.js → chunk-Q6B5XHC2.js} +2 -2
- package/lib/{chunk-5UWWL2KX.js.map → chunk-Q6B5XHC2.js.map} +1 -1
- package/lib/{chunk-6X3RJ7PD.js → chunk-TWWTSJR3.js} +2 -2
- package/lib/{chunk-VZY2WFNQ.js → chunk-V55TBLKA.js} +2 -2
- package/lib/{chunk-KMM5CTDH.js → chunk-VYQNLOTQ.js} +2 -2
- package/lib/{chunk-3A663CBX.js → chunk-WG3B6X5H.js} +2 -2
- package/lib/{chunk-FWJ7PQT3.js → chunk-YSEOUYZV.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/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/store/index.js.map +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 +144 -1
- package/lib/testing/index.js.map +1 -1
- package/lib/utils/index.js +1 -1
- package/package.json +2 -2
- /package/lib/{chunk-542NJB43.js.map → chunk-2AZ3DDYW.js.map} +0 -0
- /package/lib/{chunk-CXGSRLW3.js.map → chunk-2SDXZNMS.js.map} +0 -0
- /package/lib/{chunk-OW7PNQXI.js.map → chunk-4EPXEM2C.js.map} +0 -0
- /package/lib/{chunk-WL2T4PIX.js.map → chunk-4R3P3DNX.js.map} +0 -0
- /package/lib/{chunk-3KEEWCG3.js.map → chunk-C2Q4CM5A.js.map} +0 -0
- /package/lib/{chunk-M6HSLAJ4.js.map → chunk-D4BGG4V2.js.map} +0 -0
- /package/lib/{chunk-RFZC5JYC.js.map → chunk-DSXBXRSC.js.map} +0 -0
- /package/lib/{chunk-4GQKFZWS.js.map → chunk-HYNPEPEK.js.map} +0 -0
- /package/lib/{chunk-OVKYD5BL.js.map → chunk-ISDMCYZJ.js.map} +0 -0
- /package/lib/{chunk-2JVSMCLK.js.map → chunk-JIW4UTB3.js.map} +0 -0
- /package/lib/{chunk-GU4TPSPR.js.map → chunk-KBR5XLLQ.js.map} +0 -0
- /package/lib/{chunk-XA5HI7QM.js.map → chunk-MWNHHNKW.js.map} +0 -0
- /package/lib/{chunk-L4QQFA2V.js.map → chunk-NM2HNEFL.js.map} +0 -0
- /package/lib/{chunk-6X3RJ7PD.js.map → chunk-TWWTSJR3.js.map} +0 -0
- /package/lib/{chunk-VZY2WFNQ.js.map → chunk-V55TBLKA.js.map} +0 -0
- /package/lib/{chunk-KMM5CTDH.js.map → chunk-VYQNLOTQ.js.map} +0 -0
- /package/lib/{chunk-3A663CBX.js.map → chunk-WG3B6X5H.js.map} +0 -0
- /package/lib/{chunk-FWJ7PQT3.js.map → chunk-YSEOUYZV.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 C,b as T}from"./chunk-4WNGQ3EZ.js";import{a as de}from"./chunk-IVMOWPFA.js";import{$c as oe,B as b,Db as ee,Pd as ce,Tb as F,U as q,Ub as M,Ud as R,Wd as K,_c as j,ad as ne,bd as se,cd as ae,ed as ie,td as le,uc as te,vc as A,wc as B,xc as re,yc as L,zc as J}from"./chunk-65MPQCTW.js";import{a as i,f as H}from"./chunk-G5BIPHMS.js";import{errorString as O,GLOBAL_CONFIG as Y,mergeProcessResults as Z,Plugin as ye,PluginManager as ke,USER_PROCESSOR as ve}from"@sentio/runtime";var f=H(le(),1);import{MapStateStorage as Ie}from"@sentio/runtime";var h=class r extends Ie{static{i(this,"FuelProcessorState")}static INSTANCE=new r};import("node:process").then(r=>r.stdout.write(""));var W=H(de(),1);import{Endpoints as Pe}from"@sentio/runtime";var be={MAIN_NET:W.FuelChainId.FUEL_MAINNET,TEST_NET:W.FuelChainId.FUEL_TESTNET};function Te(r){switch(r){case be.TEST_NET:return"https://testnet.fuel.network/v1/graphql"}return"https://mainnet.fuel.network/v1/graphql"}i(Te,"getRpcEndpoint");function v(r){let e=Pe.INSTANCE.chainServer.get(r);return e||(e=Te(r)),se.create(e)}i(v,"getProvider");import("node:process").then(r=>r.stdout.write(""));var S=class{constructor(e,t,o,a,s){this.args=a;this.logs=s}static{i(this,"FuelCall")}},I=class extends ce{constructor(t,o,a,s,n,c){super({});this.chainId=t;this.contractAddress=o;this.contractName=a;this.timestamp=s;this.transaction=n;this.block=c}static{i(this,"FuelContext")}logIndex=-1;getChainId(){return this.chainId}setLogIndex(t){this.logIndex=t}getMetaDataInternal(t,o){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:ie(o)}}},N=class extends I{constructor(t,o,a,s,n,c,l){super(t,a,s,n,c,l);this.chainId=t;this.contract=o;this.contractAddress=a;this.contractName=s;this.timestamp=n;this.transaction=c;this.block=l}static{i(this,"FuelContractContext")}get provider(){return this.contract.provider}};import("node:process").then(r=>r.stdout.write(""));var y={includeFailed:!1};function ue(r,e){for(let t of r||[])if(t.type==B.Coin&&t.assetId==e)return t.owner}i(ue,"findSenderFromInputs");function w(r,e){let t=M(r.rawPayload),o=r?.status.receipts?.map(j)||[],[a]=new J().decode(t,0),{gasCosts:s,feeParameters:n,txParameters:c,baseAssetId:l}=e.getChain().consensusParameters,g=r.status?.block?.header?.height,{gasPriceFactor:d,gasPerByte:m}=n,{maxInputs:p,maxGasPerTx:P}=c,u={type:r.status?.__typename,...r.status};return{...oe({id:r.id,receipts:o,transaction:a,transactionBytes:t,gqlTransactionStatus:u,gasPerByte:F(m),gasPriceFactor:F(d),maxInputs:p,gasCosts:s,gasPrice:F(r.gasPrice),maxGasPerTx:P,baseAssetId:l}),blockNumber:g,sender:ue(a.inputs,l)}}i(w,"decodeFuelTransaction");function $(r,e){if(r&&(r.type===L.LogData||r.type===L.Log)){let t=new A(e),o=r.type===L.Log?new te("u64").encode(r.val0):r.data,a=r.val1.toString(),[s]=t.decodeLog(o,a);return{logId:a,data:s}}return null}i($,"decodeLog");async function z(r,e,t){let o=M(r.rawPayload),[a]=new J().decode(o,0),s=r?.status.receipts?.map(j)||[],n={type:r.status?.__typename,...r.status},c=n?.block?.header?.height,l=Object.values(e)[0],g=[];s.forEach((p,P)=>{try{let u=$(p,l);u&&g.push({...u,receiptIndex:P})}catch(u){console.warn("Failed to decode log",u)}});let d=new ne(r.status.transactionId,t,{main:Object.values(e)[0],otherContractsAbis:{}});return d.gqlTransaction={...r,status:n},{...await d.getTransactionSummary(),blockNumber:c,logs:g,sender:ue(a.inputs,t.getChain().consensusParameters.baseAssetId)}}i(z,"decodeFuelTransactionWithAbi");import("node:process").then(r=>r.stdout.write(""));var E=H(le(),1);var k=class r{constructor(e){this.config=e;return T(this)}static{i(this,"FuelProcessor")}callHandlers=[];blockHandlers=[];logHandlers=[];provider;contract;static bind(e){let t=new r(e);return Q(e,t),t}latestGasPrice;async configure(){this.provider=await v(this.config.chainId),this.provider.getLatestGasPrice=async()=>{if(this.latestGasPrice)return F(this.latestGasPrice);let{latestGasPrice:e}=await this.provider.operations.getLatestGasPrice();return this.latestGasPrice=e?.gasPrice,F(e.gasPrice)},this.contract=new ae(this.config.address,this.config.abi,this.provider)}onTransaction(e,t=y){let o={handlerName:C(),handler:i(async a=>{let s=this.config.abi?{[this.config.address]:this.config.abi}:{},n=await z(a.transaction,s,this.provider),c=new N(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,a.timestamp||new Date(0),n,null);return await e(n,c),c.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...t}};return this.callHandlers.push(o),this}onCall(e,t,o=y){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,n={},c=new A(s);for(let g of a)try{let d=c.functions[g],m=F(d.selector,"hex").toString();n[d.name]={function:m,includeFailed:!!o.includeFailed}}catch(d){console.error(d)}let l={handlerName:C(),handler:i(async g=>{try{let d=g.transaction,m=await z(d,{[this.config.address]:s},this.provider),p=new I(this.config.chainId,this.config.address,this.config.name??this.config.address,g.timestamp||new Date(0),m,null);for(let P of m.operations)for(let u of P.calls||[])if(a.has(u.functionName)){let U=this.contract.functions[u.functionName],he=Object.values(u.argumentsProvided||{}),Fe=U(...he),Ce=new S(Fe,m,!1,u.argumentsProvided,m.logs);await t(Ce,p)}return p.stopAndGetResult()}catch(d){return console.error(d),{gauges:[],counters:[],events:[],exports:[],states:{configUpdated:!1}}}},"handler"),fetchConfig:{filters:Object.values(n)}};return this.callHandlers.push(l),this}onLog(e,t){let o=new Set(Array.isArray(e)?e:[e]),a={handlerName:C(),handler:i(async({transaction:s,receiptIndex:n,timestamp:c})=>{try{let l=w(s,this.provider),g=Number(n),d=l.receipts[g],m=$(d,this.config.abi);if(m){let p=new N(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,c||new Date(0),l,null);return p.setLogIndex(g),await t({receiptIndex:g,...m},p),p.stopAndGetResult()}else console.error(`Log with receipt index ${n} not found in tx`)}catch(l){console.error(l)}return ee.fromPartial({})},"handler"),logConfig:{logIds:Array.from(o)}};return this.logHandlers.push(a),this}onInterval(e,t,o){t&&t.backfillInterval<t.recentInterval&&(t.backfillInterval=t.recentInterval);let a=this;return this.blockHandlers.push({blockInterval:o,timeIntervalInMinutes:t,handlerName:C(),handler:i(async function(s){let n=s.block;if(!n)throw new E.ServerError(E.Status.INVALID_ARGUMENT,"Block is empty");let c={id:n.id,height:F(n.height),time:n.time,header:{applicationHash:n.applicationHash,daHeight:F(n.daHeight),eventInboxRoot:n.eventInboxRoot,messageOutboxRoot:n.messageOutboxRoot,prevRoot:n.prevRoot,stateTransitionBytecodeVersion:n.stateTransitionBytecodeVersion,transactionsCount:n.transactionsCount,transactionsRoot:n.transactionsRoot}},l=new N(a.config.chainId,a.contract,a.config.address,a.config.name??a.config.address,s.timestamp||new Date(0),null,c);return await e(c,l),l.stopAndGetResult()},"handler")}),this}onBlockInterval(e,t=250,o=1e3){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:o})}onTimeInterval(e,t=60,o=240){return this.onInterval(e,{recentInterval:t,backfillInterval:o},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("_")}i(x,"getOptionsSignature");function pt(r){let e=x(r);return h.INSTANCE.getValue(e)}i(pt,"getFuelProcessor");function Q(r,e){let t=x(r);h.INSTANCE.getOrSetValue(t,e)}i(Q,"addFuelProcessor");import("node:process").then(r=>r.stdout.write(""));var _=class r{constructor(e){this.config=e;return T(this)}static{i(this,"FuelAssetProcessor")}callHandlers=[];blockHandlers=[];provider;static bind(e){let t=new r(e),o="assets_"+x({...e,address:"*"});return h.INSTANCE.getOrSetValue(o,t),t}async configure(){this.provider=await v(this.config.chainId)}onTransfer(e,t){let o=[],a=X(e.assetId),s=X(e.from),n=X(e.to);for(let l of a)for(let g of s)for(let d of n)o.push({assetId:l,fromAddress:g,toAddress:d});let c={handlerName:C(),handler:i(async l=>{let g=l.transaction,d=w(g,this.provider),m={from:[],to:[]};for(let u of d.transaction.inputs||[])u.type==B.Coin&&m.from.push({address:u.owner,assetId:u.assetId,amount:BigInt(u.amount.toString(10))});for(let u of d.transaction.outputs||[])if(u.type==re.Coin){let U=u.amount.toString(10);m.to.push({address:u.to,amount:BigInt(U),assetId:u.assetId})}let p=m.from[0].assetId||"",P=new I(this.config.chainId,p,this.config.name??"",l.timestamp||new Date(0),d,null);return await t(m,P),P.stopAndGetResult()},"handler"),assetConfig:{filters:o}};return this.callHandlers.push(c),this}};function X(r){return r?Array.isArray(r)?r.length>0?r:[void 0]:[r]:[void 0]}i(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{i(this,"FuelGlobalProcessor")}callHandlers=[];blockHandlers=[];provider;static bind(e){let t=new r(e),o="global_"+x({...e,address:K});return h.INSTANCE.getOrSetValue(o,t),t}async configure(){this.provider=await v(this.config.chainId)}onTransaction(e,t=y){let o={handlerName:C(),handler:i(async a=>{let s;try{s=w(a.transaction,this.provider)}catch(c){return console.error("error decoding transaction",c),xe([])}let n=new I(this.config.chainId,K,this.config.name??"*",a.timestamp||new Date(0),s,null);return await e(s,n),n.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...t}};return this.callHandlers.push(o),this}};import("node:process").then(r=>r.stdout.write(""));var V=class extends ye{static{i(this,"FuelPlugin")}name="FuelPlugin";handlers={transactionHandlers:[],blockHandlers:[],logHandlers:[]};async configure(e){let t={transactionHandlers:[],blockHandlers:[],logHandlers:[]};for(let o of h.INSTANCE.getValues()){let a=q.fromPartial({processorType:ve,contract:{name:o.config.name,chainId:o.config.chainId.toString(),address:o.config.address||"*",abi:""},startBlock:o.config.startBlock,endBlock:o.config.endBlock});for(let s of o.callHandlers){let n=t.transactionHandlers.push(s.handler)-1,c=s.handlerName;if(o instanceof k){let l={handlerId:n,handlerName:c,filters:s.fetchConfig?.filters||[]};a.fuelCallConfigs.push(l)}else if(o instanceof _){let l=s.assetConfig;a.assetConfigs.push({filters:l?.filters||[],handlerId:n,handlerName:c})}else if(o instanceof D){let l={handlerId:n,handlerName:c,filters:[]};a.fuelCallConfigs.push(l),a.contract.address="*"}}for(let s of o.logHandlers??[]){let n=t.logHandlers.push(s.handler)-1,c=s.handlerName;o instanceof k&&a.fuelLogConfigs.push({logIds:s.logConfig?.logIds||[],handlerId:n,handlerName:c})}for(let s of o.blockHandlers){let n=t.blockHandlers.push(s.handler)-1;a.intervalConfigs.push({slot:0,slotInterval:s.blockInterval,minutes:0,minutesInterval:s.timeIntervalInMinutes,handlerId:n,handlerName:s.handlerName,fetchConfig:void 0})}e.contractConfigs.push(a)}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.processLog(e);case b.FUEL_BLOCK:return this.processBlock(e);default:throw new f.ServerError(f.Status.INVALID_ARGUMENT,"No handle type registered "+e.handlerType)}}async start(e){try{for(let t of h.INSTANCE.getValues())await t.configure()}catch(t){throw new f.ServerError(f.Status.INTERNAL,"error starting FuelPlugin: "+O(t))}}stateDiff(e){return R.INSTANCE.getValues().length!==e.templateInstances.length}async processLog(e){if(!e.data?.fuelLog?.transaction)throw new f.ServerError(f.Status.INVALID_ARGUMENT,"transaction can't be null");let t=e.data.fuelLog,o=[];for(let a of e.handlerIds){let s=this.handlers.logHandlers[a](t).catch(n=>{throw new f.ServerError(f.Status.INTERNAL,"error processing transaction: "+JSON.stringify(t)+`
|
|
2
|
+
import{a as C,b as T}from"./chunk-4WNGQ3EZ.js";import{a as de}from"./chunk-IVMOWPFA.js";import{Ad as se,B as b,Bd as ae,Db as ee,Dd as ie,Tb as F,Td as le,U as q,Ub as M,ne as ce,se as R,uc as te,ue as K,vc as A,wc as B,xc as re,xd as j,yc as L,yd as oe,zc as J,zd as ne}from"./chunk-M4IWP4I2.js";import{a as i,f as H}from"./chunk-G5BIPHMS.js";import{errorString as O,GLOBAL_CONFIG as Y,mergeProcessResults as Z,Plugin as ye,PluginManager as ke,USER_PROCESSOR as ve}from"@sentio/runtime";var f=H(le(),1);import{MapStateStorage as Ie}from"@sentio/runtime";var h=class r extends Ie{static{i(this,"FuelProcessorState")}static INSTANCE=new r};import("node:process").then(r=>r.stdout.write(""));var W=H(de(),1);import{Endpoints as Pe}from"@sentio/runtime";var be={MAIN_NET:W.FuelChainId.FUEL_MAINNET,TEST_NET:W.FuelChainId.FUEL_TESTNET};function Te(r){switch(r){case be.TEST_NET:return"https://testnet.fuel.network/v1/graphql"}return"https://mainnet.fuel.network/v1/graphql"}i(Te,"getRpcEndpoint");function v(r){let e=Pe.INSTANCE.chainServer.get(r);return e||(e=Te(r)),se.create(e)}i(v,"getProvider");import("node:process").then(r=>r.stdout.write(""));var S=class{constructor(e,t,o,a,s){this.args=a;this.logs=s}static{i(this,"FuelCall")}},I=class extends ce{constructor(t,o,a,s,n,c){super({});this.chainId=t;this.contractAddress=o;this.contractName=a;this.timestamp=s;this.transaction=n;this.block=c}static{i(this,"FuelContext")}logIndex=-1;getChainId(){return this.chainId}setLogIndex(t){this.logIndex=t}getMetaDataInternal(t,o){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:ie(o)}}},N=class extends I{constructor(t,o,a,s,n,c,l){super(t,a,s,n,c,l);this.chainId=t;this.contract=o;this.contractAddress=a;this.contractName=s;this.timestamp=n;this.transaction=c;this.block=l}static{i(this,"FuelContractContext")}get provider(){return this.contract.provider}};import("node:process").then(r=>r.stdout.write(""));var y={includeFailed:!1};function ue(r,e){for(let t of r||[])if(t.type==B.Coin&&t.assetId==e)return t.owner}i(ue,"findSenderFromInputs");function w(r,e){let t=M(r.rawPayload),o=r?.status.receipts?.map(j)||[],[a]=new J().decode(t,0),{gasCosts:s,feeParameters:n,txParameters:c,baseAssetId:l}=e.getChain().consensusParameters,g=r.status?.block?.header?.height,{gasPriceFactor:d,gasPerByte:m}=n,{maxInputs:p,maxGasPerTx:P}=c,u={type:r.status?.__typename,...r.status};return{...oe({id:r.id,receipts:o,transaction:a,transactionBytes:t,gqlTransactionStatus:u,gasPerByte:F(m),gasPriceFactor:F(d),maxInputs:p,gasCosts:s,gasPrice:F(r.gasPrice),maxGasPerTx:P,baseAssetId:l}),blockNumber:g,sender:ue(a.inputs,l)}}i(w,"decodeFuelTransaction");function $(r,e){if(r&&(r.type===L.LogData||r.type===L.Log)){let t=new A(e),o=r.type===L.Log?new te("u64").encode(r.val0):r.data,a=r.val1.toString(),[s]=t.decodeLog(o,a);return{logId:a,data:s}}return null}i($,"decodeLog");async function z(r,e,t){let o=M(r.rawPayload),[a]=new J().decode(o,0),s=r?.status.receipts?.map(j)||[],n={type:r.status?.__typename,...r.status},c=n?.block?.header?.height,l=Object.values(e)[0],g=[];s.forEach((p,P)=>{try{let u=$(p,l);u&&g.push({...u,receiptIndex:P})}catch(u){console.warn("Failed to decode log",u)}});let d=new ne(r.status.transactionId,t,{main:Object.values(e)[0],otherContractsAbis:{}});return d.gqlTransaction={...r,status:n},{...await d.getTransactionSummary(),blockNumber:c,logs:g,sender:ue(a.inputs,t.getChain().consensusParameters.baseAssetId)}}i(z,"decodeFuelTransactionWithAbi");import("node:process").then(r=>r.stdout.write(""));var E=H(le(),1);var k=class r{constructor(e){this.config=e;return T(this)}static{i(this,"FuelProcessor")}callHandlers=[];blockHandlers=[];logHandlers=[];provider;contract;static bind(e){let t=new r(e);return Q(e,t),t}latestGasPrice;async configure(){this.provider=await v(this.config.chainId),this.provider.getLatestGasPrice=async()=>{if(this.latestGasPrice)return F(this.latestGasPrice);let{latestGasPrice:e}=await this.provider.operations.getLatestGasPrice();return this.latestGasPrice=e?.gasPrice,F(e.gasPrice)},this.contract=new ae(this.config.address,this.config.abi,this.provider)}onTransaction(e,t=y){let o={handlerName:C(),handler:i(async a=>{let s=this.config.abi?{[this.config.address]:this.config.abi}:{},n=await z(a.transaction,s,this.provider),c=new N(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,a.timestamp||new Date(0),n,null);return await e(n,c),c.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...t}};return this.callHandlers.push(o),this}onCall(e,t,o=y){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,n={},c=new A(s);for(let g of a)try{let d=c.functions[g],m=F(d.selector,"hex").toString();n[d.name]={function:m,includeFailed:!!o.includeFailed}}catch(d){console.error(d)}let l={handlerName:C(),handler:i(async g=>{try{let d=g.transaction,m=await z(d,{[this.config.address]:s},this.provider),p=new I(this.config.chainId,this.config.address,this.config.name??this.config.address,g.timestamp||new Date(0),m,null);for(let P of m.operations)for(let u of P.calls||[])if(a.has(u.functionName)){let U=this.contract.functions[u.functionName],he=Object.values(u.argumentsProvided||{}),Fe=U(...he),Ce=new S(Fe,m,!1,u.argumentsProvided,m.logs);await t(Ce,p)}return p.stopAndGetResult()}catch(d){return console.error(d),{gauges:[],counters:[],events:[],exports:[],states:{configUpdated:!1}}}},"handler"),fetchConfig:{filters:Object.values(n)}};return this.callHandlers.push(l),this}onLog(e,t){let o=new Set(Array.isArray(e)?e:[e]),a={handlerName:C(),handler:i(async({transaction:s,receiptIndex:n,timestamp:c})=>{try{let l=w(s,this.provider),g=Number(n),d=l.receipts[g],m=$(d,this.config.abi);if(m){let p=new N(this.config.chainId,this.contract,this.config.address,this.config.name??this.config.address,c||new Date(0),l,null);return p.setLogIndex(g),await t({receiptIndex:g,...m},p),p.stopAndGetResult()}else console.error(`Log with receipt index ${n} not found in tx`)}catch(l){console.error(l)}return ee.fromPartial({})},"handler"),logConfig:{logIds:Array.from(o)}};return this.logHandlers.push(a),this}onInterval(e,t,o){t&&t.backfillInterval<t.recentInterval&&(t.backfillInterval=t.recentInterval);let a=this;return this.blockHandlers.push({blockInterval:o,timeIntervalInMinutes:t,handlerName:C(),handler:i(async function(s){let n=s.block;if(!n)throw new E.ServerError(E.Status.INVALID_ARGUMENT,"Block is empty");let c={id:n.id,height:F(n.height),time:n.time,header:{applicationHash:n.applicationHash,daHeight:F(n.daHeight),eventInboxRoot:n.eventInboxRoot,messageOutboxRoot:n.messageOutboxRoot,prevRoot:n.prevRoot,stateTransitionBytecodeVersion:n.stateTransitionBytecodeVersion,transactionsCount:n.transactionsCount,transactionsRoot:n.transactionsRoot}},l=new N(a.config.chainId,a.contract,a.config.address,a.config.name??a.config.address,s.timestamp||new Date(0),null,c);return await e(c,l),l.stopAndGetResult()},"handler")}),this}onBlockInterval(e,t=250,o=1e3){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:o})}onTimeInterval(e,t=60,o=240){return this.onInterval(e,{recentInterval:t,backfillInterval:o},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("_")}i(x,"getOptionsSignature");function pt(r){let e=x(r);return h.INSTANCE.getValue(e)}i(pt,"getFuelProcessor");function Q(r,e){let t=x(r);h.INSTANCE.getOrSetValue(t,e)}i(Q,"addFuelProcessor");import("node:process").then(r=>r.stdout.write(""));var _=class r{constructor(e){this.config=e;return T(this)}static{i(this,"FuelAssetProcessor")}callHandlers=[];blockHandlers=[];provider;static bind(e){let t=new r(e),o="assets_"+x({...e,address:"*"});return h.INSTANCE.getOrSetValue(o,t),t}async configure(){this.provider=await v(this.config.chainId)}onTransfer(e,t){let o=[],a=X(e.assetId),s=X(e.from),n=X(e.to);for(let l of a)for(let g of s)for(let d of n)o.push({assetId:l,fromAddress:g,toAddress:d});let c={handlerName:C(),handler:i(async l=>{let g=l.transaction,d=w(g,this.provider),m={from:[],to:[]};for(let u of d.transaction.inputs||[])u.type==B.Coin&&m.from.push({address:u.owner,assetId:u.assetId,amount:BigInt(u.amount.toString(10))});for(let u of d.transaction.outputs||[])if(u.type==re.Coin){let U=u.amount.toString(10);m.to.push({address:u.to,amount:BigInt(U),assetId:u.assetId})}let p=m.from[0].assetId||"",P=new I(this.config.chainId,p,this.config.name??"",l.timestamp||new Date(0),d,null);return await t(m,P),P.stopAndGetResult()},"handler"),assetConfig:{filters:o}};return this.callHandlers.push(c),this}};function X(r){return r?Array.isArray(r)?r.length>0?r:[void 0]:[r]:[void 0]}i(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{i(this,"FuelGlobalProcessor")}callHandlers=[];blockHandlers=[];provider;static bind(e){let t=new r(e),o="global_"+x({...e,address:K});return h.INSTANCE.getOrSetValue(o,t),t}async configure(){this.provider=await v(this.config.chainId)}onTransaction(e,t=y){let o={handlerName:C(),handler:i(async a=>{let s;try{s=w(a.transaction,this.provider)}catch(c){return console.error("error decoding transaction",c),xe([])}let n=new I(this.config.chainId,K,this.config.name??"*",a.timestamp||new Date(0),s,null);return await e(s,n),n.stopAndGetResult()},"handler"),fetchConfig:{filters:[],...t}};return this.callHandlers.push(o),this}};import("node:process").then(r=>r.stdout.write(""));var V=class extends ye{static{i(this,"FuelPlugin")}name="FuelPlugin";handlers={transactionHandlers:[],blockHandlers:[],logHandlers:[]};async configure(e){let t={transactionHandlers:[],blockHandlers:[],logHandlers:[]};for(let o of h.INSTANCE.getValues()){let a=q.fromPartial({processorType:ve,contract:{name:o.config.name,chainId:o.config.chainId.toString(),address:o.config.address||"*",abi:""},startBlock:o.config.startBlock,endBlock:o.config.endBlock});for(let s of o.callHandlers){let n=t.transactionHandlers.push(s.handler)-1,c=s.handlerName;if(o instanceof k){let l={handlerId:n,handlerName:c,filters:s.fetchConfig?.filters||[]};a.fuelCallConfigs.push(l)}else if(o instanceof _){let l=s.assetConfig;a.assetConfigs.push({filters:l?.filters||[],handlerId:n,handlerName:c})}else if(o instanceof D){let l={handlerId:n,handlerName:c,filters:[]};a.fuelCallConfigs.push(l),a.contract.address="*"}}for(let s of o.logHandlers??[]){let n=t.logHandlers.push(s.handler)-1,c=s.handlerName;o instanceof k&&a.fuelLogConfigs.push({logIds:s.logConfig?.logIds||[],handlerId:n,handlerName:c})}for(let s of o.blockHandlers){let n=t.blockHandlers.push(s.handler)-1;a.intervalConfigs.push({slot:0,slotInterval:s.blockInterval,minutes:0,minutesInterval:s.timeIntervalInMinutes,handlerId:n,handlerName:s.handlerName,fetchConfig:void 0})}e.contractConfigs.push(a)}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.processLog(e);case b.FUEL_BLOCK:return this.processBlock(e);default:throw new f.ServerError(f.Status.INVALID_ARGUMENT,"No handle type registered "+e.handlerType)}}async start(e){try{for(let t of h.INSTANCE.getValues())await t.configure()}catch(t){throw new f.ServerError(f.Status.INTERNAL,"error starting FuelPlugin: "+O(t))}}stateDiff(e){return R.INSTANCE.getValues().length!==e.templateInstances.length}async processLog(e){if(!e.data?.fuelLog?.transaction)throw new f.ServerError(f.Status.INVALID_ARGUMENT,"transaction can't be null");let t=e.data.fuelLog,o=[];for(let a of e.handlerIds){let s=this.handlers.logHandlers[a](t).catch(n=>{throw new f.ServerError(f.Status.INTERNAL,"error processing transaction: "+JSON.stringify(t)+`
|
|
3
3
|
`+O(n))});Y.execution.sequential&&await s,o.push(s)}return Z(await Promise.all(o))}async processTransaction(e){if(!e.data?.fuelTransaction?.transaction)throw new f.ServerError(f.Status.INVALID_ARGUMENT,"transaction can't be null");let t=e.data.fuelTransaction,o=[];for(let a of e.handlerIds){let s=this.handlers.transactionHandlers[a](t).catch(n=>{throw new f.ServerError(f.Status.INTERNAL,"error processing transaction: "+JSON.stringify(t.transaction)+`
|
|
4
4
|
`+O(n))});Y.execution.sequential&&await s,o.push(s)}return Z(await Promise.all(o))}async processBlock(e){if(!e.data?.fuelBlock?.block)throw new f.ServerError(f.Status.INVALID_ARGUMENT,"Block can't be empty");let t=e.data.fuelBlock,o=[];for(let a of e.handlerIds){let s=this.handlers.blockHandlers[a](t).catch(n=>{throw console.error("error processing block: ",n),new f.ServerError(f.Status.INTERNAL,"error processing block: "+t.block?.height+`
|
|
5
5
|
`+O(n))});Y.execution.sequential&&await s,o.push(s)}return Z(await Promise.all(o))}};ke.INSTANCE.register(new V);import("node:process").then(r=>r.stdout.write(""));import{ListStateStorage as Ne}from"@sentio/runtime";var G=class r extends Ne{static{i(this,"FuelProcessorTemplateProcessorState")}static INSTANCE=new r},fe=class{static{i(this,"FuelBaseProcessorTemplate")}id;binds=new Set;blockHandlers=[];logHandlers=[];transactionHandlers=[];constructor(){this.id=G.INSTANCE.getValues().length,G.INSTANCE.addValue(this)}bind(e,t){let o=x({address:e.address,chainId:t.chainId});if(this.binds.has(o)){console.log(`Same address can be bind to one template only once, ignore duplicate bind: ${o}`);return}this.binds.add(o);let a=this.bindInternal({...e,chainId:t.chainId});for(let n of this.logHandlers)a.onLog(n.logIdFilter,n.handler);for(let n of this.blockHandlers)a.onInterval(n.handler,n.timeIntervalInMinutes,n.blockInterval);for(let n of this.transactionHandlers)a.onTransaction(n.handler);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:{}};R.INSTANCE.addValue(s),t.update({states:{configUpdated:!0}})}onLog(e,t){return this.logHandlers.push({logIdFilter:e,handler:t}),this}onBlockInterval(e,t=1e3,o=4e3){return this.onInterval(e,void 0,{recentInterval:t,backfillInterval:o})}onTimeInterval(e,t=60,o=240){return this.onInterval(e,{recentInterval:t,backfillInterval:o},void 0)}onInterval(e,t,o){return this.blockHandlers.push({handler:e,timeIntervalInMinutes:t,blockInterval:o}),this}onTransaction(e,t=y){return this.transactionHandlers.push({handler:e,fetchConfig:t}),this}};import("node:process").then(r=>r.stdout.write(""));var pe=H(de(),1);var ge=class extends k{static{i(this,"FuelAbstractProcessor")}constructor(e,t){return t||(t={chainId:pe.FuelChainId.FUEL_MAINNET,address:"*"}),super({...t,abi:e}),Q(t,this),T(this)}},me=class{static{i(this,"TypedCall")}args;returnValue;argsObject;logs};import("node:process").then(r=>r.stdout.write(""));import("node:process").then(r=>r.stdout.write(""));export{h as a,be as b,Te as c,v as d,S as e,I as f,N as g,y as h,w as i,$ as j,z as k,k as l,x as m,pt as n,Q as o,_ as p,D as q,V as r,G as s,fe as t,ge as u,me as v};
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
6
|
+
//# sourceMappingURL=chunk-D4BGG4V2.js.map
|