@aave/client 4.0.0-next.1 → 4.0.0-next.11
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/README.md +6 -3
- package/dist/AaveClient-CgHY2iS9.d.ts +82 -0
- package/dist/AaveClient-L3v8kWvn.d.cts +82 -0
- package/dist/actions/index.cjs +2 -0
- package/dist/actions/index.cjs.map +1 -0
- package/dist/actions/index.d.cts +1081 -0
- package/dist/actions/index.d.ts +1081 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/chunk-HH3XCL5T.js +2 -0
- package/dist/chunk-HH3XCL5T.js.map +1 -0
- package/dist/chunk-SRVGACO7.js +3 -0
- package/dist/chunk-SRVGACO7.js.map +1 -0
- package/dist/ethers.cjs +2 -0
- package/dist/ethers.cjs.map +1 -0
- package/dist/ethers.d.cts +38 -0
- package/dist/ethers.d.ts +38 -0
- package/dist/ethers.js +2 -0
- package/dist/ethers.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/options-BX6n3sbh.d.cts +51 -0
- package/dist/options-BX6n3sbh.d.ts +51 -0
- package/dist/privy.cjs +3 -0
- package/dist/privy.cjs.map +1 -0
- package/dist/privy.d.cts +30 -0
- package/dist/privy.d.ts +30 -0
- package/dist/privy.js +2 -0
- package/dist/privy.js.map +1 -0
- package/dist/testing.d.ts +190 -0
- package/dist/testing.js +546 -0
- package/dist/testing.js.map +1 -0
- package/dist/thirdweb.cjs +3 -0
- package/dist/thirdweb.cjs.map +1 -0
- package/dist/thirdweb.d.cts +40 -0
- package/dist/thirdweb.d.ts +40 -0
- package/dist/thirdweb.js +3 -0
- package/dist/thirdweb.js.map +1 -0
- package/dist/types-Bu63z0x6.d.cts +21 -0
- package/dist/types-Bu63z0x6.d.ts +21 -0
- package/dist/utils/index.cjs +2 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +18 -0
- package/dist/utils/index.d.ts +18 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/viem.cjs +3 -0
- package/dist/viem.cjs.map +1 -0
- package/dist/viem.d.cts +61 -0
- package/dist/viem.d.ts +61 -0
- package/dist/viem.js +2 -0
- package/dist/viem.js.map +1 -0
- package/package.json +11 -12
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var core=require('@aave/core'),types=require('@aave/types'),thirdweb=require('thirdweb'),chains=require('thirdweb/chains'),graphql=require('@aave/graphql');var m={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function h(n,e,{batch:t}=m){return n.query(graphql.ChainQuery,{request:e},{batch:t})}var T=thirdweb.defineChain({id:Number.parseInt("123456789",10),name:"Devnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://virtual.mainnet-aave.us-east.rpc.tenderly.co/dbaa58ab-597b-4bcd-ae6a-b8e50f716146"]}},blockExplorers:{default:{name:"Devnet Explorer",url:"https://dashboard.tenderly.co/explorer/vnet/dbaa58ab-597b-4bcd-ae6a-b8e50f716146/"}}}),P={[types.chainId(T.id)]:T};function q(n){switch(n.chainId){case types.chainId(chains.mainnet.id):return chains.mainnet;case types.chainId(chains.sepolia.id):return chains.sepolia}return thirdweb.defineChain({id:n.chainId,name:n.name,nativeCurrency:{name:n.nativeInfo.name,symbol:n.nativeInfo.symbol,decimals:n.nativeInfo.decimals},rpcUrls:{default:{http:[n.rpcUrl]}},blockExplorers:{default:{name:`${n.name} Explorer`,url:n.explorerUrl}}})}function I(n,e){switch(e){case types.chainId(chains.mainnet.id):return types.okAsync(chains.mainnet);case types.chainId(chains.sepolia.id):return types.okAsync(chains.sepolia)}return h(n,{chainId:e},{batch:false}).andThen(t=>(types.invariant(t,`Chain ${e} is not supported`),types.okAsync(q(t))))}async function U(n,e,t){let a=await thirdweb.Engine.serverWallet({client:n,chain:e,address:t.from}).sendTransaction({type:"eip1559",chainId:e.id,to:t.to,value:BigInt(t.value),data:t.data});return types.txHash(a.transactionHash)}function d(n,e,t){return I(n,t.chainId).andThen(r=>types.ResultAsync.fromPromise(U(e,r,t),a=>core.SigningError.from(a)).map(async a=>thirdweb.waitForReceipt({client:e,chain:r,transactionHash:a})).andThen(a=>{let o=types.txHash(a.transactionHash);return a.status==="reverted"?types.errAsync(core.TransactionError.new({txHash:o,request:t})):types.okAsync({txHash:o,operations:t.operations})}))}function C(n,e,t){switch(t.__typename){case "TransactionRequest":return d(n,e,t);case "Erc20ApprovalRequired":case "PreContractActionRequired":return d(n,e,t.transaction).andThen(()=>d(n,e,t.originalTransaction));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}function V(n,e,t){return t?C(n,e,t):C.bind(null,n,e)}async function W(n,e){let r=await thirdweb.Engine.serverWallet({client:n,chain:P[e.domain.chainId],address:e.message.owner}).signTypedData({types:e.types,domain:e.domain,primaryType:e.primaryType,message:e.message});return types.signatureFrom(r)}function O(n,e){return types.ResultAsync.fromPromise(W(n,e),t=>core.SigningError.from(t)).map(t=>({deadline:e.message.deadline,value:t}))}function X(n){return O.bind(null,n)}function E(n,e){let t=JSON.parse(e.message),r=async()=>{let o=await thirdweb.Engine.serverWallet({client:n,chain:P[e.domain.chainId],address:t.user}).signTypedData({types:e.types,domain:e.domain,primaryType:e.primaryType,message:t});return types.signatureFrom(o)};return types.ResultAsync.fromPromise(r(),a=>core.SigningError.from(a)).map(a=>({deadline:t.deadline,value:a}))}function j(n,e){return e?E(n,e):E.bind(null,n)}
|
|
2
|
+
exports.sendWith=V;exports.signERC20PermitWith=X;exports.signSwapTypedDataWith=j;exports.supportedChains=P;exports.toThirdwebChain=q;//# sourceMappingURL=thirdweb.cjs.map
|
|
3
|
+
//# sourceMappingURL=thirdweb.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/options.ts","../src/actions/misc.ts","../src/thirdweb.ts"],"names":["DEFAULT_QUERY_OPTIONS","Currency","TimeWindow","chain","client","request","batch","ChainQuery","devnetChain","defineChain","supportedChains","chainId","toThirdwebChain","mainnet","sepolia","fetchThirdwebChain","id","okAsync","invariant","sendTransaction","thirdwebClient","txResponse","Engine","txHash","sendTransactionAndWait","aaveClient","ResultAsync","err","SigningError","hash","waitForReceipt","receipt","errAsync","TransactionError","executePlan","result","ValidationError","sendWith","signTypedData","signature","signatureFrom","signERC20Permit","value","signERC20PermitWith","signSwapTypedData","message","signTypedDataPromise","signSwapTypedDataWith"],"mappings":"yKA+CO,IAAMA,CAAAA,CAAwB,CACnC,QAAA,CAAUC,gBAAAA,CAAS,GAAA,CACnB,UAAA,CAAYC,mBAAW,OAAA,CACvB,aAAA,CAAe,mBAAA,CACf,KAAA,CAAO,IACT,CAAA,CCTO,SAASC,CAAAA,CACdC,CAAAA,CACAC,EACA,CAAE,KAAA,CAAAC,CAAM,CAAA,CAAkBN,CAAAA,CACkB,CAC5C,OAAOI,CAAAA,CAAO,KAAA,CAAMG,kBAAAA,CAAY,CAAE,OAAA,CAAAF,CAAQ,CAAA,CAAG,CAAE,MAAAC,CAAM,CAAC,CACxD,KCNME,CAAAA,CAA6BC,oBAAAA,CAAY,CAC7C,EAAA,CAAI,OAAO,QAAA,CAAS,WAAA,CAA2C,EAAE,CAAA,CACjE,KAAM,QAAA,CACN,cAAA,CAAgB,CAAE,IAAA,CAAM,QAAS,MAAA,CAAQ,KAAA,CAAO,QAAA,CAAU,EAAG,EAC7D,OAAA,CAAS,CACP,OAAA,CAAS,CAAE,KAAM,CAAC,2FAA4C,CAAE,CAClE,EACA,cAAA,CAAgB,CACd,OAAA,CAAS,CACP,KAAM,iBAAA,CACN,GAAA,CAAK,mFACP,CACF,CACF,CAAC,CAAA,CAKYC,CAAAA,CAAkD,CAI7D,CAACC,aAAAA,CAAQH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xC,CAAM,CACzC","file":"thirdweb.cjs","sourcesContent":["import { Currency, TimeWindow } from '@aave/graphql';\nimport type { RequestPolicy } from '@urql/core';\n\nexport type CurrencyQueryOptions = {\n /**\n * The currency for fiat amounts.\n *\n * @defaultValue {@link Currency.Usd}\n */\n currency?: Currency;\n};\n\nexport type TimeWindowQueryOptions = {\n /**\n * The time window for historical data changes.\n *\n * @defaultValue {@link TimeWindow.LastDay}\n */\n timeWindow?: TimeWindow;\n};\n\n/**\n * @internal\n */\nexport type RequestPolicyOptions = {\n /**\n * The request policy to use.\n *\n * @internal This is used for testing purposes and could be changed without notice.\n * @defaultValue `cache-and-network`\n */\n requestPolicy?: RequestPolicy;\n};\n\n/**\n * @internal\n */\nexport type BatchOptions = {\n /**\n * Whether to batch the query or not.\n *\n * @internal This is used to turn off batching for a single query.\n * @defaultValue `true`\n */\n batch?: boolean;\n};\n\nexport const DEFAULT_QUERY_OPTIONS = {\n currency: Currency.Usd,\n timeWindow: TimeWindow.LastDay,\n requestPolicy: 'cache-and-network',\n batch: true,\n} as const;\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Chain,\n ChainQuery,\n type ChainRequest,\n ChainsQuery,\n type ChainsRequest,\n type ExchangeAmount,\n ExchangeRateQuery,\n type ExchangeRateRequest,\n HasProcessedKnownTransactionQuery,\n type HasProcessedKnownTransactionRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { type BatchOptions, DEFAULT_QUERY_OPTIONS } from '../options';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @returns The chain data, or null if not found.\n */\n\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n): ResultAsync<Chain | null, UnexpectedError>;\n/**\n * @internal\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n options: BatchOptions,\n): ResultAsync<Chain | null, UnexpectedError>;\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n { batch }: BatchOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request }, { batch });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { filter: ChainsFilter.ALL }\n * });\n * ```\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { chainIds: [chainId(1), chainId(137)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chains request parameters.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n request: ChainsRequest,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { request });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n): ResultAsync<ExchangeAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request });\n}\n","import {\n SigningError,\n TransactionError,\n type UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n CancelSwapTypedData,\n Chain,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapByIntentTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport {\n type ChainId,\n chainId,\n errAsync,\n invariant,\n okAsync,\n ResultAsync,\n type Signature,\n signatureFrom,\n type TxHash,\n txHash,\n} from '@aave/types';\nimport {\n defineChain,\n Engine,\n type Chain as ThirdwebChain,\n type ThirdwebClient,\n waitForReceipt,\n} from 'thirdweb';\nimport { mainnet, sepolia } from 'thirdweb/chains';\nimport type { AaveClient } from './AaveClient';\nimport { chain as fetchChain } from './actions';\nimport type {\n ERC20PermitHandler,\n ExecutionPlanHandler,\n SwapSignatureHandler,\n TransactionResult,\n} from './types';\n\nconst devnetChain: ThirdwebChain = defineChain({\n id: Number.parseInt(import.meta.env.ETHEREUM_TENDERLY_FORK_ID, 10),\n name: 'Devnet',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: {\n default: { http: [import.meta.env.ETHEREUM_TENDERLY_PUBLIC_RPC] },\n },\n blockExplorers: {\n default: {\n name: 'Devnet Explorer',\n url: import.meta.env.ETHEREUM_TENDERLY_BLOCKEXPLORER,\n },\n },\n});\n\n/**\n * @internal\n */\nexport const supportedChains: Record<ChainId, ThirdwebChain> = {\n // TODO add them back when deployed on these chains\n // [chainId(mainnet.id)]: mainnet,\n // [chainId(sepolia.id)]: sepolia,\n [chainId(devnetChain.id)]: devnetChain,\n};\n\n/**\n * @internal\n */\nexport function toThirdwebChain(chain: Chain): ThirdwebChain {\n // known chains\n switch (chain.chainId) {\n case chainId(mainnet.id):\n return mainnet;\n\n case chainId(sepolia.id):\n return sepolia;\n }\n\n // most likely a tenderly fork\n return defineChain({\n id: chain.chainId,\n name: chain.name,\n nativeCurrency: {\n name: chain.nativeInfo.name,\n symbol: chain.nativeInfo.symbol,\n decimals: chain.nativeInfo.decimals,\n },\n rpcUrls: { default: { http: [chain.rpcUrl] } },\n blockExplorers: {\n default: {\n name: `${chain.name} Explorer`,\n url: chain.explorerUrl,\n },\n },\n });\n}\n\nfunction fetchThirdwebChain(\n client: AaveClient,\n id: ChainId,\n): ResultAsync<ThirdwebChain, UnexpectedError> {\n switch (id) {\n case chainId(mainnet.id):\n return okAsync(mainnet);\n case chainId(sepolia.id):\n return okAsync(sepolia);\n }\n\n return fetchChain(client, { chainId: id }, { batch: false }).andThen(\n (chain) => {\n invariant(chain, `Chain ${id} is not supported`);\n return okAsync(toThirdwebChain(chain));\n },\n );\n}\n\nasync function sendTransaction(\n thirdwebClient: ThirdwebClient,\n chain: ThirdwebChain,\n request: TransactionRequest,\n): Promise<TxHash> {\n const wallet = Engine.serverWallet({\n client: thirdwebClient,\n chain,\n address: request.from,\n });\n\n const txResponse = await wallet.sendTransaction({\n type: 'eip1559',\n chainId: chain.id,\n to: request.to,\n value: BigInt(request.value),\n data: request.data,\n });\n return txHash(txResponse.transactionHash);\n}\n\nfunction sendTransactionAndWait(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n request: TransactionRequest,\n): ResultAsync<\n TransactionResult,\n SigningError | TransactionError | UnexpectedError\n> {\n return fetchThirdwebChain(aaveClient, request.chainId).andThen((chain) => {\n return ResultAsync.fromPromise(\n sendTransaction(thirdwebClient, chain, request),\n (err) => SigningError.from(err),\n )\n .map(async (hash) =>\n waitForReceipt({\n client: thirdwebClient,\n chain,\n transactionHash: hash,\n }),\n )\n .andThen((receipt) => {\n const hash = txHash(receipt.transactionHash);\n\n if (receipt.status === 'reverted') {\n return errAsync(\n TransactionError.new({\n txHash: hash,\n request,\n }),\n );\n }\n return okAsync({\n txHash: hash,\n operations: request.operations,\n });\n });\n });\n}\n\nfunction executePlan(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n result: ExecutionPlan,\n): ReturnType<ExecutionPlanHandler> {\n switch (result.__typename) {\n case 'TransactionRequest':\n return sendTransactionAndWait(aaveClient, thirdwebClient, result);\n\n case 'Erc20ApprovalRequired':\n case 'PreContractActionRequired':\n return sendTransactionAndWait(\n aaveClient,\n thirdwebClient,\n result.transaction,\n ).andThen(() =>\n sendTransactionAndWait(\n aaveClient,\n thirdwebClient,\n result.originalTransaction,\n ),\n );\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(result));\n }\n}\n\n/**\n * Creates an execution plan handler that sends transactions using the provided Thirdweb client and account.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n): ExecutionPlanHandler<T>;\n/**\n * Sends execution plan transactions using the provided Thirdweb client.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n result: T,\n): ReturnType<ExecutionPlanHandler<T>>;\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n result?: T,\n): ExecutionPlanHandler<T> | ReturnType<ExecutionPlanHandler<T>> {\n return result\n ? executePlan(aaveClient, thirdwebClient, result)\n : executePlan.bind(null, aaveClient, thirdwebClient);\n}\n\nasync function signTypedData(\n client: ThirdwebClient,\n result: PermitTypedDataResponse,\n): Promise<Signature> {\n const wallet = Engine.serverWallet({\n client,\n chain: supportedChains[result.domain.chainId],\n address: result.message.owner,\n });\n\n const signature = await wallet.signTypedData({\n // silence the rest of the type inference\n types: result.types as Record<string, unknown>,\n domain: result.domain,\n primaryType: result.primaryType,\n message: result.message,\n });\n\n return signatureFrom(signature);\n}\n\nfunction signERC20Permit(\n client: ThirdwebClient,\n result: PermitTypedDataResponse,\n): ReturnType<ERC20PermitHandler> {\n return ResultAsync.fromPromise(signTypedData(client, result), (err) =>\n SigningError.from(err),\n ).map((value) => ({\n deadline: result.message.deadline,\n value,\n }));\n}\n\n/**\n * Creates an ERC20 permit handler that signs ERC20 permits using the provided Thirdweb client and account.\n */\nexport function signERC20PermitWith(\n client: ThirdwebClient,\n): ERC20PermitHandler {\n return signERC20Permit.bind(null, client);\n}\n\nfunction signSwapTypedData(\n client: ThirdwebClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler> {\n const message = JSON.parse(result.message);\n\n const signTypedDataPromise = async (): Promise<Signature> => {\n const wallet = Engine.serverWallet({\n client,\n chain: supportedChains[result.domain.chainId],\n address: message.user,\n });\n\n const signature = await wallet.signTypedData({\n // silence the rest of the type inference\n types: result.types as Record<string, unknown>,\n domain: result.domain,\n primaryType: result.primaryType,\n message,\n });\n\n return signatureFrom(signature);\n };\n\n return ResultAsync.fromPromise(signTypedDataPromise(), (err) =>\n SigningError.from(err),\n ).map((value) => ({\n deadline: message.deadline,\n value,\n }));\n}\n\n/**\n * @internal\n * Creates a swap signature handler that signs swap typed data using the provided Thirdweb client.\n */\nexport function signSwapTypedDataWith(\n client: ThirdwebClient,\n): SwapSignatureHandler;\n/**\n * @internal\n * Signs swap typed data using the provided Thirdweb client.\n */\nexport function signSwapTypedDataWith(\n client: ThirdwebClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler>;\nexport function signSwapTypedDataWith(\n client: ThirdwebClient,\n result?: SwapByIntentTypedData | CancelSwapTypedData,\n): SwapSignatureHandler | ReturnType<SwapSignatureHandler> {\n return result\n ? signSwapTypedData(client, result)\n : signSwapTypedData.bind(null, client);\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Chain as Chain$1, ExecutionPlan, SwapByIntentTypedData, CancelSwapTypedData } from '@aave/graphql';
|
|
2
|
+
import { ChainId } from '@aave/types';
|
|
3
|
+
import { Chain, ThirdwebClient } from 'thirdweb';
|
|
4
|
+
import { A as AaveClient } from './AaveClient-L3v8kWvn.cjs';
|
|
5
|
+
import { E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-Bu63z0x6.cjs';
|
|
6
|
+
import '@aave/core';
|
|
7
|
+
import '@urql/core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
declare const supportedChains: Record<ChainId, Chain>;
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
declare function toThirdwebChain(chain: Chain$1): Chain;
|
|
17
|
+
/**
|
|
18
|
+
* Creates an execution plan handler that sends transactions using the provided Thirdweb client and account.
|
|
19
|
+
*/
|
|
20
|
+
declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(aaveClient: AaveClient, thirdwebClient: ThirdwebClient): ExecutionPlanHandler<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Sends execution plan transactions using the provided Thirdweb client.
|
|
23
|
+
*/
|
|
24
|
+
declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(aaveClient: AaveClient, thirdwebClient: ThirdwebClient, result: T): ReturnType<ExecutionPlanHandler<T>>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates an ERC20 permit handler that signs ERC20 permits using the provided Thirdweb client and account.
|
|
27
|
+
*/
|
|
28
|
+
declare function signERC20PermitWith(client: ThirdwebClient): ERC20PermitHandler;
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
* Creates a swap signature handler that signs swap typed data using the provided Thirdweb client.
|
|
32
|
+
*/
|
|
33
|
+
declare function signSwapTypedDataWith(client: ThirdwebClient): SwapSignatureHandler;
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
* Signs swap typed data using the provided Thirdweb client.
|
|
37
|
+
*/
|
|
38
|
+
declare function signSwapTypedDataWith(client: ThirdwebClient, result: SwapByIntentTypedData | CancelSwapTypedData): ReturnType<SwapSignatureHandler>;
|
|
39
|
+
|
|
40
|
+
export { sendWith, signERC20PermitWith, signSwapTypedDataWith, supportedChains, toThirdwebChain };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Chain as Chain$1, ExecutionPlan, SwapByIntentTypedData, CancelSwapTypedData } from '@aave/graphql';
|
|
2
|
+
import { ChainId } from '@aave/types';
|
|
3
|
+
import { Chain, ThirdwebClient } from 'thirdweb';
|
|
4
|
+
import { A as AaveClient } from './AaveClient-CgHY2iS9.js';
|
|
5
|
+
import { E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-Bu63z0x6.js';
|
|
6
|
+
import '@aave/core';
|
|
7
|
+
import '@urql/core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
declare const supportedChains: Record<ChainId, Chain>;
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
declare function toThirdwebChain(chain: Chain$1): Chain;
|
|
17
|
+
/**
|
|
18
|
+
* Creates an execution plan handler that sends transactions using the provided Thirdweb client and account.
|
|
19
|
+
*/
|
|
20
|
+
declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(aaveClient: AaveClient, thirdwebClient: ThirdwebClient): ExecutionPlanHandler<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Sends execution plan transactions using the provided Thirdweb client.
|
|
23
|
+
*/
|
|
24
|
+
declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(aaveClient: AaveClient, thirdwebClient: ThirdwebClient, result: T): ReturnType<ExecutionPlanHandler<T>>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates an ERC20 permit handler that signs ERC20 permits using the provided Thirdweb client and account.
|
|
27
|
+
*/
|
|
28
|
+
declare function signERC20PermitWith(client: ThirdwebClient): ERC20PermitHandler;
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
* Creates a swap signature handler that signs swap typed data using the provided Thirdweb client.
|
|
32
|
+
*/
|
|
33
|
+
declare function signSwapTypedDataWith(client: ThirdwebClient): SwapSignatureHandler;
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
* Signs swap typed data using the provided Thirdweb client.
|
|
37
|
+
*/
|
|
38
|
+
declare function signSwapTypedDataWith(client: ThirdwebClient, result: SwapByIntentTypedData | CancelSwapTypedData): ReturnType<SwapSignatureHandler>;
|
|
39
|
+
|
|
40
|
+
export { sendWith, signERC20PermitWith, signSwapTypedDataWith, supportedChains, toThirdwebChain };
|
package/dist/thirdweb.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {f}from'./chunk-HH3XCL5T.js';import {ValidationError,SigningError,TransactionError}from'@aave/core';import {chainId,errAsync,ResultAsync,txHash,okAsync,signatureFrom,invariant}from'@aave/types';import {defineChain,waitForReceipt,Engine}from'thirdweb';import {sepolia,mainnet}from'thirdweb/chains';var h=defineChain({id:Number.parseInt("123456789",10),name:"Devnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://virtual.mainnet-aave.us-east.rpc.tenderly.co/dbaa58ab-597b-4bcd-ae6a-b8e50f716146"]}},blockExplorers:{default:{name:"Devnet Explorer",url:"https://dashboard.tenderly.co/explorer/vnet/dbaa58ab-597b-4bcd-ae6a-b8e50f716146/"}}}),R={[chainId(h.id)]:h};function v(n){switch(n.chainId){case chainId(mainnet.id):return mainnet;case chainId(sepolia.id):return sepolia}return defineChain({id:n.chainId,name:n.name,nativeCurrency:{name:n.nativeInfo.name,symbol:n.nativeInfo.symbol,decimals:n.nativeInfo.decimals},rpcUrls:{default:{http:[n.rpcUrl]}},blockExplorers:{default:{name:`${n.name} Explorer`,url:n.explorerUrl}}})}function H(n,e){switch(e){case chainId(mainnet.id):return okAsync(mainnet);case chainId(sepolia.id):return okAsync(sepolia)}return f(n,{chainId:e},{batch:false}).andThen(a=>(invariant(a,`Chain ${e} is not supported`),okAsync(v(a))))}async function D(n,e,a){let t=await Engine.serverWallet({client:n,chain:e,address:a.from}).sendTransaction({type:"eip1559",chainId:e.id,to:a.to,value:BigInt(a.value),data:a.data});return txHash(t.transactionHash)}function c(n,e,a){return H(n,a.chainId).andThen(r=>ResultAsync.fromPromise(D(e,r,a),t=>SigningError.from(t)).map(async t=>waitForReceipt({client:e,chain:r,transactionHash:t})).andThen(t=>{let o=txHash(t.transactionHash);return t.status==="reverted"?errAsync(TransactionError.new({txHash:o,request:a})):okAsync({txHash:o,operations:a.operations})}))}function y(n,e,a){switch(a.__typename){case "TransactionRequest":return c(n,e,a);case "Erc20ApprovalRequired":case "PreContractActionRequired":return c(n,e,a.transaction).andThen(()=>c(n,e,a.originalTransaction));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(a))}}function N(n,e,a){return a?y(n,e,a):y.bind(null,n,e)}async function I(n,e){let r=await Engine.serverWallet({client:n,chain:R[e.domain.chainId],address:e.message.owner}).signTypedData({types:e.types,domain:e.domain,primaryType:e.primaryType,message:e.message});return signatureFrom(r)}function A(n,e){return ResultAsync.fromPromise(I(n,e),a=>SigningError.from(a)).map(a=>({deadline:e.message.deadline,value:a}))}function k(n){return A.bind(null,n)}function w(n,e){let a=JSON.parse(e.message),r=async()=>{let o=await Engine.serverWallet({client:n,chain:R[e.domain.chainId],address:a.user}).signTypedData({types:e.types,domain:e.domain,primaryType:e.primaryType,message:a});return signatureFrom(o)};return ResultAsync.fromPromise(r(),t=>SigningError.from(t)).map(t=>({deadline:a.deadline,value:t}))}function O(n,e){return e?w(n,e):w.bind(null,n)}
|
|
2
|
+
export{N as sendWith,k as signERC20PermitWith,O as signSwapTypedDataWith,R as supportedChains,v as toThirdwebChain};//# sourceMappingURL=thirdweb.js.map
|
|
3
|
+
//# sourceMappingURL=thirdweb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/thirdweb.ts"],"names":["devnetChain","defineChain","supportedChains","chainId","toThirdwebChain","chain","mainnet","sepolia","fetchThirdwebChain","client","id","okAsync","invariant","sendTransaction","thirdwebClient","request","txResponse","Engine","txHash","sendTransactionAndWait","aaveClient","ResultAsync","err","SigningError","hash","waitForReceipt","receipt","errAsync","TransactionError","executePlan","result","ValidationError","sendWith","signTypedData","signature","signatureFrom","signERC20Permit","value","signERC20PermitWith","signSwapTypedData","message","signTypedDataPromise","signSwapTypedDataWith"],"mappings":"gTA2CA,IAAMA,CAAAA,CAA6BC,W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AE8B,aAAA,CAAc,CAE3C,KAAA,CAAOV,CAAAA,CAAO,KAAA,CACd,MAAA,CAAQA,CAAAA,CAAO,MAAA,CACf,YAAaA,CAAAA,CAAO,WAAA,CACpB,OAAA,CAAAU,CACF,CAAC,CAAA,CAED,OAAOL,aAAAA,CAAcD,CAAS,CAChC,CAAA,CAEA,OAAOb,WAAAA,CAAY,WAAA,CAAYoB,CAAAA,EAAqB,CAAInB,CAAAA,EACtDC,YAAAA,CAAa,KAAKD,CAAG,CACvB,CAAA,CAAE,GAAA,CAAKe,IAAW,CAChB,QAAA,CAAUG,CAAAA,CAAQ,QAAA,CAClB,MAAAH,CACF,CAAA,CAAE,CACJ,CAiBO,SAASK,CAAAA,CACdjC,CAAAA,CACAqB,CAAAA,CACyD,CACzD,OAAOA,CAAAA,CACHS,CAAAA,CAAkB9B,CAAAA,CAAQqB,CAAM,CAAA,CAChCS,CAAAA,CAAkB,IAAA,CAAK,IAAA,CAAM9B,CAAM,CACzC","file":"thirdweb.js","sourcesContent":["import {\n SigningError,\n TransactionError,\n type UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n CancelSwapTypedData,\n Chain,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapByIntentTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport {\n type ChainId,\n chainId,\n errAsync,\n invariant,\n okAsync,\n ResultAsync,\n type Signature,\n signatureFrom,\n type TxHash,\n txHash,\n} from '@aave/types';\nimport {\n defineChain,\n Engine,\n type Chain as ThirdwebChain,\n type ThirdwebClient,\n waitForReceipt,\n} from 'thirdweb';\nimport { mainnet, sepolia } from 'thirdweb/chains';\nimport type { AaveClient } from './AaveClient';\nimport { chain as fetchChain } from './actions';\nimport type {\n ERC20PermitHandler,\n ExecutionPlanHandler,\n SwapSignatureHandler,\n TransactionResult,\n} from './types';\n\nconst devnetChain: ThirdwebChain = defineChain({\n id: Number.parseInt(import.meta.env.ETHEREUM_TENDERLY_FORK_ID, 10),\n name: 'Devnet',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: {\n default: { http: [import.meta.env.ETHEREUM_TENDERLY_PUBLIC_RPC] },\n },\n blockExplorers: {\n default: {\n name: 'Devnet Explorer',\n url: import.meta.env.ETHEREUM_TENDERLY_BLOCKEXPLORER,\n },\n },\n});\n\n/**\n * @internal\n */\nexport const supportedChains: Record<ChainId, ThirdwebChain> = {\n // TODO add them back when deployed on these chains\n // [chainId(mainnet.id)]: mainnet,\n // [chainId(sepolia.id)]: sepolia,\n [chainId(devnetChain.id)]: devnetChain,\n};\n\n/**\n * @internal\n */\nexport function toThirdwebChain(chain: Chain): ThirdwebChain {\n // known chains\n switch (chain.chainId) {\n case chainId(mainnet.id):\n return mainnet;\n\n case chainId(sepolia.id):\n return sepolia;\n }\n\n // most likely a tenderly fork\n return defineChain({\n id: chain.chainId,\n name: chain.name,\n nativeCurrency: {\n name: chain.nativeInfo.name,\n symbol: chain.nativeInfo.symbol,\n decimals: chain.nativeInfo.decimals,\n },\n rpcUrls: { default: { http: [chain.rpcUrl] } },\n blockExplorers: {\n default: {\n name: `${chain.name} Explorer`,\n url: chain.explorerUrl,\n },\n },\n });\n}\n\nfunction fetchThirdwebChain(\n client: AaveClient,\n id: ChainId,\n): ResultAsync<ThirdwebChain, UnexpectedError> {\n switch (id) {\n case chainId(mainnet.id):\n return okAsync(mainnet);\n case chainId(sepolia.id):\n return okAsync(sepolia);\n }\n\n return fetchChain(client, { chainId: id }, { batch: false }).andThen(\n (chain) => {\n invariant(chain, `Chain ${id} is not supported`);\n return okAsync(toThirdwebChain(chain));\n },\n );\n}\n\nasync function sendTransaction(\n thirdwebClient: ThirdwebClient,\n chain: ThirdwebChain,\n request: TransactionRequest,\n): Promise<TxHash> {\n const wallet = Engine.serverWallet({\n client: thirdwebClient,\n chain,\n address: request.from,\n });\n\n const txResponse = await wallet.sendTransaction({\n type: 'eip1559',\n chainId: chain.id,\n to: request.to,\n value: BigInt(request.value),\n data: request.data,\n });\n return txHash(txResponse.transactionHash);\n}\n\nfunction sendTransactionAndWait(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n request: TransactionRequest,\n): ResultAsync<\n TransactionResult,\n SigningError | TransactionError | UnexpectedError\n> {\n return fetchThirdwebChain(aaveClient, request.chainId).andThen((chain) => {\n return ResultAsync.fromPromise(\n sendTransaction(thirdwebClient, chain, request),\n (err) => SigningError.from(err),\n )\n .map(async (hash) =>\n waitForReceipt({\n client: thirdwebClient,\n chain,\n transactionHash: hash,\n }),\n )\n .andThen((receipt) => {\n const hash = txHash(receipt.transactionHash);\n\n if (receipt.status === 'reverted') {\n return errAsync(\n TransactionError.new({\n txHash: hash,\n request,\n }),\n );\n }\n return okAsync({\n txHash: hash,\n operations: request.operations,\n });\n });\n });\n}\n\nfunction executePlan(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n result: ExecutionPlan,\n): ReturnType<ExecutionPlanHandler> {\n switch (result.__typename) {\n case 'TransactionRequest':\n return sendTransactionAndWait(aaveClient, thirdwebClient, result);\n\n case 'Erc20ApprovalRequired':\n case 'PreContractActionRequired':\n return sendTransactionAndWait(\n aaveClient,\n thirdwebClient,\n result.transaction,\n ).andThen(() =>\n sendTransactionAndWait(\n aaveClient,\n thirdwebClient,\n result.originalTransaction,\n ),\n );\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(result));\n }\n}\n\n/**\n * Creates an execution plan handler that sends transactions using the provided Thirdweb client and account.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n): ExecutionPlanHandler<T>;\n/**\n * Sends execution plan transactions using the provided Thirdweb client.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n result: T,\n): ReturnType<ExecutionPlanHandler<T>>;\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n aaveClient: AaveClient,\n thirdwebClient: ThirdwebClient,\n result?: T,\n): ExecutionPlanHandler<T> | ReturnType<ExecutionPlanHandler<T>> {\n return result\n ? executePlan(aaveClient, thirdwebClient, result)\n : executePlan.bind(null, aaveClient, thirdwebClient);\n}\n\nasync function signTypedData(\n client: ThirdwebClient,\n result: PermitTypedDataResponse,\n): Promise<Signature> {\n const wallet = Engine.serverWallet({\n client,\n chain: supportedChains[result.domain.chainId],\n address: result.message.owner,\n });\n\n const signature = await wallet.signTypedData({\n // silence the rest of the type inference\n types: result.types as Record<string, unknown>,\n domain: result.domain,\n primaryType: result.primaryType,\n message: result.message,\n });\n\n return signatureFrom(signature);\n}\n\nfunction signERC20Permit(\n client: ThirdwebClient,\n result: PermitTypedDataResponse,\n): ReturnType<ERC20PermitHandler> {\n return ResultAsync.fromPromise(signTypedData(client, result), (err) =>\n SigningError.from(err),\n ).map((value) => ({\n deadline: result.message.deadline,\n value,\n }));\n}\n\n/**\n * Creates an ERC20 permit handler that signs ERC20 permits using the provided Thirdweb client and account.\n */\nexport function signERC20PermitWith(\n client: ThirdwebClient,\n): ERC20PermitHandler {\n return signERC20Permit.bind(null, client);\n}\n\nfunction signSwapTypedData(\n client: ThirdwebClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler> {\n const message = JSON.parse(result.message);\n\n const signTypedDataPromise = async (): Promise<Signature> => {\n const wallet = Engine.serverWallet({\n client,\n chain: supportedChains[result.domain.chainId],\n address: message.user,\n });\n\n const signature = await wallet.signTypedData({\n // silence the rest of the type inference\n types: result.types as Record<string, unknown>,\n domain: result.domain,\n primaryType: result.primaryType,\n message,\n });\n\n return signatureFrom(signature);\n };\n\n return ResultAsync.fromPromise(signTypedDataPromise(), (err) =>\n SigningError.from(err),\n ).map((value) => ({\n deadline: message.deadline,\n value,\n }));\n}\n\n/**\n * @internal\n * Creates a swap signature handler that signs swap typed data using the provided Thirdweb client.\n */\nexport function signSwapTypedDataWith(\n client: ThirdwebClient,\n): SwapSignatureHandler;\n/**\n * @internal\n * Signs swap typed data using the provided Thirdweb client.\n */\nexport function signSwapTypedDataWith(\n client: ThirdwebClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler>;\nexport function signSwapTypedDataWith(\n client: ThirdwebClient,\n result?: SwapByIntentTypedData | CancelSwapTypedData,\n): SwapSignatureHandler | ReturnType<SwapSignatureHandler> {\n return result\n ? signSwapTypedData(client, result)\n : signSwapTypedData.bind(null, client);\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CancelError, SigningError, TransactionError, ValidationError, UnexpectedError } from '@aave/core';
|
|
2
|
+
import { OperationType, ExecutionPlan, InsufficientBalanceError, PermitTypedDataResponse, ERC20PermitSignature, CancelSwapTypedData, SwapByIntentTypedData, HasProcessedKnownTransactionRequest } from '@aave/graphql';
|
|
3
|
+
import { TxHash, ResultAsync } from '@aave/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
type TransactionResult = {
|
|
9
|
+
txHash: TxHash;
|
|
10
|
+
operations: OperationType[] | null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
declare function isHasProcessedKnownTransactionRequest(result: TransactionResult): result is HasProcessedKnownTransactionRequest;
|
|
16
|
+
type SendWithError = CancelError | SigningError | TransactionError | ValidationError<InsufficientBalanceError> | UnexpectedError;
|
|
17
|
+
type ExecutionPlanHandler<T extends ExecutionPlan = ExecutionPlan> = (result: T) => ResultAsync<TransactionResult, SendWithError>;
|
|
18
|
+
type ERC20PermitHandler = (result: PermitTypedDataResponse) => ResultAsync<ERC20PermitSignature, SigningError>;
|
|
19
|
+
type SwapSignatureHandler = (result: CancelSwapTypedData | SwapByIntentTypedData) => ResultAsync<ERC20PermitSignature, SigningError>;
|
|
20
|
+
|
|
21
|
+
export { type ExecutionPlanHandler as E, type SwapSignatureHandler as S, type TransactionResult as T, type ERC20PermitHandler as a, type SendWithError as b, isHasProcessedKnownTransactionRequest as i };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CancelError, SigningError, TransactionError, ValidationError, UnexpectedError } from '@aave/core';
|
|
2
|
+
import { OperationType, ExecutionPlan, InsufficientBalanceError, PermitTypedDataResponse, ERC20PermitSignature, CancelSwapTypedData, SwapByIntentTypedData, HasProcessedKnownTransactionRequest } from '@aave/graphql';
|
|
3
|
+
import { TxHash, ResultAsync } from '@aave/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
type TransactionResult = {
|
|
9
|
+
txHash: TxHash;
|
|
10
|
+
operations: OperationType[] | null;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
declare function isHasProcessedKnownTransactionRequest(result: TransactionResult): result is HasProcessedKnownTransactionRequest;
|
|
16
|
+
type SendWithError = CancelError | SigningError | TransactionError | ValidationError<InsufficientBalanceError> | UnexpectedError;
|
|
17
|
+
type ExecutionPlanHandler<T extends ExecutionPlan = ExecutionPlan> = (result: T) => ResultAsync<TransactionResult, SendWithError>;
|
|
18
|
+
type ERC20PermitHandler = (result: PermitTypedDataResponse) => ResultAsync<ERC20PermitSignature, SigningError>;
|
|
19
|
+
type SwapSignatureHandler = (result: CancelSwapTypedData | SwapByIntentTypedData) => ResultAsync<ERC20PermitSignature, SigningError>;
|
|
20
|
+
|
|
21
|
+
export { type ExecutionPlanHandler as E, type SwapSignatureHandler as S, type TransactionResult as T, type ERC20PermitHandler as a, type SendWithError as b, isHasProcessedKnownTransactionRequest as i };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var types=require('@aave/types');function o(r){return types.isNonEmptyArray(r)?r.reduce((u,e)=>e.summary.supplyApy.value.gt(u.summary.supplyApy.value)?e:u,r[0]):null}function l(r){return types.isNonEmptyArray(r)?r.reduce((u,e)=>e.summary.borrowApy.value.lt(u.summary.borrowApy.value)?e:u,r[0]):null}exports.pickHighestSupplyApyReserve=o;exports.pickLowestBorrowApyReserve=l;//# sourceMappingURL=index.cjs.map
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/reserves.ts"],"names":["pickHighestSupplyApyReserve","reserves","isNonEmptyArray","max","reserve","pickLowestBorrowApyReserve","min"],"mappings":"8CASO,SAASA,CAAAA,CACdC,CAAAA,CACgB,CAChB,OAAKC,qBAAAA,CAAgBD,CAAQ,CAAA,CAItBA,CAAAA,CAAS,MAAA,CAAO,CAACE,CAAAA,CAAKC,CAAAA,GACpBA,CAAAA,CAAQ,OAAA,CAAQ,SAAA,CAAU,KAAA,CAAM,EAAA,CAAGD,CAAAA,CAAI,OAAA,CAAQ,SAAA,CAAU,KAAK,CAAA,CACjEC,CAAAA,CACAD,CAAAA,CACHF,EAAS,CAAC,CAAC,CAAA,CAPL,IAQX,CAQO,SAASI,CAAAA,CACdJ,CAAAA,CACgB,CAChB,OAAKC,qBAAAA,CAAgBD,CAAQ,CAAA,CAItBA,CAAAA,CAAS,MAAA,CAAO,CAACK,EAAKF,CAAAA,GACpBA,CAAAA,CAAQ,OAAA,CAAQ,SAAA,CAAU,KAAA,CAAM,EAAA,CAAGE,CAAAA,CAAI,OAAA,CAAQ,SAAA,CAAU,KAAK,CAAA,CACjEF,CAAAA,CACAE,CAAAA,CACHL,CAAAA,CAAS,CAAC,CAAC,EAPL,IAQX","file":"index.cjs","sourcesContent":["import type { Reserve } from '@aave/graphql';\nimport { isNonEmptyArray } from '@aave/types';\n\n/**\n * Picks the highest supply APY reserve from the given reserves.\n *\n * @param reserves - The reserves to pick the highest supply apy reserve from.\n * @returns The highest supply APY reserve or null if not found.\n */\nexport function pickHighestSupplyApyReserve(\n reserves: Reserve[],\n): Reserve | null {\n if (!isNonEmptyArray(reserves)) {\n return null;\n }\n\n return reserves.reduce((max, reserve) => {\n return reserve.summary.supplyApy.value.gt(max.summary.supplyApy.value)\n ? reserve\n : max;\n }, reserves[0]);\n}\n\n/**\n * Picks the lowest borrow APY reserve from the given reserves.\n *\n * @param reserves - The reserves to pick the lowest borrow apy reserve from.\n * @returns The lowest borrow APY reserve or null if not found.\n */\nexport function pickLowestBorrowApyReserve(\n reserves: Reserve[],\n): Reserve | null {\n if (!isNonEmptyArray(reserves)) {\n return null;\n }\n\n return reserves.reduce((min, reserve) => {\n return reserve.summary.borrowApy.value.lt(min.summary.borrowApy.value)\n ? reserve\n : min;\n }, reserves[0]);\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Reserve } from '@aave/graphql';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Picks the highest supply APY reserve from the given reserves.
|
|
5
|
+
*
|
|
6
|
+
* @param reserves - The reserves to pick the highest supply apy reserve from.
|
|
7
|
+
* @returns The highest supply APY reserve or null if not found.
|
|
8
|
+
*/
|
|
9
|
+
declare function pickHighestSupplyApyReserve(reserves: Reserve[]): Reserve | null;
|
|
10
|
+
/**
|
|
11
|
+
* Picks the lowest borrow APY reserve from the given reserves.
|
|
12
|
+
*
|
|
13
|
+
* @param reserves - The reserves to pick the lowest borrow apy reserve from.
|
|
14
|
+
* @returns The lowest borrow APY reserve or null if not found.
|
|
15
|
+
*/
|
|
16
|
+
declare function pickLowestBorrowApyReserve(reserves: Reserve[]): Reserve | null;
|
|
17
|
+
|
|
18
|
+
export { pickHighestSupplyApyReserve, pickLowestBorrowApyReserve };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Reserve } from '@aave/graphql';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Picks the highest supply APY reserve from the given reserves.
|
|
5
|
+
*
|
|
6
|
+
* @param reserves - The reserves to pick the highest supply apy reserve from.
|
|
7
|
+
* @returns The highest supply APY reserve or null if not found.
|
|
8
|
+
*/
|
|
9
|
+
declare function pickHighestSupplyApyReserve(reserves: Reserve[]): Reserve | null;
|
|
10
|
+
/**
|
|
11
|
+
* Picks the lowest borrow APY reserve from the given reserves.
|
|
12
|
+
*
|
|
13
|
+
* @param reserves - The reserves to pick the lowest borrow apy reserve from.
|
|
14
|
+
* @returns The lowest borrow APY reserve or null if not found.
|
|
15
|
+
*/
|
|
16
|
+
declare function pickLowestBorrowApyReserve(reserves: Reserve[]): Reserve | null;
|
|
17
|
+
|
|
18
|
+
export { pickHighestSupplyApyReserve, pickLowestBorrowApyReserve };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {isNonEmptyArray}from'@aave/types';function o(r){return isNonEmptyArray(r)?r.reduce((u,e)=>e.summary.supplyApy.value.gt(u.summary.supplyApy.value)?e:u,r[0]):null}function l(r){return isNonEmptyArray(r)?r.reduce((u,e)=>e.summary.borrowApy.value.lt(u.summary.borrowApy.value)?e:u,r[0]):null}export{o as pickHighestSupplyApyReserve,l as pickLowestBorrowApyReserve};//# sourceMappingURL=index.js.map
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/reserves.ts"],"names":["pickHighestSupplyApyReserve","reserves","isNonEmptyArray","max","reserve","pickLowestBorrowApyReserve","min"],"mappings":"0CASO,SAASA,CAAAA,CACdC,CAAAA,CACgB,CAChB,OAAKC,eAAAA,CAAgBD,CAAQ,CAAA,CAItBA,CAAAA,CAAS,MAAA,CAAO,CAACE,CAAAA,CAAKC,CAAAA,GACpBA,CAAAA,CAAQ,OAAA,CAAQ,SAAA,CAAU,KAAA,CAAM,EAAA,CAAGD,CAAAA,CAAI,OAAA,CAAQ,SAAA,CAAU,KAAK,CAAA,CACjEC,CAAAA,CACAD,CAAAA,CACHF,EAAS,CAAC,CAAC,CAAA,CAPL,IAQX,CAQO,SAASI,CAAAA,CACdJ,CAAAA,CACgB,CAChB,OAAKC,eAAAA,CAAgBD,CAAQ,CAAA,CAItBA,CAAAA,CAAS,MAAA,CAAO,CAACK,EAAKF,CAAAA,GACpBA,CAAAA,CAAQ,OAAA,CAAQ,SAAA,CAAU,KAAA,CAAM,EAAA,CAAGE,CAAAA,CAAI,OAAA,CAAQ,SAAA,CAAU,KAAK,CAAA,CACjEF,CAAAA,CACAE,CAAAA,CACHL,CAAAA,CAAS,CAAC,CAAC,EAPL,IAQX","file":"index.js","sourcesContent":["import type { Reserve } from '@aave/graphql';\nimport { isNonEmptyArray } from '@aave/types';\n\n/**\n * Picks the highest supply APY reserve from the given reserves.\n *\n * @param reserves - The reserves to pick the highest supply apy reserve from.\n * @returns The highest supply APY reserve or null if not found.\n */\nexport function pickHighestSupplyApyReserve(\n reserves: Reserve[],\n): Reserve | null {\n if (!isNonEmptyArray(reserves)) {\n return null;\n }\n\n return reserves.reduce((max, reserve) => {\n return reserve.summary.supplyApy.value.gt(max.summary.supplyApy.value)\n ? reserve\n : max;\n }, reserves[0]);\n}\n\n/**\n * Picks the lowest borrow APY reserve from the given reserves.\n *\n * @param reserves - The reserves to pick the lowest borrow apy reserve from.\n * @returns The lowest borrow APY reserve or null if not found.\n */\nexport function pickLowestBorrowApyReserve(\n reserves: Reserve[],\n): Reserve | null {\n if (!isNonEmptyArray(reserves)) {\n return null;\n }\n\n return reserves.reduce((min, reserve) => {\n return reserve.summary.borrowApy.value.lt(min.summary.borrowApy.value)\n ? reserve\n : min;\n }, reserves[0]);\n}\n"]}
|
package/dist/viem.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var core=require('@aave/core'),types=require('@aave/types'),viem=require('viem'),actions=require('viem/actions'),chains=require('viem/chains'),graphql=require('@aave/graphql');var h={currency:graphql.Currency.Usd,timeWindow:graphql.TimeWindow.LastDay,requestPolicy:"cache-and-network",batch:true};function E(e,n,{batch:t}=h){return e.query(graphql.ChainQuery,{request:n},{batch:t})}function m(e){return types.isObject(e)&&"code"in e&&"message"in e}function N(e){return types.isObject(e)&&"name"in e&&"message"in e&&"originalError"in e?m(e.originalError)&&"code"in e.originalError:true}var R=viem.defineChain({id:Number.parseInt("123456789",10),name:"Devnet",network:"ethereum-fork",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://virtual.mainnet-aave.us-east.rpc.tenderly.co/dbaa58ab-597b-4bcd-ae6a-b8e50f716146"]}},blockExplorers:{default:{name:"Devnet Explorer",url:"https://dashboard.tenderly.co/explorer/vnet/dbaa58ab-597b-4bcd-ae6a-b8e50f716146/"}}}),pe={[types.chainId(R.id)]:R};function w(e){switch(e.chainId){case types.chainId(chains.mainnet.id):return chains.mainnet;case types.chainId(chains.sepolia.id):return chains.sepolia}return viem.defineChain({id:e.chainId,name:e.name,nativeCurrency:{name:e.nativeInfo.name,symbol:e.nativeInfo.symbol,decimals:e.nativeInfo.decimals},rpcUrls:{default:{http:[e.rpcUrl]}},blockExplorers:{default:{name:`${e.name} Explorer`,url:e.explorerUrl}}})}function le(e){return e.map(w)}function de(e,n,t){return types.ResultAsync.fromPromise(n.getChainId(),r=>core.SigningError.from(r)).andThen(r=>r===t.chainId?types.okAsync():E(e,{chainId:t.chainId},{batch:false}).andThen(a=>(types.invariant(a,`Chain ${t.chainId} is not supported`),types.ResultAsync.fromPromise(n.switchChain({id:t.chainId}),i=>core.SigningError.from(i)).orElse(i=>(m(i.cause)?i.cause.code:N(i.cause)?i.cause.data?.originalError?.code:void 0)===viem.SwitchChainError.code?types.ResultAsync.fromPromise(n.addChain({chain:w(a)}),s=>m(s)&&s.code===viem.UserRejectedRequestError.code?core.CancelError.from(s):core.SigningError.from(s)):i.asResultAsync()))))}function Q(e,n){return types.ResultAsync.fromPromise(actions.estimateGas(e,{account:e.account,data:n.data,to:n.to,value:BigInt(n.value)}),t=>core.SigningError.from(t)).map(t=>t*115n/100n)}function F(e,n){return Q(e,n).andThen(t=>types.ResultAsync.fromPromise(actions.sendTransaction(e,{account:e.account,data:n.data,to:n.to,value:BigInt(n.value),chain:e.chain,gas:t}),r=>{if(r instanceof viem.TransactionExecutionError){let a=r.walk(i=>i instanceof viem.UserRejectedRequestError);if(a)return core.CancelError.from(a)}return core.SigningError.from(r)})).map(types.txHash)}function K(e){return e.account!==void 0}function Y(e,n){return types.invariant(K(e),"Wallet client with account is required"),F(e,n)}function G(e,n,t){let r=e?.blockExplorers?.default?.url,a=r&&new URL(`/tx/${n}`,r).toString();return core.TransactionError.new({txHash:n,request:t,link:a})}function $(e,n,t){return types.ResultAsync.fromPromise(actions.waitForTransactionReceipt(e,{hash:t,pollingInterval:100,retryCount:20,retryDelay:50}),r=>core.UnexpectedError.from(r)).andThen(r=>{let a=types.txHash(r.transactionHash);switch(r.status){case "reverted":return t!==a?types.errAsync(core.CancelError.from(`Transaction replaced by ${a}`)):types.errAsync(G(e.chain,a,n));case "success":return types.okAsync({txHash:a,operations:n.operations})}})}function p(e,n){return Y(e,n).andThen(t=>$(e,n,t))}function C(e,n){switch(n.__typename){case "TransactionRequest":return p(e,n);case "Erc20ApprovalRequired":case "PreContractActionRequired":return p(e,n.transaction).andThen(()=>p(e,n.originalTransaction));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(n))}}function me(e,n){return n?C(e,n):C.bind(null,e)}function j(e,n){return types.invariant(e.account,"Wallet account is required"),types.ResultAsync.fromPromise(actions.signTypedData(e,{account:e.account,domain:n.domain,types:n.types,primaryType:n.primaryType,message:n.message}),t=>core.SigningError.from(t)).map(t=>({deadline:n.message.deadline,value:types.signatureFrom(t)}))}function ye(e){return j.bind(null,e)}function x(e,n){return types.invariant(e.account,"Wallet account is required"),types.ResultAsync.fromPromise(actions.signTypedData(e,{account:e.account,domain:n.domain,types:n.types,primaryType:n.primaryType,message:JSON.parse(n.message)}),t=>core.SigningError.from(t)).map(t=>({deadline:JSON.parse(n.message).deadline,value:types.signatureFrom(t)}))}function he(e,n){return n?x(e,n):x.bind(null,e)}
|
|
2
|
+
exports.ensureChain=de;exports.sendTransaction=Y;exports.sendWith=me;exports.signERC20PermitWith=ye;exports.signSwapTypedDataWith=he;exports.supportedChains=pe;exports.toViemChain=w;exports.transactionError=G;exports.viemChainsFrom=le;exports.waitForTransactionResult=$;//# sourceMappingURL=viem.cjs.map
|
|
3
|
+
//# sourceMappingURL=viem.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/options.ts","../src/actions/misc.ts","../src/viem.ts"],"names":["DEFAULT_QUERY_OPTIONS","Currency","TimeWindow","chain","client","request","batch","ChainQuery","isRpcError","err","isObject","isProviderRpcError","devnetChain","defineChain","supportedChains","chainId","toViemChain","mainnet","sepolia","viemChainsFrom","chains","ensureChain","aaveClient","walletClient","ResultAsync","SigningError","okAsync","invariant","SwitchChainError","UserRejectedRequestError","CancelError","estimateGas","estimateGasWithViem","gas","sendEip1559Transaction","sendTransactionWithViem","TransactionExecutionError","rejected","txHash","isWalletClientWithAccount","sendTransaction","transactionError","baseUrl","link","TransactionError","waitForTransactionResult","initialTxHash","waitForTransactionReceipt","UnexpectedError","receipt","hash","errAsync","sendTransactionAndWait","executePlan","result","ValidationError","sendWith","signERC20Permit","signTypedData","hex","signatureFrom","signERC20PermitWith","signSwapTypedData","signSwapTypedDataWith"],"mappings":"6LA+CO,IAAMA,CAAAA,CAAwB,CACnC,QAAA,CAAUC,iBAAS,GAAA,CACnB,UAAA,CAAYC,kBAAAA,CAAW,OAAA,CACvB,aAAA,CAAe,mBAAA,CACf,MAAO,IACT,CAAA,CCTO,SAASC,EACdC,CAAAA,CACAC,CAAAA,CACA,CAAE,KAAA,CAAAC,CAAM,CAAA,CAAkBN,EACkB,CAC5C,OAAOI,CAAAA,CAAO,KAAA,CAAMG,kBAAAA,CAAY,CAAE,QAAAF,CAAQ,CAAA,CAAG,CAAE,KAAA,CAAAC,CAAM,CAAC,CACxD,CCQA,SAASE,EAAWC,CAAAA,CAA+B,CACjD,OAAOC,cAAAA,CAASD,CAAG,CAAA,EAAK,MAAA,GAAUA,CAA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,CACd,QAAA,CAAU,IAAA,CAAK,KAAA,CAAML,EAAO,OAAO,CAAA,CAAE,QAAA,CACrC,KAAA,CAAOM,mBAAAA,CAAcD,CAAG,CAC1B,CAAA,CAAE,CACJ,CAiBO,SAASI,EAAAA,CACdxC,CAAAA,CACA+B,EACyD,CACzD,OAAOA,CAAAA,CACHQ,CAAAA,CAAkBvC,CAAAA,CAAc+B,CAAM,EACtCQ,CAAAA,CAAkB,IAAA,CAAK,IAAA,CAAMvC,CAAY,CAC/C","file":"viem.cjs","sourcesContent":["import { Currency, TimeWindow } from '@aave/graphql';\nimport type { RequestPolicy } from '@urql/core';\n\nexport type CurrencyQueryOptions = {\n /**\n * The currency for fiat amounts.\n *\n * @defaultValue {@link Currency.Usd}\n */\n currency?: Currency;\n};\n\nexport type TimeWindowQueryOptions = {\n /**\n * The time window for historical data changes.\n *\n * @defaultValue {@link TimeWindow.LastDay}\n */\n timeWindow?: TimeWindow;\n};\n\n/**\n * @internal\n */\nexport type RequestPolicyOptions = {\n /**\n * The request policy to use.\n *\n * @internal This is used for testing purposes and could be changed without notice.\n * @defaultValue `cache-and-network`\n */\n requestPolicy?: RequestPolicy;\n};\n\n/**\n * @internal\n */\nexport type BatchOptions = {\n /**\n * Whether to batch the query or not.\n *\n * @internal This is used to turn off batching for a single query.\n * @defaultValue `true`\n */\n batch?: boolean;\n};\n\nexport const DEFAULT_QUERY_OPTIONS = {\n currency: Currency.Usd,\n timeWindow: TimeWindow.LastDay,\n requestPolicy: 'cache-and-network',\n batch: true,\n} as const;\n","import type { UnexpectedError } from '@aave/core';\nimport {\n type Chain,\n ChainQuery,\n type ChainRequest,\n ChainsQuery,\n type ChainsRequest,\n type ExchangeAmount,\n ExchangeRateQuery,\n type ExchangeRateRequest,\n HasProcessedKnownTransactionQuery,\n type HasProcessedKnownTransactionRequest,\n} from '@aave/graphql';\nimport type { ResultAsync } from '@aave/types';\nimport type { AaveClient } from '../AaveClient';\nimport { type BatchOptions, DEFAULT_QUERY_OPTIONS } from '../options';\n\n/**\n * Fetches a specific chain by chain ID.\n *\n * ```ts\n * const result = await chain(client, {\n * chainId: chainId(1),\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chain request parameters.\n * @returns The chain data, or null if not found.\n */\n\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n): ResultAsync<Chain | null, UnexpectedError>;\n/**\n * @internal\n */\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n options: BatchOptions,\n): ResultAsync<Chain | null, UnexpectedError>;\nexport function chain(\n client: AaveClient,\n request: ChainRequest,\n { batch }: BatchOptions = DEFAULT_QUERY_OPTIONS,\n): ResultAsync<Chain | null, UnexpectedError> {\n return client.query(ChainQuery, { request }, { batch });\n}\n\n/**\n * Fetches the list of supported chains.\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { filter: ChainsFilter.ALL }\n * });\n * ```\n *\n * ```ts\n * const chains = await chains(client, {\n * query: { chainIds: [chainId(1), chainId(137)] }\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The chains request parameters.\n * @returns Array of supported chains.\n */\nexport function chains(\n client: AaveClient,\n request: ChainsRequest,\n): ResultAsync<Chain[], UnexpectedError> {\n return client.query(ChainsQuery, { request });\n}\n\n/**\n * Check if a transaction has been processed by the Aave API.\n *\n * @param client - Aave client.\n * @param request - The request containing transaction hash and operations to check.\n * @returns True if the transaction has been processed, false otherwise.\n */\nexport function hasProcessedKnownTransaction(\n client: AaveClient,\n request: HasProcessedKnownTransactionRequest,\n): ResultAsync<boolean, UnexpectedError> {\n return client.query(\n HasProcessedKnownTransactionQuery,\n { request },\n {\n requestPolicy: 'network-only', // alwats hit the network\n batch: false, // never batch, always run ASAP\n },\n );\n}\n\n/**\n * Fetches the exchange rate between tokens and fiat currencies.\n *\n * ```ts\n * const result = await exchangeRate(client, {\n * from: { erc20: { chainId: chainId(1), address: evmAddress('0xA0b86a33E6...') } },\n * to: Currency.Usd,\n * });\n * ```\n *\n * @param client - Aave client.\n * @param request - The exchange rate request parameters.\n * @returns The exchange rate information as a fiat amount.\n */\nexport function exchangeRate(\n client: AaveClient,\n request: ExchangeRateRequest,\n): ResultAsync<ExchangeAmount, UnexpectedError> {\n return client.query(ExchangeRateQuery, { request });\n}\n","import {\n CancelError,\n SigningError,\n TransactionError,\n UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n CancelSwapTypedData,\n Chain,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapByIntentTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport {\n type ChainId,\n chainId,\n errAsync,\n invariant,\n isObject,\n okAsync,\n ResultAsync,\n signatureFrom,\n type TxHash,\n txHash,\n} from '@aave/types';\nimport {\n type Account,\n defineChain,\n type ProviderRpcError,\n type RpcError,\n SwitchChainError,\n TransactionExecutionError,\n type Transport,\n type TypedData,\n type TypedDataDomain,\n UserRejectedRequestError,\n type Chain as ViemChain,\n type WalletClient,\n} from 'viem';\nimport {\n estimateGas as estimateGasWithViem,\n sendTransaction as sendTransactionWithViem,\n signTypedData,\n waitForTransactionReceipt,\n} from 'viem/actions';\nimport { mainnet, sepolia } from 'viem/chains';\nimport type { AaveClient } from './AaveClient';\nimport { chain as fetchChain } from './actions';\nimport type {\n ERC20PermitHandler,\n ExecutionPlanHandler,\n SwapSignatureHandler,\n TransactionResult,\n} from './types';\n\nfunction isRpcError(err: unknown): err is RpcError {\n return isObject(err) && 'code' in err && 'message' in err;\n}\n\nfunction isProviderRpcError(\n err: unknown,\n): err is ProviderRpcError<{ originalError?: { code: number } }> {\n return isObject(err) &&\n 'name' in err &&\n 'message' in err &&\n 'originalError' in err\n ? isRpcError(err.originalError) && 'code' in err.originalError\n : true;\n}\n\nconst devnetChain: ViemChain = defineChain({\n id: Number.parseInt(import.meta.env.ETHEREUM_TENDERLY_FORK_ID, 10),\n name: 'Devnet',\n network: 'ethereum-fork',\n nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },\n rpcUrls: {\n default: { http: [import.meta.env.ETHEREUM_TENDERLY_PUBLIC_RPC] },\n },\n blockExplorers: {\n default: {\n name: 'Devnet Explorer',\n url: import.meta.env.ETHEREUM_TENDERLY_BLOCKEXPLORER,\n },\n },\n});\n\n/**\n * @internal\n * @deprecated\n */\nexport const supportedChains: Record<ChainId, ViemChain> = {\n [chainId(devnetChain.id)]: devnetChain,\n};\n\n/**\n * @internal\n */\nexport function toViemChain(chain: Chain): ViemChain {\n // known chains\n switch (chain.chainId) {\n case chainId(mainnet.id):\n return mainnet;\n\n case chainId(sepolia.id):\n return sepolia;\n }\n\n // most likely a tenderly fork\n return defineChain({\n id: chain.chainId,\n name: chain.name,\n nativeCurrency: {\n name: chain.nativeInfo.name,\n symbol: chain.nativeInfo.symbol,\n decimals: chain.nativeInfo.decimals,\n },\n rpcUrls: { default: { http: [chain.rpcUrl] } },\n blockExplorers: {\n default: {\n name: `${chain.name} Explorer`,\n url: chain.explorerUrl,\n },\n },\n });\n}\n\n/**\n * @internal\n */\nexport function viemChainsFrom(chains: Chain[]): ViemChain[] {\n return chains.map(toViemChain);\n}\n\n/**\n * @internal\n */\nexport function ensureChain(\n aaveClient: AaveClient,\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<void, CancelError | SigningError | UnexpectedError> {\n return ResultAsync.fromPromise(walletClient.getChainId(), (err) =>\n SigningError.from(err),\n ).andThen((chainId) => {\n if (chainId === request.chainId) {\n return okAsync();\n }\n\n return fetchChain(\n aaveClient,\n { chainId: request.chainId },\n { batch: false },\n ).andThen((chain) => {\n invariant(chain, `Chain ${request.chainId} is not supported`);\n\n return ResultAsync.fromPromise(\n walletClient.switchChain({ id: request.chainId }),\n (err) => SigningError.from(err),\n ).orElse((err) => {\n const code = isRpcError(err.cause)\n ? err.cause.code\n : // Unwrapping for MetaMask Mobile\n // https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719\n isProviderRpcError(err.cause)\n ? err.cause.data?.originalError?.code\n : undefined;\n\n if (code === SwitchChainError.code) {\n return ResultAsync.fromPromise(\n walletClient.addChain({ chain: toViemChain(chain) }),\n (err) => {\n if (\n isRpcError(err) &&\n err.code === UserRejectedRequestError.code\n ) {\n return CancelError.from(err);\n }\n return SigningError.from(err);\n },\n );\n }\n\n return err.asResultAsync();\n });\n });\n });\n}\n\nfunction estimateGas(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<bigint, SigningError> {\n return ResultAsync.fromPromise(\n estimateGasWithViem(walletClient, {\n account: walletClient.account,\n data: request.data,\n to: request.to,\n value: BigInt(request.value),\n }),\n (err) => SigningError.from(err),\n ).map((gas) => (gas * 115n) / 100n); // 15% buffer\n}\n\nfunction sendEip1559Transaction(\n walletClient: WalletClient<Transport, ViemChain, Account>,\n request: TransactionRequest,\n): ResultAsync<TxHash, CancelError | SigningError> {\n return estimateGas(walletClient, request)\n .andThen((gas) =>\n ResultAsync.fromPromise(\n sendTransactionWithViem(walletClient, {\n account: walletClient.account,\n data: request.data,\n to: request.to,\n value: BigInt(request.value),\n chain: walletClient.chain,\n gas,\n }),\n (err) => {\n if (err instanceof TransactionExecutionError) {\n const rejected = err.walk(\n (err) => err instanceof UserRejectedRequestError,\n );\n\n if (rejected) {\n return CancelError.from(rejected);\n }\n }\n return SigningError.from(err);\n },\n ),\n )\n .map(txHash);\n}\n\nfunction isWalletClientWithAccount(\n walletClient: WalletClient,\n): walletClient is WalletClient<Transport, ViemChain, Account> {\n return walletClient.account !== undefined;\n}\n\n/**\n * @internal\n */\nexport function sendTransaction(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<TxHash, CancelError | SigningError> {\n invariant(\n isWalletClientWithAccount(walletClient),\n 'Wallet client with account is required',\n );\n\n return sendEip1559Transaction(walletClient, request);\n}\n\n/**\n * @internal\n */\nexport function transactionError(\n chain: ViemChain | undefined,\n txHash: TxHash,\n request: TransactionRequest,\n): TransactionError {\n const baseUrl = chain?.blockExplorers?.default?.url;\n const link = baseUrl && new URL(`/tx/${txHash}`, baseUrl).toString();\n\n return TransactionError.new({ txHash, request, link });\n}\n\n/**\n * @internal\n */\nexport function waitForTransactionResult(\n walletClient: WalletClient,\n request: TransactionRequest,\n initialTxHash: TxHash,\n): ResultAsync<\n TransactionResult,\n CancelError | TransactionError | UnexpectedError\n> {\n return ResultAsync.fromPromise(\n waitForTransactionReceipt(walletClient, {\n hash: initialTxHash,\n pollingInterval: 100,\n retryCount: 20,\n retryDelay: 50,\n }),\n (err) => UnexpectedError.from(err),\n ).andThen((receipt) => {\n const hash = txHash(receipt.transactionHash);\n\n switch (receipt.status) {\n case 'reverted':\n if (initialTxHash !== hash) {\n return errAsync(CancelError.from(`Transaction replaced by ${hash}`));\n }\n return errAsync(transactionError(walletClient.chain, hash, request));\n case 'success':\n return okAsync({\n // viem's waitForTransactionReceipt supports transaction replacement\n // so it's important to use the transaction hash from the receipt\n txHash: hash,\n operations: request.operations,\n });\n }\n });\n}\n\nfunction sendTransactionAndWait(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<\n TransactionResult,\n CancelError | SigningError | TransactionError | UnexpectedError\n> {\n return sendTransaction(walletClient, request).andThen((hash) =>\n waitForTransactionResult(walletClient, request, hash),\n );\n}\n\nfunction executePlan(\n walletClient: WalletClient,\n result: ExecutionPlan,\n): ReturnType<ExecutionPlanHandler> {\n switch (result.__typename) {\n case 'TransactionRequest':\n return sendTransactionAndWait(walletClient, result);\n\n case 'Erc20ApprovalRequired':\n case 'PreContractActionRequired':\n return sendTransactionAndWait(walletClient, result.transaction).andThen(\n () => sendTransactionAndWait(walletClient, result.originalTransaction),\n );\n\n case 'InsufficientBalanceError':\n return errAsync(ValidationError.fromGqlNode(result));\n }\n}\n\n/**\n * Creates an execution plan handler that sends transactions using the provided wallet client.\n */\nexport function sendWith(walletClient: WalletClient): ExecutionPlanHandler;\n/**\n * Sends execution plan transactions using the provided wallet client.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n walletClient: WalletClient,\n result: T,\n): ReturnType<ExecutionPlanHandler<T>>;\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n walletClient: WalletClient,\n result?: T,\n): ExecutionPlanHandler<T> | ReturnType<ExecutionPlanHandler<T>> {\n return result\n ? executePlan(walletClient, result)\n : executePlan.bind(null, walletClient);\n}\n\nfunction signERC20Permit(\n walletClient: WalletClient,\n result: PermitTypedDataResponse,\n): ReturnType<ERC20PermitHandler> {\n invariant(walletClient.account, 'Wallet account is required');\n\n return ResultAsync.fromPromise(\n signTypedData(walletClient, {\n account: walletClient.account,\n domain: result.domain as TypedDataDomain,\n types: result.types as TypedData,\n primaryType: result.primaryType as keyof typeof result.types,\n message: result.message,\n }),\n (err) => SigningError.from(err),\n ).map((hex) => ({\n deadline: result.message.deadline,\n value: signatureFrom(hex),\n }));\n}\n\n/**\n * Creates an ERC20 permit handler that signs ERC20 permits using the provided wallet client.\n */\nexport function signERC20PermitWith(\n walletClient: WalletClient,\n): ERC20PermitHandler {\n return signERC20Permit.bind(null, walletClient);\n}\n\nfunction signSwapTypedData(\n walletClient: WalletClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler> {\n invariant(walletClient.account, 'Wallet account is required');\n\n return ResultAsync.fromPromise(\n signTypedData(walletClient, {\n account: walletClient.account,\n domain: result.domain as TypedDataDomain,\n types: result.types as TypedData,\n primaryType: result.primaryType,\n message: JSON.parse(result.message),\n }),\n (err) => SigningError.from(err),\n ).map((hex) => ({\n deadline: JSON.parse(result.message).deadline,\n value: signatureFrom(hex),\n }));\n}\n\n/**\n * @internal\n * Creates a swap signature handler that signs swap typed data using the provided wallet client.\n */\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n): SwapSignatureHandler;\n/**\n * @internal\n * Signs swap typed data using the provided wallet client.\n */\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n result: SwapByIntentTypedData | CancelSwapTypedData,\n): ReturnType<SwapSignatureHandler>;\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n result?: SwapByIntentTypedData | CancelSwapTypedData,\n): SwapSignatureHandler | ReturnType<SwapSignatureHandler> {\n return result\n ? signSwapTypedData(walletClient, result)\n : signSwapTypedData.bind(null, walletClient);\n}\n"]}
|
package/dist/viem.d.cts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CancelError, SigningError, UnexpectedError, TransactionError } from '@aave/core';
|
|
2
|
+
import { Chain as Chain$1, TransactionRequest, ExecutionPlan, SwapByIntentTypedData, CancelSwapTypedData } from '@aave/graphql';
|
|
3
|
+
import { ChainId, ResultAsync, TxHash } from '@aave/types';
|
|
4
|
+
import { Chain, WalletClient } from 'viem';
|
|
5
|
+
import { A as AaveClient } from './AaveClient-L3v8kWvn.cjs';
|
|
6
|
+
import { T as TransactionResult, E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-Bu63z0x6.cjs';
|
|
7
|
+
import '@urql/core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
13
|
+
declare const supportedChains: Record<ChainId, Chain>;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
declare function toViemChain(chain: Chain$1): Chain;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
declare function viemChainsFrom(chains: Chain$1[]): Chain[];
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
declare function ensureChain(aaveClient: AaveClient, walletClient: WalletClient, request: TransactionRequest): ResultAsync<void, CancelError | SigningError | UnexpectedError>;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
declare function sendTransaction(walletClient: WalletClient, request: TransactionRequest): ResultAsync<TxHash, CancelError | SigningError>;
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
declare function transactionError(chain: Chain | undefined, txHash: TxHash, request: TransactionRequest): TransactionError;
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
declare function waitForTransactionResult(walletClient: WalletClient, request: TransactionRequest, initialTxHash: TxHash): ResultAsync<TransactionResult, CancelError | TransactionError | UnexpectedError>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates an execution plan handler that sends transactions using the provided wallet client.
|
|
40
|
+
*/
|
|
41
|
+
declare function sendWith(walletClient: WalletClient): ExecutionPlanHandler;
|
|
42
|
+
/**
|
|
43
|
+
* Sends execution plan transactions using the provided wallet client.
|
|
44
|
+
*/
|
|
45
|
+
declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(walletClient: WalletClient, result: T): ReturnType<ExecutionPlanHandler<T>>;
|
|
46
|
+
/**
|
|
47
|
+
* Creates an ERC20 permit handler that signs ERC20 permits using the provided wallet client.
|
|
48
|
+
*/
|
|
49
|
+
declare function signERC20PermitWith(walletClient: WalletClient): ERC20PermitHandler;
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
* Creates a swap signature handler that signs swap typed data using the provided wallet client.
|
|
53
|
+
*/
|
|
54
|
+
declare function signSwapTypedDataWith(walletClient: WalletClient): SwapSignatureHandler;
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* Signs swap typed data using the provided wallet client.
|
|
58
|
+
*/
|
|
59
|
+
declare function signSwapTypedDataWith(walletClient: WalletClient, result: SwapByIntentTypedData | CancelSwapTypedData): ReturnType<SwapSignatureHandler>;
|
|
60
|
+
|
|
61
|
+
export { ensureChain, sendTransaction, sendWith, signERC20PermitWith, signSwapTypedDataWith, supportedChains, toViemChain, transactionError, viemChainsFrom, waitForTransactionResult };
|
package/dist/viem.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { CancelError, SigningError, UnexpectedError, TransactionError } from '@aave/core';
|
|
2
|
+
import { Chain as Chain$1, TransactionRequest, ExecutionPlan, SwapByIntentTypedData, CancelSwapTypedData } from '@aave/graphql';
|
|
3
|
+
import { ChainId, ResultAsync, TxHash } from '@aave/types';
|
|
4
|
+
import { Chain, WalletClient } from 'viem';
|
|
5
|
+
import { A as AaveClient } from './AaveClient-CgHY2iS9.js';
|
|
6
|
+
import { T as TransactionResult, E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-Bu63z0x6.js';
|
|
7
|
+
import '@urql/core';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* @deprecated
|
|
12
|
+
*/
|
|
13
|
+
declare const supportedChains: Record<ChainId, Chain>;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
declare function toViemChain(chain: Chain$1): Chain;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
declare function viemChainsFrom(chains: Chain$1[]): Chain[];
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
declare function ensureChain(aaveClient: AaveClient, walletClient: WalletClient, request: TransactionRequest): ResultAsync<void, CancelError | SigningError | UnexpectedError>;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
declare function sendTransaction(walletClient: WalletClient, request: TransactionRequest): ResultAsync<TxHash, CancelError | SigningError>;
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
declare function transactionError(chain: Chain | undefined, txHash: TxHash, request: TransactionRequest): TransactionError;
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
declare function waitForTransactionResult(walletClient: WalletClient, request: TransactionRequest, initialTxHash: TxHash): ResultAsync<TransactionResult, CancelError | TransactionError | UnexpectedError>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates an execution plan handler that sends transactions using the provided wallet client.
|
|
40
|
+
*/
|
|
41
|
+
declare function sendWith(walletClient: WalletClient): ExecutionPlanHandler;
|
|
42
|
+
/**
|
|
43
|
+
* Sends execution plan transactions using the provided wallet client.
|
|
44
|
+
*/
|
|
45
|
+
declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(walletClient: WalletClient, result: T): ReturnType<ExecutionPlanHandler<T>>;
|
|
46
|
+
/**
|
|
47
|
+
* Creates an ERC20 permit handler that signs ERC20 permits using the provided wallet client.
|
|
48
|
+
*/
|
|
49
|
+
declare function signERC20PermitWith(walletClient: WalletClient): ERC20PermitHandler;
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
* Creates a swap signature handler that signs swap typed data using the provided wallet client.
|
|
53
|
+
*/
|
|
54
|
+
declare function signSwapTypedDataWith(walletClient: WalletClient): SwapSignatureHandler;
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
* Signs swap typed data using the provided wallet client.
|
|
58
|
+
*/
|
|
59
|
+
declare function signSwapTypedDataWith(walletClient: WalletClient, result: SwapByIntentTypedData | CancelSwapTypedData): ReturnType<SwapSignatureHandler>;
|
|
60
|
+
|
|
61
|
+
export { ensureChain, sendTransaction, sendWith, signERC20PermitWith, signSwapTypedDataWith, supportedChains, toViemChain, transactionError, viemChainsFrom, waitForTransactionResult };
|
package/dist/viem.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export{d as ensureChain,e as sendTransaction,h as sendWith,i as signERC20PermitWith,j as signSwapTypedDataWith,a as supportedChains,b as toViemChain,f as transactionError,c as viemChainsFrom,g as waitForTransactionResult}from'./chunk-SRVGACO7.js';import'./chunk-HH3XCL5T.js';//# sourceMappingURL=viem.js.map
|
|
2
|
+
//# sourceMappingURL=viem.js.map
|
package/dist/viem.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"viem.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aave/client",
|
|
3
|
-
"version": "4.0.0-next.
|
|
3
|
+
"version": "4.0.0-next.11",
|
|
4
4
|
"description": "The official TypeScript client for the AaveKit API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aave",
|
|
@@ -50,9 +50,8 @@
|
|
|
50
50
|
"import": "./dist/viem.js",
|
|
51
51
|
"require": "./dist/viem.cjs"
|
|
52
52
|
},
|
|
53
|
-
"./
|
|
54
|
-
"
|
|
55
|
-
"require": "./dist/test-utils.cjs"
|
|
53
|
+
"./testing": {
|
|
54
|
+
"default": "./dist/testing.js"
|
|
56
55
|
}
|
|
57
56
|
},
|
|
58
57
|
"typesVersions": {
|
|
@@ -75,8 +74,8 @@
|
|
|
75
74
|
"viem": [
|
|
76
75
|
"./dist/viem.d.ts"
|
|
77
76
|
],
|
|
78
|
-
"
|
|
79
|
-
"./dist/
|
|
77
|
+
"testing": [
|
|
78
|
+
"./dist/testing.d.ts"
|
|
80
79
|
]
|
|
81
80
|
}
|
|
82
81
|
},
|
|
@@ -88,19 +87,19 @@
|
|
|
88
87
|
"@urql/core": "^6.0.1",
|
|
89
88
|
"@urql/exchange-graphcache": "^8.1.0",
|
|
90
89
|
"graphql": "^16.11.0",
|
|
91
|
-
"@aave/
|
|
92
|
-
"@aave/
|
|
93
|
-
"@aave/
|
|
90
|
+
"@aave/types": "1.0.0-next.5",
|
|
91
|
+
"@aave/core": "1.0.0-next.7",
|
|
92
|
+
"@aave/graphql": "1.0.0-next.10"
|
|
94
93
|
},
|
|
95
94
|
"devDependencies": {
|
|
96
95
|
"@bgd-labs/aave-address-book": "^4.25.3",
|
|
97
96
|
"@node-kit/pnpm-workspace-root": "^3.3.1",
|
|
98
|
-
"@privy-io/server-auth": "^1.
|
|
97
|
+
"@privy-io/server-auth": "^1.32.5",
|
|
99
98
|
"dotenv": "^17.2.3",
|
|
100
99
|
"ethers": "^6.14.4",
|
|
101
100
|
"msw": "^2.10.5",
|
|
102
101
|
"thirdweb": "^5.105.25",
|
|
103
|
-
"tsup": "^8.5.
|
|
102
|
+
"tsup": "^8.5.1",
|
|
104
103
|
"typescript": "^5.9.2",
|
|
105
104
|
"viem": "^2.37.5"
|
|
106
105
|
},
|
|
@@ -126,7 +125,7 @@
|
|
|
126
125
|
},
|
|
127
126
|
"license": "MIT",
|
|
128
127
|
"publishConfig": {
|
|
129
|
-
"access": "
|
|
128
|
+
"access": "public"
|
|
130
129
|
},
|
|
131
130
|
"scripts": {
|
|
132
131
|
"build": "tsup"
|