@sentio/sdk 2.18.0-rc.1 → 2.18.0-rc.2

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.
@@ -44,6 +44,10 @@ export declare class BoundContractView<TContract extends BaseContract, TContract
44
44
  protected view: TContractView;
45
45
  readonly address: string;
46
46
  context: EthContext;
47
+ callStatic: {
48
+ context: EthContext;
49
+ view: TContractView;
50
+ };
47
51
  constructor(address: string, view: TContractView);
48
52
  get rawContract(): TContract;
49
53
  get provider(): import("ethers").Provider;
@@ -101,6 +101,9 @@ export class ContractContext extends EthContext {
101
101
  constructor(contractName, view, chainId, timestamp, block, log, trace, transaction, transactionReceipt, baseLabels) {
102
102
  super(chainId, view.address, timestamp, block, log, trace, transaction, transactionReceipt, baseLabels);
103
103
  view.context = this;
104
+ if (view.callStatic) {
105
+ view.callStatic.context = this;
106
+ }
104
107
  this.contractName = contractName;
105
108
  this.contract = view;
106
109
  }
@@ -129,6 +132,7 @@ export class BoundContractView {
129
132
  // context will be set right after context creation (in context's constructor)
130
133
  // context: ContractContext<TContract, BoundContractView<TContract, TContractView>>
131
134
  context;
135
+ callStatic;
132
136
  constructor(address, view) {
133
137
  this.address = address;
134
138
  this.view = view;
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/eth/context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGrD,MAAM,OAAgB,UAAW,SAAQ,WAAW;IAClD,OAAO,CAAY;IACnB,OAAO,CAAQ;IACE,GAAG,CAAY;IAChC,KAAK,CAAc;IACF,KAAK,CAAQ;IAC9B,WAAW,CAAQ;IACnB,eAAe,CAAS;IACxB,WAAW,CAA4B;IACvC,kBAAkB,CAA2B;IAC7C,SAAS,CAAM;IAEf,YACE,OAAmB,EACnB,OAAe,EACf,SAAgB,EAChB,KA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AAC,QAAQ,CAAA;SACrC;QACD,MAAM,KAAK,CAAC,kCAAkC,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC5E,CAAC;CACF;AAED,MAAM,OAAO,iBAAiB;IAClB,IAAI,CAAe;IACpB,OAAO,CAAQ;IACxB,8EAA8E;IAC9E,mFAAmF;IACnF,OAAO,CAAY;IAEnB,YAAY,OAAe,EAAE,IAAmB;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAA;IAC9B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAA;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAA;IACtC,CAAC;CACF","sourcesContent":["import { BaseContract } from 'ethers'\nimport { LogParams, BlockParams, TransactionReceiptParams, TransactionResponseParams } from 'ethers/providers'\n\nimport { RecordMetaData } from '@sentio/protos'\nimport { Trace } from './eth.js'\nimport { Labels, normalizeLabels } from '../core/index.js'\nimport { BaseContext } from '../core/base-context.js'\nimport { EthChainId } from '../core/chain.js'\n\nexport abstract class EthContext extends BaseContext {\n chainId: EthChainId\n address: string\n private readonly log?: LogParams\n block?: BlockParams\n private readonly trace?: Trace\n blockNumber: number\n transactionHash?: string\n transaction?: TransactionResponseParams\n transactionReceipt?: TransactionReceiptParams\n timestamp: Date\n\n constructor(\n chainId: EthChainId,\n address: string,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams,\n baseLabels?: Labels\n ) {\n super(baseLabels)\n this.chainId = chainId\n this.log = log\n this.block = block\n this.trace = trace\n this.address = address.toLowerCase()\n this.transaction = transaction\n this.transactionReceipt = transactionReceipt\n this.timestamp = timestamp || new Date(0)\n if (log) {\n this.blockNumber = log.blockNumber\n this.transactionHash = log.transactionHash\n } else if (block) {\n this.blockNumber = block.number\n } else if (trace) {\n this.blockNumber = trace.blockNumber\n this.transactionHash = trace.transactionHash\n }\n }\n\n protected abstract getContractName(): string\n\n getChainId(): EthChainId {\n return this.chainId\n }\n\n getMetaDataInternal(name: string, labels: Labels): RecordMetaData {\n if (this.log) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: this.log.transactionIndex,\n transactionHash: this.transactionHash || '',\n logIndex: this.log.index,\n chainId: this.chainId,\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.block) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: -1,\n transactionHash: '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.trace) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: this.trace.transactionPosition,\n transactionHash: this.transactionHash || '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n throw new Error(\"Invaid ctx argument can't happen\")\n }\n}\n\nexport class AccountContext extends EthContext {\n // constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {\n // super(chainId, address, new Date(0), block, log, trace)\n // }\n protected getContractName(): string {\n return 'account'\n }\n}\n\nexport class GlobalContext extends EthContext {\n constructor(\n chainId: EthChainId,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams\n ) {\n super(chainId, '*', timestamp, block, log, trace, transaction, transactionReceipt)\n }\n protected getContractName(): string {\n return '*'\n }\n}\n\nexport class ContractContext<\n TContract extends BaseContract,\n TContractBoundView extends BoundContractView<TContract, ContractView<TContract>>\n> extends EthContext {\n contract: TContractBoundView\n contractName: string\n\n constructor(\n contractName: string,\n view: TContractBoundView,\n chainId: EthChainId,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams,\n baseLabels?: Labels\n ) {\n super(chainId, view.address, timestamp, block, log, trace, transaction, transactionReceipt, baseLabels)\n view.context = this\n this.contractName = contractName\n this.contract = view\n }\n\n protected getContractName(): string {\n return this.contractName\n }\n}\n\nexport class ContractView<TContract extends BaseContract> {\n protected contract: TContract\n\n constructor(contract: TContract) {\n this.contract = contract\n }\n\n get rawContract() {\n return this.contract\n }\n\n get provider() {\n if (this.contract.runner?.provider) {\n return this.contract.runner.provider\n }\n throw Error(\"Can't find provider for contract\" + this.contract.toString())\n }\n}\n\nexport class BoundContractView<TContract extends BaseContract, TContractView extends ContractView<TContract>> {\n protected view: TContractView\n readonly address: string\n // context will be set right after context creation (in context's constructor)\n // context: ContractContext<TContract, BoundContractView<TContract, TContractView>>\n context: EthContext\n\n constructor(address: string, view: TContractView) {\n this.address = address\n this.view = view\n }\n\n get rawContract() {\n return this.view.rawContract\n }\n\n get provider() {\n return this.view.provider\n }\n\n get filters() {\n return this.view.rawContract.filters\n }\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/eth/context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAGrD,MAAM,OAAgB,UAAW,SAAQ,WAAW;IAClD,OAAO,CAAY;IACnB,OAAO,CAAQ;IACE,GAAG,CAAY;IAChC,KAAK,CAAc;IACF,KAAK,CAAQ;IAC9B,WAAW,CAAQ;IACnB,eAAe,CAAS;IACxB,WAAW,CAA4B;IACvC,kBAAkB,CAA2B;IAC7C,SAAS,CAAM;IAEf,YAC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A;IACtB,CAAC;IAED,IAAI,QAAQ;QACV,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE;YAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAA;SACrC;QACD,MAAM,KAAK,CAAC,kCAAkC,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC5E,CAAC;CACF;AAED,MAAM,OAAO,iBAAiB;IAClB,IAAI,CAAe;IACpB,OAAO,CAAQ;IACxB,8EAA8E;IAC9E,mFAAmF;IACnF,OAAO,CAAY;IACnB,UAAU,CAGT;IAED,YAAY,OAAe,EAAE,IAAmB;QAC9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAA;IAC9B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAA;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAA;IACtC,CAAC;CACF","sourcesContent":["import { BaseContract } from 'ethers'\nimport { LogParams, BlockParams, TransactionReceiptParams, TransactionResponseParams } from 'ethers/providers'\n\nimport { RecordMetaData } from '@sentio/protos'\nimport { Trace } from './eth.js'\nimport { Labels, normalizeLabels } from '../core/index.js'\nimport { BaseContext } from '../core/base-context.js'\nimport { EthChainId } from '../core/chain.js'\n\nexport abstract class EthContext extends BaseContext {\n chainId: EthChainId\n address: string\n private readonly log?: LogParams\n block?: BlockParams\n private readonly trace?: Trace\n blockNumber: number\n transactionHash?: string\n transaction?: TransactionResponseParams\n transactionReceipt?: TransactionReceiptParams\n timestamp: Date\n\n constructor(\n chainId: EthChainId,\n address: string,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams,\n baseLabels?: Labels\n ) {\n super(baseLabels)\n this.chainId = chainId\n this.log = log\n this.block = block\n this.trace = trace\n this.address = address.toLowerCase()\n this.transaction = transaction\n this.transactionReceipt = transactionReceipt\n this.timestamp = timestamp || new Date(0)\n if (log) {\n this.blockNumber = log.blockNumber\n this.transactionHash = log.transactionHash\n } else if (block) {\n this.blockNumber = block.number\n } else if (trace) {\n this.blockNumber = trace.blockNumber\n this.transactionHash = trace.transactionHash\n }\n }\n\n protected abstract getContractName(): string\n\n getChainId(): EthChainId {\n return this.chainId\n }\n\n getMetaDataInternal(name: string, labels: Labels): RecordMetaData {\n if (this.log) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: this.log.transactionIndex,\n transactionHash: this.transactionHash || '',\n logIndex: this.log.index,\n chainId: this.chainId,\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.block) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: -1,\n transactionHash: '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n if (this.trace) {\n return {\n address: this.address,\n contractName: this.getContractName(),\n blockNumber: BigInt(this.blockNumber),\n transactionIndex: this.trace.transactionPosition,\n transactionHash: this.transactionHash || '',\n logIndex: -1,\n chainId: this.chainId.toString(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n throw new Error(\"Invaid ctx argument can't happen\")\n }\n}\n\nexport class AccountContext extends EthContext {\n // constructor(chainId: number, address: string, block?: Block, log?: Log, trace?: Trace) {\n // super(chainId, address, new Date(0), block, log, trace)\n // }\n protected getContractName(): string {\n return 'account'\n }\n}\n\nexport class GlobalContext extends EthContext {\n constructor(\n chainId: EthChainId,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams\n ) {\n super(chainId, '*', timestamp, block, log, trace, transaction, transactionReceipt)\n }\n protected getContractName(): string {\n return '*'\n }\n}\n\nexport class ContractContext<\n TContract extends BaseContract,\n TContractBoundView extends BoundContractView<TContract, ContractView<TContract>>\n> extends EthContext {\n contract: TContractBoundView\n contractName: string\n\n constructor(\n contractName: string,\n view: TContractBoundView,\n chainId: EthChainId,\n timestamp?: Date,\n block?: BlockParams,\n log?: LogParams,\n trace?: Trace,\n transaction?: TransactionResponseParams,\n transactionReceipt?: TransactionReceiptParams,\n baseLabels?: Labels\n ) {\n super(chainId, view.address, timestamp, block, log, trace, transaction, transactionReceipt, baseLabels)\n view.context = this\n if (view.callStatic) {\n view.callStatic.context = this\n }\n this.contractName = contractName\n this.contract = view\n }\n\n protected getContractName(): string {\n return this.contractName\n }\n}\n\nexport class ContractView<TContract extends BaseContract> {\n protected contract: TContract\n\n constructor(contract: TContract) {\n this.contract = contract\n }\n\n get rawContract() {\n return this.contract\n }\n\n get provider() {\n if (this.contract.runner?.provider) {\n return this.contract.runner.provider\n }\n throw Error(\"Can't find provider for contract\" + this.contract.toString())\n }\n}\n\nexport class BoundContractView<TContract extends BaseContract, TContractView extends ContractView<TContract>> {\n protected view: TContractView\n readonly address: string\n // context will be set right after context creation (in context's constructor)\n // context: ContractContext<TContract, BoundContractView<TContract, TContractView>>\n context: EthContext\n callStatic: {\n context: EthContext\n view: TContractView\n }\n\n constructor(address: string, view: TContractView) {\n this.address = address\n this.view = view\n }\n\n get rawContract() {\n return this.view.rawContract\n }\n\n get provider() {\n return this.view.provider\n }\n\n get filters() {\n return this.view.rawContract.filters\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.18.0-rc.1",
3
+ "version": "2.18.0-rc.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -71,8 +71,8 @@
71
71
  "typedoc": "^0.24.1",
72
72
  "utility-types": "^3.10.0",
73
73
  "yaml": "^2.2.1",
74
- "@sentio/protos": "2.18.0-rc.1",
75
- "@sentio/runtime": "^2.18.0-rc.1"
74
+ "@sentio/protos": "2.18.0-rc.2",
75
+ "@sentio/runtime": "^2.18.0-rc.2"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "tsup": "npm:@sentio/tsup@^6.7.0"
@@ -147,6 +147,9 @@ export class ContractContext<
147
147
  ) {
148
148
  super(chainId, view.address, timestamp, block, log, trace, transaction, transactionReceipt, baseLabels)
149
149
  view.context = this
150
+ if (view.callStatic) {
151
+ view.callStatic.context = this
152
+ }
150
153
  this.contractName = contractName
151
154
  this.contract = view
152
155
  }
@@ -181,6 +184,10 @@ export class BoundContractView<TContract extends BaseContract, TContractView ext
181
184
  // context will be set right after context creation (in context's constructor)
182
185
  // context: ContractContext<TContract, BoundContractView<TContract, TContractView>>
183
186
  context: EthContext
187
+ callStatic: {
188
+ context: EthContext
189
+ view: TContractView
190
+ }
184
191
 
185
192
  constructor(address: string, view: TContractView) {
186
193
  this.address = address