@delvtech/evm-client
Advanced tools
| import{c as t}from"./chunk-EXKUPYHD.js";t(); | ||
| //# sourceMappingURL=chunk-SXCIO5B6.js.map |
| {"version":3,"sources":["../src/exports/network.ts"],"sourcesContent":["export type { Block, BlockTag } from 'src/network/types/Block';\nexport type {\n Network,\n NetworkGetBalanceArgs,\n NetworkGetBlockArgs,\n NetworkGetBlockOptions,\n NetworkGetTransactionArgs,\n NetworkWaitForTransactionArgs,\n} from 'src/network/types/Network';\nexport type {\n MinedTransaction,\n Transaction,\n TransactionInfo,\n} from 'src/network/types/Transaction';\n"],"mappings":"wCAAAA","names":["init_esm_shims"]} |
| import { B as Block, a as BlockTag } from './Block-D7itLNye.js'; | ||
| interface TransactionInfo { | ||
| blockHash?: `0x${string}`; | ||
| blockNumber?: bigint; | ||
| from?: `0x${string}`; | ||
| hash?: `0x${string}`; | ||
| transactionIndex?: number; | ||
| } | ||
| /** Basic legacy compatible transaction */ | ||
| interface Transaction extends TransactionInfo { | ||
| type: `0x${string}`; | ||
| nonce: number; | ||
| gas: bigint; | ||
| value: bigint; | ||
| input: `0x${string}`; | ||
| gasPrice: bigint; | ||
| chainId?: number; | ||
| to?: `0x${string}` | null; | ||
| } | ||
| type MinedTransaction = Transaction & Required<TransactionInfo>; | ||
| interface TransactionReceipt { | ||
| blockHash: `0x${string}`; | ||
| blockNumber: bigint; | ||
| from: `0x${string}`; | ||
| /** | ||
| * Address of the receiver or `null` in a contract creation transaction. | ||
| */ | ||
| to: `0x${string}` | null; | ||
| /** | ||
| * The sum of gas used by this transaction and all preceding transactions in | ||
| * the same block. | ||
| */ | ||
| cumulativeGasUsed: bigint; | ||
| /** | ||
| * The amount of gas used for this specific transaction alone. | ||
| */ | ||
| gasUsed: bigint; | ||
| logsBloom: `0x${string}`; | ||
| transactionHash: `0x${string}`; | ||
| transactionIndex: number; | ||
| /** | ||
| * The actual value per gas deducted from the sender's account. Before | ||
| * EIP-1559, this is equal to the transaction's gas price. After, it is equal | ||
| * to baseFeePerGas + min(maxFeePerGas - baseFeePerGas, maxPriorityFeePerGas). | ||
| */ | ||
| effectiveGasPrice: bigint; | ||
| } | ||
| /** | ||
| * An interface representing data the SDK needs to get from the network. | ||
| */ | ||
| interface Network { | ||
| /** | ||
| * Get the balance of native currency for an account. | ||
| */ | ||
| getBalance(...args: NetworkGetBalanceArgs): Promise<bigint>; | ||
| /** | ||
| * Get a block from a block tag, number, or hash. If no argument is provided, | ||
| * the latest block is returned. | ||
| */ | ||
| getBlock(...args: NetworkGetBlockArgs): Promise<Block | undefined>; | ||
| /** | ||
| * Get a transaction from a transaction hash. | ||
| */ | ||
| getTransaction(...args: NetworkGetTransactionArgs): Promise<Transaction | undefined>; | ||
| /** | ||
| * Wait for a transaction to be mined. | ||
| */ | ||
| waitForTransaction(...args: NetworkWaitForTransactionArgs): Promise<TransactionReceipt | undefined>; | ||
| } | ||
| type NetworkGetBlockOptions = { | ||
| blockHash?: `0x${string}`; | ||
| blockNumber?: never; | ||
| blockTag?: never; | ||
| } | { | ||
| blockHash?: never; | ||
| blockNumber?: bigint; | ||
| blockTag?: never; | ||
| } | { | ||
| blockHash?: never; | ||
| blockNumber?: never; | ||
| blockTag?: BlockTag; | ||
| }; | ||
| type NetworkGetBalanceArgs = [ | ||
| address: `0x${string}`, | ||
| block?: NetworkGetBlockOptions | ||
| ]; | ||
| type NetworkGetBlockArgs = [options?: NetworkGetBlockOptions]; | ||
| type NetworkGetTransactionArgs = [hash: `0x${string}`]; | ||
| type NetworkWaitForTransactionArgs = [ | ||
| hash: `0x${string}`, | ||
| options?: { | ||
| /** | ||
| * The number of milliseconds to wait for the transaction until rejecting | ||
| * the promise. | ||
| */ | ||
| timeout?: number; | ||
| } | ||
| ]; | ||
| export type { MinedTransaction as M, Network as N, Transaction as T, NetworkGetBalanceArgs as a, NetworkGetBlockArgs as b, NetworkGetBlockOptions as c, NetworkGetTransactionArgs as d, NetworkWaitForTransactionArgs as e, TransactionInfo as f, TransactionReceipt as g }; |
+1
-1
@@ -7,4 +7,4 @@ export { createLruSimpleCache, createSimpleCacheKey } from './cache.js'; | ||
| export { B as Block, a as BlockTag } from './Block-D7itLNye.js'; | ||
| export { M as MinedTransaction, N as Network, a as NetworkGetBlockArgs, b as NetworkGetBlockOptions, c as NetworkGetTransactionArgs, T as Transaction, d as TransactionInfo } from './network-BqcpoPpv.js'; | ||
| export { M as MinedTransaction, N as Network, a as NetworkGetBalanceArgs, b as NetworkGetBlockArgs, c as NetworkGetBlockOptions, d as NetworkGetTransactionArgs, e as NetworkWaitForTransactionArgs, T as Transaction, f as TransactionInfo } from './network-Do1HtQIB.js'; | ||
| import 'lru-cache'; | ||
| import 'abitype'; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import"./chunk-MWVTNBAN.js";import{a as f,b as m,c as t,d as x,e as a,f as b}from"./chunk-FI3KYCOV.js";import{a as r,b as e}from"./chunk-HB4JKCEF.js";import"./chunk-3DBCK3WJ.js";import{a as p}from"./chunk-FJROFRBN.js";import"./chunk-ZKEAVCAH.js";import{c as o}from"./chunk-EXKUPYHD.js";o();export{p as AbiEntryNotFoundError,x as arrayToFriendly,a as arrayToObject,f as createCachedReadContract,m as createCachedReadWriteContract,r as createLruSimpleCache,e as createSimpleCacheKey,t as getAbiEntry,b as objectToArray}; | ||
| import"./chunk-MWVTNBAN.js";import{a as f,b as m,c as t,d as x,e as a,f as b}from"./chunk-FI3KYCOV.js";import{a as r,b as e}from"./chunk-HB4JKCEF.js";import"./chunk-3DBCK3WJ.js";import{a as p}from"./chunk-FJROFRBN.js";import"./chunk-SXCIO5B6.js";import{c as o}from"./chunk-EXKUPYHD.js";o();export{p as AbiEntryNotFoundError,x as arrayToFriendly,a as arrayToObject,f as createCachedReadContract,m as createCachedReadWriteContract,r as createLruSimpleCache,e as createSimpleCacheKey,t as getAbiEntry,b as objectToArray}; | ||
| //# sourceMappingURL=index.js.map |
| export { B as Block, a as BlockTag } from './Block-D7itLNye.js'; | ||
| export { M as MinedTransaction, N as Network, a as NetworkGetBlockArgs, b as NetworkGetBlockOptions, c as NetworkGetTransactionArgs, T as Transaction, d as TransactionInfo } from './network-BqcpoPpv.js'; | ||
| export { M as MinedTransaction, N as Network, a as NetworkGetBalanceArgs, b as NetworkGetBlockArgs, c as NetworkGetBlockOptions, d as NetworkGetTransactionArgs, e as NetworkWaitForTransactionArgs, T as Transaction, f as TransactionInfo } from './network-Do1HtQIB.js'; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import"./chunk-ZKEAVCAH.js";import"./chunk-EXKUPYHD.js"; | ||
| import"./chunk-SXCIO5B6.js";import"./chunk-EXKUPYHD.js"; | ||
| //# sourceMappingURL=network.js.map |
+7
-1
@@ -5,3 +5,3 @@ import { Abi } from 'abitype'; | ||
| import { B as Block } from './Block-D7itLNye.js'; | ||
| import { N as Network, a as NetworkGetBlockArgs, c as NetworkGetTransactionArgs, T as Transaction, e as NetworkWaitForTransactionArgs, f as TransactionReceipt } from './network-BqcpoPpv.js'; | ||
| import { N as Network, a as NetworkGetBalanceArgs, b as NetworkGetBlockArgs, d as NetworkGetTransactionArgs, T as Transaction, e as NetworkWaitForTransactionArgs, g as TransactionReceipt } from './network-Do1HtQIB.js'; | ||
@@ -164,4 +164,9 @@ /** | ||
| declare class NetworkStub implements Network { | ||
| protected getBalanceStub: SinonStub<[NetworkGetBalanceArgs?], Promise<bigint>> | undefined; | ||
| protected getBlockStub: SinonStub<[NetworkGetBlockArgs?], Promise<Block | undefined>> | undefined; | ||
| protected getTransactionStub: SinonStub<[NetworkGetTransactionArgs?], Promise<Transaction | undefined>> | undefined; | ||
| stubGetBalance({ args, value, }: { | ||
| args?: NetworkGetBalanceArgs | undefined; | ||
| value: bigint; | ||
| }): void; | ||
| stubGetBlock({ args, value, }: { | ||
@@ -175,2 +180,3 @@ args?: NetworkGetBlockArgs | undefined; | ||
| }): void; | ||
| getBalance(...args: NetworkGetBalanceArgs): Promise<bigint>; | ||
| getBlock(...args: NetworkGetBlockArgs): Promise<Block | undefined>; | ||
@@ -177,0 +183,0 @@ getTransaction(...args: NetworkGetTransactionArgs): Promise<Transaction | undefined>; |
+5
-4
@@ -1,8 +0,9 @@ | ||
| import{c as a}from"./chunk-EXKUPYHD.js";a();a();import F from"fast-safe-stringify";import{stub as b}from"sinon";var s=class{abi;address="0x0000000000000000000000000000000000000000";readStubMap=new Map;eventsStubMap=new Map;simulateWriteStubMap=new Map;constructor(t=[]){this.abi=t}async read(...[t,n,e]){let i=this.getReadStub(t);if(!i)throw new Error(`Called read for ${t} on a stubbed contract without a return value. The function must be stubbed first: | ||
| import{c as o}from"./chunk-EXKUPYHD.js";o();o();import N from"fast-safe-stringify";import{stub as b}from"sinon";var s=class{abi;address="0x0000000000000000000000000000000000000000";readStubMap=new Map;eventsStubMap=new Map;simulateWriteStubMap=new Map;constructor(t=[]){this.abi=t}async read(...[t,n,e]){let i=this.getReadStub(t);if(!i)throw new Error(`Called read for ${t} on a stubbed contract without a return value. The function must be stubbed first: | ||
| contract.stubRead("${t}", value)`);return i(n,e)}async simulateWrite(...[t,n,e]){let i=this.getSimulateWriteStub(t);if(!i)throw new Error(`Called simulateWrite for ${t} on a stubbed contract without a return value. The function must be stubbed first: | ||
| contract.stubWrite("${t}", value)`);return i(n,e)}async getEvents(...[t,n]){let e=this.getEventsStub(t,n);if(!e)throw new Error(`Called getEvents for ${t} on a stubbed contract without a return value. The function must be stubbed first: | ||
| contract.stubEvents("${t}", value)`);return e(n)}stubRead({functionName:t,args:n,value:e,options:i}){let r=this.readStubMap.get(t);if(r||(r=b(),this.readStubMap.set(t,r)),n||i){r.withArgs(n,i).resolves(e);return}r.resolves(e)}stubSimulateWrite(t,n){let e=this.simulateWriteStubMap.get(t);e||(e=b(),this.simulateWriteStubMap.set(t,e)),e.resolves(n)}stubEvents(t,n,e){let i=d({eventName:t,args:n});this.eventsStubMap.has(i)?this.getEventsStub(t,n).resolves(e):this.eventsStubMap.set(i,b().resolves(e))}getReadStub(t){return this.readStubMap.get(t)}getSimulateWriteStub(t){return this.simulateWriteStubMap.get(t)}getEventsStub(t,n){let e=d({eventName:t,args:n});return this.eventsStubMap.get(e)}decodeFunctionData(...t){throw new Error("Method not implemented.")}encodeFunctionData(...t){throw new Error("Method not implemented.")}};function d(o){function t(n,e){return typeof e=="bigint"?e.toString():e}return F.stableStringify(o,t)}a();import{stub as l}from"sinon";a();var A="0xBob";var T=class extends s{writeStubMap=new Map;getSignerAddress=l().resolves(A);async write(...[t,n,e]){let i=this.getWriteStub(t);if(!i)throw new Error(`Called write for ${t} on a stubbed contract without a return value. The function must be stubbed first: | ||
| contract.stubWrite("${t}", value)`);return i(n,e)}stubWrite(t,n){let e=this.writeStubMap.get(t);e||(e=l(),this.writeStubMap.set(t,e)),e.resolves(n)}getWriteStub(t){return this.writeStubMap.get(t)}};a();import{stub as p}from"sinon";var m=class{getBlockStub;getTransactionStub;stubGetBlock({args:t,value:n}){if(this.getBlockStub||(this.getBlockStub=p()),t){this.getBlockStub.withArgs(t).resolves(n);return}this.getBlockStub.resolves(n)}stubGetTransaction({args:t,value:n}){if(this.getTransactionStub||(this.getTransactionStub=p()),t){this.getTransactionStub.withArgs(t).resolves(n);return}this.getTransactionStub.resolves(n)}getBlock(...t){if(!this.getBlockStub)throw new Error(`The getBlock function must be stubbed first: | ||
| contract.stubEvents("${t}", value)`);return e(n)}stubRead({functionName:t,args:n,value:e,options:i}){let r=this.readStubMap.get(t);if(r||(r=b(),this.readStubMap.set(t,r)),n||i){r.withArgs(n,i).resolves(e);return}r.resolves(e)}stubSimulateWrite(t,n){let e=this.simulateWriteStubMap.get(t);e||(e=b(),this.simulateWriteStubMap.set(t,e)),e.resolves(n)}stubEvents(t,n,e){let i=l({eventName:t,args:n});this.eventsStubMap.has(i)?this.getEventsStub(t,n).resolves(e):this.eventsStubMap.set(i,b().resolves(e))}getReadStub(t){return this.readStubMap.get(t)}getSimulateWriteStub(t){return this.simulateWriteStubMap.get(t)}getEventsStub(t,n){let e=l({eventName:t,args:n});return this.eventsStubMap.get(e)}decodeFunctionData(...t){throw new Error("Method not implemented.")}encodeFunctionData(...t){throw new Error("Method not implemented.")}};function l(a){function t(n,e){return typeof e=="bigint"?e.toString():e}return N.stableStringify(a,t)}o();import{stub as p}from"sinon";o();var A="0xBob";var T=class extends s{writeStubMap=new Map;getSignerAddress=p().resolves(A);async write(...[t,n,e]){let i=this.getWriteStub(t);if(!i)throw new Error(`Called write for ${t} on a stubbed contract without a return value. The function must be stubbed first: | ||
| contract.stubWrite("${t}", value)`);return i(n,e)}stubWrite(t,n){let e=this.writeStubMap.get(t);e||(e=p(),this.writeStubMap.set(t,e)),e.resolves(n)}getWriteStub(t){return this.writeStubMap.get(t)}};o();import{stub as m}from"sinon";var d=class{getBalanceStub;getBlockStub;getTransactionStub;stubGetBalance({args:t,value:n}){if(this.getBalanceStub||(this.getBalanceStub=m()),t){this.getBalanceStub.withArgs(t).resolves(n);return}this.getBalanceStub.resolves(n)}stubGetBlock({args:t,value:n}){if(this.getBlockStub||(this.getBlockStub=m()),t){this.getBlockStub.withArgs(t).resolves(n);return}this.getBlockStub.resolves(n)}stubGetTransaction({args:t,value:n}){if(this.getTransactionStub||(this.getTransactionStub=m()),t){this.getTransactionStub.withArgs(t).resolves(n);return}this.getTransactionStub.resolves(n)}getBalance(...t){if(!this.getBalanceStub)throw new Error(`The getBalance function must be stubbed first: | ||
| contract.stubGetBalance()`);return this.getBalanceStub(t)}getBlock(...t){if(!this.getBlockStub)throw new Error(`The getBlock function must be stubbed first: | ||
| contract.stubGetBlock()`);return this.getBlockStub(t)}getTransaction(...t){if(!this.getTransactionStub)throw new Error(`The getTransaction function must be stubbed first: | ||
| contract.stubGetTransaction()`);return this.getTransactionStub(t)}async waitForTransaction(...[t,{timeout:n=6e4}={}]){return new Promise(async e=>{let i;if(i=await this.getTransactionStub?.([t]).catch(),i)return e(N(i));let r=0,S=setInterval(async()=>{r+=1e3,i=await this.getTransactionStub?.([t]).catch(),(i||r>=n)&&(clearInterval(S),e(N(i)))},1e3)})}};function N(o){return o?{blockHash:o.blockHash,blockNumber:o.blockNumber,from:o.from,to:o.to,transactionIndex:o.transactionIndex,cumulativeGasUsed:0n,effectiveGasPrice:0n,transactionHash:o.hash,gasUsed:0n,logsBloom:"0x"}:void 0}export{m as NetworkStub,s as ReadContractStub,T as ReadWriteContractStub}; | ||
| contract.stubGetTransaction()`);return this.getTransactionStub(t)}async waitForTransaction(...[t,{timeout:n=6e4}={}]){return new Promise(async e=>{let i;if(i=await this.getTransactionStub?.([t]).catch(),i)return e(g(i));let r=0,S=setInterval(async()=>{r+=1e3,i=await this.getTransactionStub?.([t]).catch(),(i||r>=n)&&(clearInterval(S),e(g(i)))},1e3)})}};function g(a){return a?{blockHash:a.blockHash,blockNumber:a.blockNumber,from:a.from,to:a.to,transactionIndex:a.transactionIndex,cumulativeGasUsed:0n,effectiveGasPrice:0n,transactionHash:a.hash,gasUsed:0n,logsBloom:"0x"}:void 0}export{d as NetworkStub,s as ReadContractStub,T as ReadWriteContractStub}; | ||
| //# sourceMappingURL=stubs.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/exports/stubs.ts","../src/contract/stubs/ReadContractStub.ts","../src/contract/stubs/ReadWriteContractStub.ts","../src/base/testing/accounts.ts","../src/network/stubs/NetworkStub.ts"],"sourcesContent":["// Contract\nexport { ReadContractStub } from 'src/contract/stubs/ReadContractStub';\nexport { ReadWriteContractStub } from 'src/contract/stubs/ReadWriteContractStub';\n\n// Network\nexport { NetworkStub } from 'src/network/stubs/NetworkStub';\n","import { Abi } from 'abitype';\nimport stringify from 'fast-safe-stringify';\nimport { SinonStub, stub } from 'sinon';\nimport {\n ContractDecodeFunctionDataArgs,\n ContractEncodeFunctionDataArgs,\n ContractGetEventsArgs,\n ContractGetEventsOptions,\n ContractReadArgs,\n ContractReadOptions,\n ContractWriteArgs,\n ContractWriteOptions,\n ReadContract,\n} from 'src/contract/types/Contract';\nimport { Event, EventName } from 'src/contract/types/Event';\nimport {\n DecodedFunctionData,\n FunctionArgs,\n FunctionName,\n FunctionReturn,\n} from 'src/contract/types/Function';\n\n/**\n * A mock implementation of a `ReadContract` designed to facilitate unit\n * testing. The `ReadContractStub` provides a way to stub out specific\n * contract read, write, and event-fetching behaviors, allowing tests to focus\n * on the business logic of the SDK.\n *\n * @example\n * const contract = new ReadContractStub(ERC20ABI);\n * contract.stubRead(\"baseToken\", \"0x123abc\");\n *\n * const value = await contract.read(\"baseToken\", []); // \"0x123abc\"\n *\n */\nexport class ReadContractStub<TAbi extends Abi = Abi>\n implements ReadContract<TAbi>\n{\n abi;\n address = '0x0000000000000000000000000000000000000000' as const;\n\n // Maps to store stubs for different contract methods based on their name.\n protected readStubMap = new Map<\n FunctionName<TAbi>,\n ReadStub<TAbi, FunctionName<TAbi>>\n >();\n protected eventsStubMap = new Map<\n EventName<TAbi>,\n EventsStub<TAbi, EventName<TAbi>>\n >();\n protected simulateWriteStubMap = new Map<\n FunctionName<TAbi, 'nonpayable' | 'payable'>,\n SimulateWriteStub<TAbi, FunctionName<TAbi, 'nonpayable' | 'payable'>>\n >();\n\n constructor(abi: TAbi = [] as any) {\n this.abi = abi;\n }\n\n /**\n * Simulates a contract read operation for a given function. If the function\n * is not previously stubbed using `stubRead`, an error will be thrown.\n */\n async read<TFunctionName extends FunctionName<TAbi>>(\n ...[functionName, args, options]: ContractReadArgs<TAbi, TFunctionName>\n ): Promise<FunctionReturn<TAbi, TFunctionName>> {\n const stub = this.getReadStub(functionName);\n if (!stub) {\n throw new Error(\n `Called read for ${functionName} on a stubbed contract without a return value. The function must be stubbed first:\\n\\tcontract.stubRead(\"${functionName}\", value)`,\n );\n }\n return stub(args, options);\n }\n\n /**\n * Simulates a contract write operation for a given function. If the function\n * is not previously stubbed using `stubWrite`, an error will be thrown.\n */\n async simulateWrite<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(\n ...[functionName, args, options]: ContractWriteArgs<TAbi, TFunctionName>\n ): Promise<FunctionReturn<TAbi, TFunctionName>> {\n const stub = this.getSimulateWriteStub(functionName);\n if (!stub) {\n throw new Error(\n `Called simulateWrite for ${functionName} on a stubbed contract without a return value. The function must be stubbed first:\\n\\tcontract.stubWrite(\"${functionName}\", value)`,\n );\n }\n return stub(args, options);\n }\n\n /**\n * Simulates fetching events for a given event name from the contract. If the\n * event name is not previously stubbed using `stubEvents`, an error will be\n * thrown.\n */\n async getEvents<TEventName extends EventName<TAbi>>(\n ...[eventName, options]: ContractGetEventsArgs<TAbi, TEventName>\n ): Promise<Event<TAbi, TEventName>[]> {\n const stub = this.getEventsStub(eventName, options);\n if (!stub) {\n throw new Error(\n `Called getEvents for ${eventName} on a stubbed contract without a return value. The function must be stubbed first:\\n\\tcontract.stubEvents(\"${eventName}\", value)`,\n );\n }\n return stub(options);\n }\n\n /**\n * Stubs the return value for a given function when `read` is called with that\n * function name. This method overrides any previously stubbed values for the\n * same function.\n */\n stubRead<TFunctionName extends FunctionName<TAbi>>({\n functionName,\n args,\n value,\n options,\n }: {\n functionName: TFunctionName;\n args?: FunctionArgs<TAbi, TFunctionName>;\n value: FunctionReturn<TAbi, TFunctionName>;\n options?: ContractReadOptions;\n }): void {\n let readStub = this.readStubMap.get(functionName);\n if (!readStub) {\n readStub = stub();\n this.readStubMap.set(functionName, readStub);\n }\n\n // Account for dynamic args if provided\n if (args || options) {\n // The stub returned from the map doesn't have a strong FunctionName type\n // so we have to cast to avoid contravariance errors with the args.\n (readStub as ReadStub<TAbi, TFunctionName>)\n .withArgs(args, options)\n .resolves(value);\n return;\n }\n\n readStub.resolves(value);\n }\n\n /**\n * Stubs the return value for a given function when `simulateWrite` is called\n * with that function name. This method overrides any previously stubbed\n * values for the same function.\n *\n * *Note: The stub doesn't account for dynamic values based on provided\n * arguments/options.*\n */\n stubSimulateWrite<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(\n functionName: TFunctionName,\n value: FunctionReturn<TAbi, TFunctionName>,\n ): void {\n let simulateWriteStub = this.simulateWriteStubMap.get(functionName);\n if (!simulateWriteStub) {\n simulateWriteStub = stub();\n this.simulateWriteStubMap.set(functionName, simulateWriteStub);\n }\n simulateWriteStub.resolves(value);\n }\n\n /**\n * Stubs the return value for a given event name when `getEvents` is called\n * with that event name. This method overrides any previously stubbed values\n * for the same event.\n */\n stubEvents<TEventName extends EventName<TAbi>>(\n eventName: TEventName,\n args: ContractGetEventsOptions<TAbi, TEventName> | undefined,\n value: Event<TAbi, TEventName>[],\n ): void {\n const stubKey = stableStringify({ eventName, args });\n if (this.eventsStubMap.has(stubKey)) {\n this.getEventsStub(eventName, args)!.resolves(value as any);\n } else {\n this.eventsStubMap.set(stubKey, stub().resolves(value) as any);\n }\n }\n\n /**\n * Retrieves the stub associated with a read function name.\n * Useful for assertions in testing, such as checking call counts.\n */\n getReadStub<TFunctionName extends FunctionName<TAbi>>(\n functionName: TFunctionName,\n ): ReadStub<TAbi, TFunctionName> | undefined {\n return this.readStubMap.get(functionName) as\n | ReadStub<TAbi, TFunctionName>\n | undefined;\n }\n\n /**\n * Retrieves the stub associated with a write function name.\n * Useful for assertions in testing, such as checking call counts.\n */\n getSimulateWriteStub<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(\n functionName: TFunctionName,\n ): SimulateWriteStub<TAbi, TFunctionName> | undefined {\n return this.simulateWriteStubMap.get(functionName) as\n | SimulateWriteStub<TAbi, TFunctionName>\n | undefined;\n }\n\n /**\n * Retrieves the stub associated with an event name.\n * Useful for assertions in testing, such as checking call counts.\n */\n getEventsStub<TEventName extends EventName<TAbi>>(\n eventName: TEventName,\n args?: ContractGetEventsOptions<TAbi, TEventName> | undefined,\n ): EventsStub<TAbi, TEventName> | undefined {\n const stubKey = stableStringify({ eventName, args });\n return this.eventsStubMap.get(stubKey) as\n | EventsStub<TAbi, TEventName>\n | undefined;\n }\n\n // TODO:\n decodeFunctionData<\n TFunctionName extends FunctionName<TAbi> = FunctionName<TAbi>,\n >(\n ...args: ContractDecodeFunctionDataArgs\n ): DecodedFunctionData<TAbi, TFunctionName> {\n throw new Error('Method not implemented.');\n }\n\n // TODO:\n encodeFunctionData<\n TFunctionName extends FunctionName<TAbi> = FunctionName<TAbi>,\n >(\n ...args: ContractEncodeFunctionDataArgs<TAbi, TFunctionName>\n ): `0x${string}` {\n throw new Error('Method not implemented.');\n }\n}\n\n/**\n * Type representing a stub for the \"read\" function of a contract.\n */\ntype ReadStub<\n TAbi extends Abi,\n TFunctionName extends FunctionName<TAbi>,\n> = SinonStub<\n [args?: FunctionArgs<TAbi, TFunctionName>, options?: ContractReadOptions],\n Promise<FunctionReturn<TAbi, TFunctionName>>\n>;\n\n/**\n * Type representing a stub for the \"getEvents\" function of a contract.\n */\ntype EventsStub<\n TAbi extends Abi,\n TEventName extends EventName<TAbi>,\n> = SinonStub<\n [options?: ContractGetEventsOptions<TAbi, TEventName>],\n Promise<Event<TAbi, TEventName>[]>\n>;\n\n/**\n * Type representing a stub for the \"write\" and \"simulateWrite\" functions of a\n * contract.\n */\ntype SimulateWriteStub<\n TAbi extends Abi,\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n> = SinonStub<\n [\n args?: FunctionArgs<TAbi, TFunctionName> | undefined,\n options?: ContractWriteOptions,\n ],\n Promise<FunctionReturn<TAbi, TFunctionName>>\n>;\n\nfunction stableStringify(obj: Record<any, any>) {\n // simple non-recursive stringify replacer for bigints\n function replacer(_: any, v: any) {\n return typeof v === 'bigint' ? v.toString() : v;\n }\n\n return stringify.stableStringify(obj, replacer);\n}\n","import { Abi } from 'abitype';\nimport { SinonStub, stub } from 'sinon';\nimport { BOB } from 'src/base/testing/accounts';\nimport { ReadContractStub } from 'src/contract/stubs/ReadContractStub';\nimport {\n ContractWriteArgs,\n ContractWriteOptions,\n ReadWriteContract,\n} from 'src/contract/types/Contract';\nimport { FunctionArgs, FunctionName } from 'src/contract/types/Function';\n\n/**\n * A mock implementation of a writable Ethereum contract designed for unit\n * testing purposes. The `ReadWriteContractStub` extends the functionalities of\n * `ReadContractStub` and provides capabilities to stub out specific\n * contract write behaviors. This makes it a valuable tool when testing\n * scenarios that involve contract writing operations, without actually\n * interacting with a real Ethereum contract.\n *\n * @example\n * const contract = new ReadWriteContractStub(ERC20ABI);\n * contract.stubWrite(\"addLiquidity\", 100n);\n *\n * const result = await contract.write(\"addLiquidity\", []); // 100n\n * @extends {ReadContractStub<TAbi>}\n * @implements {ReadWriteContract<TAbi>}\n */\nexport class ReadWriteContractStub<TAbi extends Abi = Abi>\n extends ReadContractStub<TAbi>\n implements ReadWriteContract<TAbi>\n{\n protected writeStubMap = new Map<\n FunctionName<TAbi, 'nonpayable' | 'payable'>,\n WriteStub<TAbi, FunctionName<TAbi, 'nonpayable' | 'payable'>>\n >();\n\n getSignerAddress = stub().resolves(BOB);\n\n /**\n * Simulates a contract write operation for a given function. If the function\n * is not previously stubbed using `stubWrite` from the parent class, an error\n * will be thrown.\n */\n async write<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(\n ...[functionName, args, options]: ContractWriteArgs<TAbi, TFunctionName>\n ): Promise<`0x${string}`> {\n const stub = this.getWriteStub(functionName);\n if (!stub) {\n throw new Error(\n `Called write for ${functionName} on a stubbed contract without a return value. The function must be stubbed first:\\n\\tcontract.stubWrite(\"${functionName}\", value)`,\n );\n }\n return stub(args, options);\n }\n\n /**\n * Stubs the return value for a given function when `simulateWrite` is called\n * with that function name. This method overrides any previously stubbed\n * values for the same function.\n *\n * *Note: The stub doesn't account for dynamic values based on provided\n * arguments/options.*\n */\n stubWrite<TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>>(\n functionName: TFunctionName,\n value: `0x${string}`,\n ): void {\n let writeStub = this.writeStubMap.get(functionName);\n if (!writeStub) {\n writeStub = stub();\n this.writeStubMap.set(functionName, writeStub);\n }\n writeStub.resolves(value);\n }\n\n /**\n * Retrieves the stub associated with a write function name.\n * Useful for assertions in testing, such as checking call counts.\n */\n getWriteStub<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(functionName: TFunctionName): WriteStub<TAbi, TFunctionName> | undefined {\n return this.writeStubMap.get(functionName) as WriteStub<\n TAbi,\n TFunctionName\n >;\n }\n}\n\n/**\n * Type representing a stub for the \"write\" and \"simulateWrite\" functions of a\n * contract.\n */\ntype WriteStub<\n TAbi extends Abi,\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n> = SinonStub<\n [args?: FunctionArgs<TAbi, TFunctionName>, options?: ContractWriteOptions],\n `0x${string}`\n>;\n","export const BOB = '0xBob';\nexport const ALICE = '0xAlice';\nexport const NANCY = '0xNancy';\n","import { SinonStub, stub } from 'sinon';\nimport { Block } from 'src/network/types/Block';\nimport {\n Network,\n NetworkGetBlockArgs,\n NetworkGetTransactionArgs,\n NetworkWaitForTransactionArgs,\n} from 'src/network/types/Network';\nimport { Transaction, TransactionReceipt } from 'src/network/types/Transaction';\n\n/**\n * A mock implementation of a `Network` designed to facilitate unit\n * testing.\n */\nexport class NetworkStub implements Network {\n protected getBlockStub:\n | SinonStub<[NetworkGetBlockArgs?], Promise<Block | undefined>>\n | undefined;\n protected getTransactionStub:\n | SinonStub<[NetworkGetTransactionArgs?], Promise<Transaction | undefined>>\n | undefined;\n\n stubGetBlock({\n args,\n value,\n }: {\n args?: NetworkGetBlockArgs | undefined;\n value: Block | undefined;\n }): void {\n if (!this.getBlockStub) {\n this.getBlockStub = stub();\n }\n\n // Account for dynamic args if provided\n if (args) {\n this.getBlockStub.withArgs(args).resolves(value);\n return;\n }\n\n this.getBlockStub.resolves(value);\n }\n\n stubGetTransaction({\n args,\n value,\n }: {\n args?: NetworkGetTransactionArgs;\n value: Transaction | undefined;\n }): void {\n if (!this.getTransactionStub) {\n this.getTransactionStub = stub();\n }\n\n // Account for dynamic args if provided\n if (args) {\n this.getTransactionStub.withArgs(args).resolves(value);\n return;\n }\n\n this.getTransactionStub.resolves(value);\n }\n\n getBlock(...args: NetworkGetBlockArgs): Promise<Block | undefined> {\n if (!this.getBlockStub) {\n throw new Error(\n `The getBlock function must be stubbed first:\\n\\tcontract.stubGetBlock()`,\n );\n }\n return this.getBlockStub(args);\n }\n\n getTransaction(\n ...args: NetworkGetTransactionArgs\n ): Promise<Transaction | undefined> {\n if (!this.getTransactionStub) {\n throw new Error(\n `The getTransaction function must be stubbed first:\\n\\tcontract.stubGetTransaction()`,\n );\n }\n return this.getTransactionStub(args);\n }\n\n async waitForTransaction(\n ...[hash, { timeout = 60_000 } = {}]: NetworkWaitForTransactionArgs\n ): Promise<TransactionReceipt | undefined> {\n return new Promise(async (resolve) => {\n let transaction: Transaction | undefined;\n\n transaction = await this.getTransactionStub?.([hash]).catch();\n\n if (transaction) {\n return resolve(transactionToReceipt(transaction));\n }\n\n // Poll for the transaction until it's found or the timeout is reached\n let waitedTime = 0;\n const interval = setInterval(async () => {\n waitedTime += 1000;\n transaction = await this.getTransactionStub?.([hash]).catch();\n if (transaction || waitedTime >= timeout) {\n clearInterval(interval);\n resolve(transactionToReceipt(transaction));\n }\n }, 1000);\n });\n }\n}\n\nexport function transactionToReceipt(\n transaction: Transaction | undefined,\n): TransactionReceipt | undefined {\n return transaction\n ? {\n blockHash: transaction.blockHash!,\n blockNumber: transaction.blockNumber!,\n from: transaction.from!,\n to: transaction.to!,\n transactionIndex: transaction.transactionIndex!,\n cumulativeGasUsed: 0n,\n effectiveGasPrice: 0n,\n transactionHash: transaction.hash!,\n gasUsed: 0n,\n logsBloom: '0x',\n }\n : undefined;\n}\n"],"mappings":"wCAAAA,ICAAC,IACA,OAAOC,MAAe,sBACtB,OAAoB,QAAAC,MAAY,QAiCzB,IAAMC,EAAN,KAEP,CACE,IACA,QAAU,6CAGA,YAAc,IAAI,IAIlB,cAAgB,IAAI,IAIpB,qBAAuB,IAAI,IAKrC,YAAYC,EAAY,CAAC,EAAU,CACjC,KAAK,IAAMA,CACb,CAMA,MAAM,QACD,CAACC,EAAcC,EAAMC,CAAO,EACe,CAC9C,IAAML,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C,CAChC,OAAOA,EACH,CACE,UAAWA,EAAY,UACvB,YAAaA,EAAY,YACzB,KAAMA,EAAY,KAClB,GAAIA,EAAY,GAChB,iBAAkBA,EAAY,iBAC9B,kBAAmB,GACnB,kBAAmB,GACnB,gBAAiBA,EAAY,KAC7B,QAAS,GACT,UAAW,IACb,EACA,MACN","names":["init_esm_shims","init_esm_shims","stringify","stub","ReadContractStub","abi","functionName","args","options","eventName","value","readStub","simulateWriteStub","stubKey","stableStringify","obj","replacer","_","v","init_esm_shims","stub","init_esm_shims","BOB","ReadWriteContractStub","ReadContractStub","stub","BOB","functionName","args","options","value","writeStub","init_esm_shims","stub","NetworkStub","args","value","hash","timeout","resolve","transaction","transactionToReceipt","waitedTime","interval"]} | ||
| {"version":3,"sources":["../src/exports/stubs.ts","../src/contract/stubs/ReadContractStub.ts","../src/contract/stubs/ReadWriteContractStub.ts","../src/base/testing/accounts.ts","../src/network/stubs/NetworkStub.ts"],"sourcesContent":["// Contract\nexport { ReadContractStub } from 'src/contract/stubs/ReadContractStub';\nexport { ReadWriteContractStub } from 'src/contract/stubs/ReadWriteContractStub';\n\n// Network\nexport { NetworkStub } from 'src/network/stubs/NetworkStub';\n","import { Abi } from 'abitype';\nimport stringify from 'fast-safe-stringify';\nimport { SinonStub, stub } from 'sinon';\nimport {\n ContractDecodeFunctionDataArgs,\n ContractEncodeFunctionDataArgs,\n ContractGetEventsArgs,\n ContractGetEventsOptions,\n ContractReadArgs,\n ContractReadOptions,\n ContractWriteArgs,\n ContractWriteOptions,\n ReadContract,\n} from 'src/contract/types/Contract';\nimport { Event, EventName } from 'src/contract/types/Event';\nimport {\n DecodedFunctionData,\n FunctionArgs,\n FunctionName,\n FunctionReturn,\n} from 'src/contract/types/Function';\n\n/**\n * A mock implementation of a `ReadContract` designed to facilitate unit\n * testing. The `ReadContractStub` provides a way to stub out specific\n * contract read, write, and event-fetching behaviors, allowing tests to focus\n * on the business logic of the SDK.\n *\n * @example\n * const contract = new ReadContractStub(ERC20ABI);\n * contract.stubRead(\"baseToken\", \"0x123abc\");\n *\n * const value = await contract.read(\"baseToken\", []); // \"0x123abc\"\n *\n */\nexport class ReadContractStub<TAbi extends Abi = Abi>\n implements ReadContract<TAbi>\n{\n abi;\n address = '0x0000000000000000000000000000000000000000' as const;\n\n // Maps to store stubs for different contract methods based on their name.\n protected readStubMap = new Map<\n FunctionName<TAbi>,\n ReadStub<TAbi, FunctionName<TAbi>>\n >();\n protected eventsStubMap = new Map<\n EventName<TAbi>,\n EventsStub<TAbi, EventName<TAbi>>\n >();\n protected simulateWriteStubMap = new Map<\n FunctionName<TAbi, 'nonpayable' | 'payable'>,\n SimulateWriteStub<TAbi, FunctionName<TAbi, 'nonpayable' | 'payable'>>\n >();\n\n constructor(abi: TAbi = [] as any) {\n this.abi = abi;\n }\n\n /**\n * Simulates a contract read operation for a given function. If the function\n * is not previously stubbed using `stubRead`, an error will be thrown.\n */\n async read<TFunctionName extends FunctionName<TAbi>>(\n ...[functionName, args, options]: ContractReadArgs<TAbi, TFunctionName>\n ): Promise<FunctionReturn<TAbi, TFunctionName>> {\n const stub = this.getReadStub(functionName);\n if (!stub) {\n throw new Error(\n `Called read for ${functionName} on a stubbed contract without a return value. The function must be stubbed first:\\n\\tcontract.stubRead(\"${functionName}\", value)`,\n );\n }\n return stub(args, options);\n }\n\n /**\n * Simulates a contract write operation for a given function. If the function\n * is not previously stubbed using `stubWrite`, an error will be thrown.\n */\n async simulateWrite<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(\n ...[functionName, args, options]: ContractWriteArgs<TAbi, TFunctionName>\n ): Promise<FunctionReturn<TAbi, TFunctionName>> {\n const stub = this.getSimulateWriteStub(functionName);\n if (!stub) {\n throw new Error(\n `Called simulateWrite for ${functionName} on a stubbed contract without a return value. The function must be stubbed first:\\n\\tcontract.stubWrite(\"${functionName}\", value)`,\n );\n }\n return stub(args, options);\n }\n\n /**\n * Simulates fetching events for a given event name from the contract. If the\n * event name is not previously stubbed using `stubEvents`, an error will be\n * thrown.\n */\n async getEvents<TEventName extends EventName<TAbi>>(\n ...[eventName, options]: ContractGetEventsArgs<TAbi, TEventName>\n ): Promise<Event<TAbi, TEventName>[]> {\n const stub = this.getEventsStub(eventName, options);\n if (!stub) {\n throw new Error(\n `Called getEvents for ${eventName} on a stubbed contract without a return value. The function must be stubbed first:\\n\\tcontract.stubEvents(\"${eventName}\", value)`,\n );\n }\n return stub(options);\n }\n\n /**\n * Stubs the return value for a given function when `read` is called with that\n * function name. This method overrides any previously stubbed values for the\n * same function.\n */\n stubRead<TFunctionName extends FunctionName<TAbi>>({\n functionName,\n args,\n value,\n options,\n }: {\n functionName: TFunctionName;\n args?: FunctionArgs<TAbi, TFunctionName>;\n value: FunctionReturn<TAbi, TFunctionName>;\n options?: ContractReadOptions;\n }): void {\n let readStub = this.readStubMap.get(functionName);\n if (!readStub) {\n readStub = stub();\n this.readStubMap.set(functionName, readStub);\n }\n\n // Account for dynamic args if provided\n if (args || options) {\n // The stub returned from the map doesn't have a strong FunctionName type\n // so we have to cast to avoid contravariance errors with the args.\n (readStub as ReadStub<TAbi, TFunctionName>)\n .withArgs(args, options)\n .resolves(value);\n return;\n }\n\n readStub.resolves(value);\n }\n\n /**\n * Stubs the return value for a given function when `simulateWrite` is called\n * with that function name. This method overrides any previously stubbed\n * values for the same function.\n *\n * *Note: The stub doesn't account for dynamic values based on provided\n * arguments/options.*\n */\n stubSimulateWrite<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(\n functionName: TFunctionName,\n value: FunctionReturn<TAbi, TFunctionName>,\n ): void {\n let simulateWriteStub = this.simulateWriteStubMap.get(functionName);\n if (!simulateWriteStub) {\n simulateWriteStub = stub();\n this.simulateWriteStubMap.set(functionName, simulateWriteStub);\n }\n simulateWriteStub.resolves(value);\n }\n\n /**\n * Stubs the return value for a given event name when `getEvents` is called\n * with that event name. This method overrides any previously stubbed values\n * for the same event.\n */\n stubEvents<TEventName extends EventName<TAbi>>(\n eventName: TEventName,\n args: ContractGetEventsOptions<TAbi, TEventName> | undefined,\n value: Event<TAbi, TEventName>[],\n ): void {\n const stubKey = stableStringify({ eventName, args });\n if (this.eventsStubMap.has(stubKey)) {\n this.getEventsStub(eventName, args)!.resolves(value as any);\n } else {\n this.eventsStubMap.set(stubKey, stub().resolves(value) as any);\n }\n }\n\n /**\n * Retrieves the stub associated with a read function name.\n * Useful for assertions in testing, such as checking call counts.\n */\n getReadStub<TFunctionName extends FunctionName<TAbi>>(\n functionName: TFunctionName,\n ): ReadStub<TAbi, TFunctionName> | undefined {\n return this.readStubMap.get(functionName) as\n | ReadStub<TAbi, TFunctionName>\n | undefined;\n }\n\n /**\n * Retrieves the stub associated with a write function name.\n * Useful for assertions in testing, such as checking call counts.\n */\n getSimulateWriteStub<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(\n functionName: TFunctionName,\n ): SimulateWriteStub<TAbi, TFunctionName> | undefined {\n return this.simulateWriteStubMap.get(functionName) as\n | SimulateWriteStub<TAbi, TFunctionName>\n | undefined;\n }\n\n /**\n * Retrieves the stub associated with an event name.\n * Useful for assertions in testing, such as checking call counts.\n */\n getEventsStub<TEventName extends EventName<TAbi>>(\n eventName: TEventName,\n args?: ContractGetEventsOptions<TAbi, TEventName> | undefined,\n ): EventsStub<TAbi, TEventName> | undefined {\n const stubKey = stableStringify({ eventName, args });\n return this.eventsStubMap.get(stubKey) as\n | EventsStub<TAbi, TEventName>\n | undefined;\n }\n\n // TODO:\n decodeFunctionData<\n TFunctionName extends FunctionName<TAbi> = FunctionName<TAbi>,\n >(\n ...args: ContractDecodeFunctionDataArgs\n ): DecodedFunctionData<TAbi, TFunctionName> {\n throw new Error('Method not implemented.');\n }\n\n // TODO:\n encodeFunctionData<\n TFunctionName extends FunctionName<TAbi> = FunctionName<TAbi>,\n >(\n ...args: ContractEncodeFunctionDataArgs<TAbi, TFunctionName>\n ): `0x${string}` {\n throw new Error('Method not implemented.');\n }\n}\n\n/**\n * Type representing a stub for the \"read\" function of a contract.\n */\ntype ReadStub<\n TAbi extends Abi,\n TFunctionName extends FunctionName<TAbi>,\n> = SinonStub<\n [args?: FunctionArgs<TAbi, TFunctionName>, options?: ContractReadOptions],\n Promise<FunctionReturn<TAbi, TFunctionName>>\n>;\n\n/**\n * Type representing a stub for the \"getEvents\" function of a contract.\n */\ntype EventsStub<\n TAbi extends Abi,\n TEventName extends EventName<TAbi>,\n> = SinonStub<\n [options?: ContractGetEventsOptions<TAbi, TEventName>],\n Promise<Event<TAbi, TEventName>[]>\n>;\n\n/**\n * Type representing a stub for the \"write\" and \"simulateWrite\" functions of a\n * contract.\n */\ntype SimulateWriteStub<\n TAbi extends Abi,\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n> = SinonStub<\n [\n args?: FunctionArgs<TAbi, TFunctionName> | undefined,\n options?: ContractWriteOptions,\n ],\n Promise<FunctionReturn<TAbi, TFunctionName>>\n>;\n\nfunction stableStringify(obj: Record<any, any>) {\n // simple non-recursive stringify replacer for bigints\n function replacer(_: any, v: any) {\n return typeof v === 'bigint' ? v.toString() : v;\n }\n\n return stringify.stableStringify(obj, replacer);\n}\n","import { Abi } from 'abitype';\nimport { SinonStub, stub } from 'sinon';\nimport { BOB } from 'src/base/testing/accounts';\nimport { ReadContractStub } from 'src/contract/stubs/ReadContractStub';\nimport {\n ContractWriteArgs,\n ContractWriteOptions,\n ReadWriteContract,\n} from 'src/contract/types/Contract';\nimport { FunctionArgs, FunctionName } from 'src/contract/types/Function';\n\n/**\n * A mock implementation of a writable Ethereum contract designed for unit\n * testing purposes. The `ReadWriteContractStub` extends the functionalities of\n * `ReadContractStub` and provides capabilities to stub out specific\n * contract write behaviors. This makes it a valuable tool when testing\n * scenarios that involve contract writing operations, without actually\n * interacting with a real Ethereum contract.\n *\n * @example\n * const contract = new ReadWriteContractStub(ERC20ABI);\n * contract.stubWrite(\"addLiquidity\", 100n);\n *\n * const result = await contract.write(\"addLiquidity\", []); // 100n\n * @extends {ReadContractStub<TAbi>}\n * @implements {ReadWriteContract<TAbi>}\n */\nexport class ReadWriteContractStub<TAbi extends Abi = Abi>\n extends ReadContractStub<TAbi>\n implements ReadWriteContract<TAbi>\n{\n protected writeStubMap = new Map<\n FunctionName<TAbi, 'nonpayable' | 'payable'>,\n WriteStub<TAbi, FunctionName<TAbi, 'nonpayable' | 'payable'>>\n >();\n\n getSignerAddress = stub().resolves(BOB);\n\n /**\n * Simulates a contract write operation for a given function. If the function\n * is not previously stubbed using `stubWrite` from the parent class, an error\n * will be thrown.\n */\n async write<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(\n ...[functionName, args, options]: ContractWriteArgs<TAbi, TFunctionName>\n ): Promise<`0x${string}`> {\n const stub = this.getWriteStub(functionName);\n if (!stub) {\n throw new Error(\n `Called write for ${functionName} on a stubbed contract without a return value. The function must be stubbed first:\\n\\tcontract.stubWrite(\"${functionName}\", value)`,\n );\n }\n return stub(args, options);\n }\n\n /**\n * Stubs the return value for a given function when `simulateWrite` is called\n * with that function name. This method overrides any previously stubbed\n * values for the same function.\n *\n * *Note: The stub doesn't account for dynamic values based on provided\n * arguments/options.*\n */\n stubWrite<TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>>(\n functionName: TFunctionName,\n value: `0x${string}`,\n ): void {\n let writeStub = this.writeStubMap.get(functionName);\n if (!writeStub) {\n writeStub = stub();\n this.writeStubMap.set(functionName, writeStub);\n }\n writeStub.resolves(value);\n }\n\n /**\n * Retrieves the stub associated with a write function name.\n * Useful for assertions in testing, such as checking call counts.\n */\n getWriteStub<\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n >(functionName: TFunctionName): WriteStub<TAbi, TFunctionName> | undefined {\n return this.writeStubMap.get(functionName) as WriteStub<\n TAbi,\n TFunctionName\n >;\n }\n}\n\n/**\n * Type representing a stub for the \"write\" and \"simulateWrite\" functions of a\n * contract.\n */\ntype WriteStub<\n TAbi extends Abi,\n TFunctionName extends FunctionName<TAbi, 'nonpayable' | 'payable'>,\n> = SinonStub<\n [args?: FunctionArgs<TAbi, TFunctionName>, options?: ContractWriteOptions],\n `0x${string}`\n>;\n","export const BOB = '0xBob';\nexport const ALICE = '0xAlice';\nexport const NANCY = '0xNancy';\n","import { SinonStub, stub } from 'sinon';\nimport { Block } from 'src/network/types/Block';\nimport {\n Network,\n NetworkGetBalanceArgs,\n NetworkGetBlockArgs,\n NetworkGetTransactionArgs,\n NetworkWaitForTransactionArgs,\n} from 'src/network/types/Network';\nimport { Transaction, TransactionReceipt } from 'src/network/types/Transaction';\n\n/**\n * A mock implementation of a `Network` designed to facilitate unit\n * testing.\n */\nexport class NetworkStub implements Network {\n protected getBalanceStub:\n | SinonStub<[NetworkGetBalanceArgs?], Promise<bigint>>\n | undefined;\n protected getBlockStub:\n | SinonStub<[NetworkGetBlockArgs?], Promise<Block | undefined>>\n | undefined;\n protected getTransactionStub:\n | SinonStub<[NetworkGetTransactionArgs?], Promise<Transaction | undefined>>\n | undefined;\n\n stubGetBalance({\n args,\n value,\n }: {\n args?: NetworkGetBalanceArgs | undefined;\n value: bigint;\n }): void {\n if (!this.getBalanceStub) {\n this.getBalanceStub = stub();\n }\n\n // Account for dynamic args if provided\n if (args) {\n this.getBalanceStub.withArgs(args).resolves(value);\n return;\n }\n\n this.getBalanceStub.resolves(value);\n }\n\n stubGetBlock({\n args,\n value,\n }: {\n args?: NetworkGetBlockArgs | undefined;\n value: Block | undefined;\n }): void {\n if (!this.getBlockStub) {\n this.getBlockStub = stub();\n }\n\n // Account for dynamic args if provided\n if (args) {\n this.getBlockStub.withArgs(args).resolves(value);\n return;\n }\n\n this.getBlockStub.resolves(value);\n }\n\n stubGetTransaction({\n args,\n value,\n }: {\n args?: NetworkGetTransactionArgs;\n value: Transaction | undefined;\n }): void {\n if (!this.getTransactionStub) {\n this.getTransactionStub = stub();\n }\n\n // Account for dynamic args if provided\n if (args) {\n this.getTransactionStub.withArgs(args).resolves(value);\n return;\n }\n\n this.getTransactionStub.resolves(value);\n }\n\n getBalance(...args: NetworkGetBalanceArgs): Promise<bigint> {\n if (!this.getBalanceStub) {\n throw new Error(\n `The getBalance function must be stubbed first:\\n\\tcontract.stubGetBalance()`,\n );\n }\n return this.getBalanceStub(args);\n }\n\n getBlock(...args: NetworkGetBlockArgs): Promise<Block | undefined> {\n if (!this.getBlockStub) {\n throw new Error(\n `The getBlock function must be stubbed first:\\n\\tcontract.stubGetBlock()`,\n );\n }\n return this.getBlockStub(args);\n }\n\n getTransaction(\n ...args: NetworkGetTransactionArgs\n ): Promise<Transaction | undefined> {\n if (!this.getTransactionStub) {\n throw new Error(\n `The getTransaction function must be stubbed first:\\n\\tcontract.stubGetTransaction()`,\n );\n }\n return this.getTransactionStub(args);\n }\n\n async waitForTransaction(\n ...[hash, { timeout = 60_000 } = {}]: NetworkWaitForTransactionArgs\n ): Promise<TransactionReceipt | undefined> {\n return new Promise(async (resolve) => {\n let transaction: Transaction | undefined;\n\n transaction = await this.getTransactionStub?.([hash]).catch();\n\n if (transaction) {\n return resolve(transactionToReceipt(transaction));\n }\n\n // Poll for the transaction until it's found or the timeout is reached\n let waitedTime = 0;\n const interval = setInterval(async () => {\n waitedTime += 1000;\n transaction = await this.getTransactionStub?.([hash]).catch();\n if (transaction || waitedTime >= timeout) {\n clearInterval(interval);\n resolve(transactionToReceipt(transaction));\n }\n }, 1000);\n });\n }\n}\n\nexport function transactionToReceipt(\n transaction: Transaction | undefined,\n): TransactionReceipt | undefined {\n return transaction\n ? {\n blockHash: transaction.blockHash!,\n blockNumber: transaction.blockNumber!,\n from: transaction.from!,\n to: transaction.to!,\n transactionIndex: transaction.transactionIndex!,\n cumulativeGasUsed: 0n,\n effectiveGasPrice: 0n,\n transactionHash: transaction.hash!,\n gasUsed: 0n,\n logsBloom: '0x',\n }\n : undefined;\n}\n"],"mappings":"wCAAAA,ICAAC,IACA,OAAOC,MAAe,sBACtB,OAAoB,QAA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ACF,EAEF,OAAO,KAAK,mBAAmBA,CAAI,CACrC,CAEA,MAAM,sBACD,CAACE,EAAM,CAAE,QAAAC,EAAU,GAAO,EAAI,CAAC,CAAC,EACM,CACzC,OAAO,IAAI,QAAQ,MAAOC,GAAY,CACpC,IAAIC,EAIJ,GAFAA,EAAc,MAAM,KAAK,qBAAqB,CAACH,CAAI,CAAC,EAAE,MAAM,EAExDG,EACF,OAAOD,EAAQE,EAAqBD,CAAW,CAAC,EAIlD,IAAIE,EAAa,EACXC,EAAW,YAAY,SAAY,CACvCD,GAAc,IACdF,EAAc,MAAM,KAAK,qBAAqB,CAACH,CAAI,CAAC,EAAE,MAAM,GACxDG,GAAeE,GAAcJ,KAC/B,cAAcK,CAAQ,EACtBJ,EAAQE,EAAqBD,CAAW,CAAC,EAE7C,EAAG,GAAI,CACT,CAAC,CACH,CACF,EAEO,SAASC,EACdD,EACgC,CAChC,OAAOA,EACH,CACE,UAAWA,EAAY,UACvB,YAAaA,EAAY,YACzB,KAAMA,EAAY,KAClB,GAAIA,EAAY,GAChB,iBAAkBA,EAAY,iBAC9B,kBAAmB,GACnB,kBAAmB,GACnB,gBAAiBA,EAAY,KAC7B,QAAS,GACT,UAAW,IACb,EACA,MACN","names":["init_esm_shims","init_esm_shims","stringify","stub","ReadContractStub","abi","functionName","args","options","eventName","value","readStub","simulateWriteStub","stubKey","stableStringify","obj","replacer","_","v","init_esm_shims","stub","init_esm_shims","BOB","ReadWriteContractStub","ReadContractStub","stub","BOB","functionName","args","options","value","writeStub","init_esm_shims","stub","NetworkStub","args","value","hash","timeout","resolve","transaction","transactionToReceipt","waitedTime","interval"]} |
+1
-1
| { | ||
| "name": "@delvtech/evm-client", | ||
| "version": "0.2.4", | ||
| "version": "0.3.0", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "type": "module", |
| import{c as o}from"./chunk-EXKUPYHD.js";o(); | ||
| //# sourceMappingURL=chunk-ZKEAVCAH.js.map |
| {"version":3,"sources":["../src/exports/network.ts"],"sourcesContent":["export type { Block, BlockTag } from 'src/network/types/Block';\nexport type {\n Network,\n NetworkGetBlockArgs,\n NetworkGetBlockOptions,\n NetworkGetTransactionArgs,\n} from 'src/network/types/Network';\nexport type {\n MinedTransaction,\n Transaction,\n TransactionInfo,\n} from 'src/network/types/Transaction';\n"],"mappings":"wCAAAA","names":["init_esm_shims"]} |
| import { B as Block, a as BlockTag } from './Block-D7itLNye.js'; | ||
| interface TransactionInfo { | ||
| blockHash?: `0x${string}`; | ||
| blockNumber?: bigint; | ||
| from?: `0x${string}`; | ||
| hash?: `0x${string}`; | ||
| transactionIndex?: number; | ||
| } | ||
| /** Basic legacy compatible transaction */ | ||
| interface Transaction extends TransactionInfo { | ||
| type: `0x${string}`; | ||
| nonce: number; | ||
| gas: bigint; | ||
| value: bigint; | ||
| input: `0x${string}`; | ||
| gasPrice: bigint; | ||
| chainId?: number; | ||
| to?: `0x${string}` | null; | ||
| } | ||
| type MinedTransaction = Transaction & Required<TransactionInfo>; | ||
| interface TransactionReceipt { | ||
| blockHash: `0x${string}`; | ||
| blockNumber: bigint; | ||
| from: `0x${string}`; | ||
| /** | ||
| * Address of the receiver or `null` in a contract creation transaction. | ||
| */ | ||
| to: `0x${string}` | null; | ||
| /** | ||
| * The sum of gas used by this transaction and all preceding transactions in | ||
| * the same block. | ||
| */ | ||
| cumulativeGasUsed: bigint; | ||
| /** | ||
| * The amount of gas used for this specific transaction alone. | ||
| */ | ||
| gasUsed: bigint; | ||
| logsBloom: `0x${string}`; | ||
| transactionHash: `0x${string}`; | ||
| transactionIndex: number; | ||
| /** | ||
| * The actual value per gas deducted from the sender's account. Before | ||
| * EIP-1559, this is equal to the transaction's gas price. After, it is equal | ||
| * to baseFeePerGas + min(maxFeePerGas - baseFeePerGas, maxPriorityFeePerGas). | ||
| */ | ||
| effectiveGasPrice: bigint; | ||
| } | ||
| /** | ||
| * An interface representing data the SDK needs to get from the network. | ||
| */ | ||
| interface Network { | ||
| /** | ||
| * Get a block from a block tag, number, or hash. If no argument is provided, | ||
| * the latest block is returned. | ||
| */ | ||
| getBlock(...args: NetworkGetBlockArgs): Promise<Block | undefined>; | ||
| /** | ||
| * Get a transaction from a transaction hash. | ||
| */ | ||
| getTransaction(...args: NetworkGetTransactionArgs): Promise<Transaction | undefined>; | ||
| /** | ||
| * Wait for a transaction to be mined. | ||
| */ | ||
| waitForTransaction(...args: NetworkWaitForTransactionArgs): Promise<TransactionReceipt | undefined>; | ||
| } | ||
| type NetworkGetBlockOptions = { | ||
| blockHash?: `0x${string}`; | ||
| blockNumber?: never; | ||
| blockTag?: never; | ||
| } | { | ||
| blockHash?: never; | ||
| blockNumber?: bigint; | ||
| blockTag?: never; | ||
| } | { | ||
| blockHash?: never; | ||
| blockNumber?: never; | ||
| blockTag?: BlockTag; | ||
| }; | ||
| type NetworkGetBlockArgs = [options?: NetworkGetBlockOptions]; | ||
| type NetworkGetTransactionArgs = [hash: `0x${string}`]; | ||
| type NetworkWaitForTransactionArgs = [ | ||
| hash: `0x${string}`, | ||
| options?: { | ||
| /** | ||
| * The number of milliseconds to wait for the transaction until rejecting | ||
| * the promise. | ||
| */ | ||
| timeout?: number; | ||
| } | ||
| ]; | ||
| export type { MinedTransaction as M, Network as N, Transaction as T, NetworkGetBlockArgs as a, NetworkGetBlockOptions as b, NetworkGetTransactionArgs as c, TransactionInfo as d, NetworkWaitForTransactionArgs as e, TransactionReceipt as f }; |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
113039
1.99%969
1.68%