diff --git a/apps/docs/src/content/docs/welcome/getting-started.mdx b/apps/docs/src/content/docs/welcome/getting-started.mdx index c034863..f900113 100644 --- a/apps/docs/src/content/docs/welcome/getting-started.mdx +++ b/apps/docs/src/content/docs/welcome/getting-started.mdx @@ -61,8 +61,9 @@ The `InMemoryContractMetaStoreLive` handles contract metadata resolution: - Caches results in memory ```ts +import { ERC20RPCStrategyResolver, ProxyRPCStrategyResolver, PublicClient } from '@3loop/transaction-decoder' import { InMemoryContractMetaStoreLive } from '@3loop/transaction-decoder/in-memory' -import { Layer } from 'effect' +import { Effect, Layer } from 'effect' const contractMetaStore = Layer.unwrapEffect( Effect.gen(function* () { diff --git a/sandbox/quick-start/package-lock.json b/sandbox/quick-start/package-lock.json index 9bdebd3..903ea03 100644 --- a/sandbox/quick-start/package-lock.json +++ b/sandbox/quick-start/package-lock.json @@ -8,7 +8,7 @@ "name": "quick-start", "version": "0.0.0", "dependencies": { - "@3loop/transaction-decoder": "0.25.0", + "@3loop/transaction-decoder": "0.26.0", "effect": "^3.10.18", "viem": "^2.21.35" }, @@ -18,9 +18,9 @@ } }, "node_modules/@3loop/transaction-decoder": { - "version": "0.25.0", - "resolved": "https://registry.npmjs.org/@3loop/transaction-decoder/-/transaction-decoder-0.25.0.tgz", - "integrity": "sha512-GW8xxSFspV8LKMzjWiwozI9WsgvgJWctI6sVnjiTxo/3wRte6t73DKLNHzQIuPViIsJg7BV44ps8EshqKfG5lg==", + "version": "0.26.0", + "resolved": "https://registry.npmjs.org/@3loop/transaction-decoder/-/transaction-decoder-0.26.0.tgz", + "integrity": "sha512-HUNmIaGrddFATY1Nfl1m4aqZ1hFuVwKYX8KW+8gLS8QKGvYz7v76JZqLeJqrXGAC1HR3c0Cn5mSWolJQcVBsEw==", "dependencies": { "@shazow/whatsabi": "^0.18.0" }, diff --git a/sandbox/quick-start/package.json b/sandbox/quick-start/package.json index 373a141..0d46704 100644 --- a/sandbox/quick-start/package.json +++ b/sandbox/quick-start/package.json @@ -12,7 +12,7 @@ "vite": "^5.4.9" }, "dependencies": { - "@3loop/transaction-decoder": "0.25.0", + "@3loop/transaction-decoder": "0.26.0", "effect": "^3.10.18", "viem": "^2.21.35" } diff --git a/sandbox/quick-start/src/decoder.ts b/sandbox/quick-start/src/decoder.ts index e7c9491..383755b 100644 --- a/sandbox/quick-start/src/decoder.ts +++ b/sandbox/quick-start/src/decoder.ts @@ -1,7 +1,13 @@ -import { TransactionDecoder } from '@3loop/transaction-decoder' +import { + ERC20RPCStrategyResolver, + ProxyRPCStrategyResolver, + PublicClient, + TransactionDecoder, +} from '@3loop/transaction-decoder' import { createPublicClient, http } from 'viem' import { InMemoryAbiStoreLive, InMemoryContractMetaStoreLive } from '@3loop/transaction-decoder/in-memory' -import { ConfigProvider, Layer } from 'effect' +import { EtherscanV2StrategyResolver } from '@3loop/transaction-decoder' +import { Effect, Layer } from 'effect' /* * Example of decoding a transaction by hash @@ -19,12 +25,23 @@ const getPublicClient = (chainId: number) => { } } -// Create a config for the ABI loader to provide your Etherscan API key -const Config = ConfigProvider.fromMap(new Map([['ETHERSCAN_API_KEY', 'YourApiKey']])) -const ABILoaderLayer = Layer.setConfigProvider(Config) -const abiStore = InMemoryAbiStoreLive.pipe(Layer.provide(ABILoaderLayer)) +const contractMetaStore = Layer.unwrapEffect( + Effect.gen(function* () { + const service = yield* PublicClient -const contractMetaStore = InMemoryContractMetaStoreLive + return InMemoryContractMetaStoreLive.make({ + default: [ERC20RPCStrategyResolver(service), ProxyRPCStrategyResolver(service)], + }) + }), +) + +const abiStore = InMemoryAbiStoreLive.make({ + default: [ + EtherscanV2StrategyResolver({ + apikey: 'YourApiKey', // provide Etherscan V2 API key + }), + ], +}) const decoder = new TransactionDecoder({ getPublicClient: getPublicClient, diff --git a/sandbox/quick-start/src/main.ts b/sandbox/quick-start/src/main.ts index 8ce588b..db17695 100644 --- a/sandbox/quick-start/src/main.ts +++ b/sandbox/quick-start/src/main.ts @@ -11,7 +11,7 @@ const hash = '0xc0bd04d7e94542e58709f51879f64946ff4a744e1c37f5f920cea3d478e115d7 appElement.innerHTML = `
- Decoded Transaction ${hash} + Decoded Transaction (don't forget to set your Etherscan API key) ${hash}
${await main({ hash }).catch((err) => {
       console.error('Failed to decode transaction:', err)
       return 'Error decoding transaction'