@aave/client 4.0.0-next.2 → 4.0.0-next.21

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.
Files changed (61) hide show
  1. package/README.md +6 -3
  2. package/dist/{AaveClient-L3v8kWvn.d.cts → AaveClient-BIfAdE-4.d.cts} +2 -1
  3. package/dist/{AaveClient-CgHY2iS9.d.ts → AaveClient-C36zcfbL.d.ts} +2 -1
  4. package/dist/actions/index.cjs +1 -1
  5. package/dist/actions/index.cjs.map +1 -1
  6. package/dist/actions/index.d.cts +228 -135
  7. package/dist/actions/index.d.ts +228 -135
  8. package/dist/actions/index.js +1 -1
  9. package/dist/chunk-3HZQC3YV.js +3 -0
  10. package/dist/chunk-3HZQC3YV.js.map +1 -0
  11. package/dist/chunk-MKZBFAXA.js +2 -0
  12. package/dist/chunk-MKZBFAXA.js.map +1 -0
  13. package/dist/ethers.cjs +1 -1
  14. package/dist/ethers.cjs.map +1 -1
  15. package/dist/ethers.d.cts +5 -7
  16. package/dist/ethers.d.ts +5 -7
  17. package/dist/ethers.js +1 -1
  18. package/dist/ethers.js.map +1 -1
  19. package/dist/index.cjs +2 -2
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +3 -3
  22. package/dist/index.d.ts +3 -3
  23. package/dist/index.js +2 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/{options-vB2peXdE.d.cts → options-BX6n3sbh.d.cts} +17 -1
  26. package/dist/{options-vB2peXdE.d.ts → options-BX6n3sbh.d.ts} +17 -1
  27. package/dist/privy.cjs +2 -2
  28. package/dist/privy.cjs.map +1 -1
  29. package/dist/privy.d.cts +3 -5
  30. package/dist/privy.d.ts +3 -5
  31. package/dist/privy.js +1 -1
  32. package/dist/privy.js.map +1 -1
  33. package/dist/testing.d.ts +3840 -0
  34. package/dist/testing.js +546 -0
  35. package/dist/testing.js.map +1 -0
  36. package/dist/thirdweb.cjs +1 -2
  37. package/dist/thirdweb.cjs.map +1 -1
  38. package/dist/thirdweb.d.cts +15 -11
  39. package/dist/thirdweb.d.ts +15 -11
  40. package/dist/thirdweb.js +1 -2
  41. package/dist/thirdweb.js.map +1 -1
  42. package/dist/{types-Bu63z0x6.d.cts → types-CQvue0x0.d.cts} +4 -4
  43. package/dist/{types-Bu63z0x6.d.ts → types-CQvue0x0.d.ts} +4 -4
  44. package/dist/viem.cjs +2 -2
  45. package/dist/viem.cjs.map +1 -1
  46. package/dist/viem.d.cts +23 -10
  47. package/dist/viem.d.ts +23 -10
  48. package/dist/viem.js +1 -1
  49. package/package.json +11 -12
  50. package/dist/chunk-2TNQ52OQ.js +0 -3
  51. package/dist/chunk-2TNQ52OQ.js.map +0 -1
  52. package/dist/chunk-BQFM5RT3.js +0 -2
  53. package/dist/chunk-BQFM5RT3.js.map +0 -1
  54. package/dist/chunk-BQNVAUS6.js +0 -3
  55. package/dist/chunk-BQNVAUS6.js.map +0 -1
  56. package/dist/test-utils.cjs +0 -3
  57. package/dist/test-utils.cjs.map +0 -1
  58. package/dist/test-utils.d.cts +0 -49
  59. package/dist/test-utils.d.ts +0 -49
  60. package/dist/test-utils.js +0 -3
  61. package/dist/test-utils.js.map +0 -1
package/dist/thirdweb.cjs CHANGED
@@ -1,3 +1,2 @@
1
- 'use strict';var core=require('@aave/core'),types=require('@aave/types'),thirdweb=require('thirdweb');async function P(e,n){let a=await e.sendTransaction({type:"eip1559",chainId:n.chainId,to:n.to,value:BigInt(n.value),data:n.data});return types.txHash(a.transactionHash)}function r(e,n){let a=thirdweb.Engine.serverWallet({client:e,address:n.from});return types.ResultAsync.fromPromise(P(a,n),t=>core.SigningError.from(t)).map(async t=>thirdweb.waitForReceipt({client:e,chain:{id:n.chainId,rpc:`https://${n.chainId}.rpc.thirdweb.com/${e.clientId}`},transactionHash:t})).andThen(t=>{let i=types.txHash(t.transactionHash);return t.status==="reverted"?types.errAsync(core.TransactionError.new({txHash:i,request:n})):types.okAsync({txHash:i,operations:n.operations})})}function p(e,n){switch(n.__typename){case "TransactionRequest":return r(e,n);case "Erc20ApprovalRequired":case "PreContractActionRequired":return r(e,n.transaction).andThen(()=>r(e,n.originalTransaction));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(n))}}function H(e,n){return n?p(e,n):p.bind(null,e)}async function S(e,n){let t=await thirdweb.Engine.serverWallet({client:e,chain:thirdweb.defineChain({id:n.domain.chainId}),address:n.message.owner}).signTypedData({types:n.types,domain:n.domain,primaryType:n.primaryType,message:n.message});return types.signatureFrom(t)}function f(e,n){return types.ResultAsync.fromPromise(S(e,n),a=>core.SigningError.from(a)).map(a=>({deadline:n.message.deadline,value:a}))}function D(e){return f.bind(null,e)}function c(e,n){let a=JSON.parse(n.message),t=async()=>{let m=await thirdweb.Engine.serverWallet({client:e,chain:thirdweb.defineChain({id:n.domain.chainId}),address:a.user}).signTypedData({types:n.types,domain:n.domain,primaryType:n.primaryType,message:a});return types.signatureFrom(m)};return types.ResultAsync.fromPromise(t(),i=>core.SigningError.from(i)).map(i=>({deadline:a.deadline,value:i}))}function b(e,n){return n?c(e,n):c.bind(null,e)}
2
- exports.sendWith=H;exports.signERC20PermitWith=D;exports.signSwapTypedDataWith=b;//# sourceMappingURL=thirdweb.cjs.map
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(e,n,{batch:t}=m){return e.query(graphql.ChainQuery,{request:n},{batch:t})}function q(e){switch(e.chainId){case types.chainId(chains.mainnet.id):return chains.mainnet;case types.chainId(chains.sepolia.id):return chains.sepolia}return thirdweb.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 b(e,n){switch(n){case types.chainId(chains.mainnet.id):return types.okAsync(chains.mainnet);case types.chainId(chains.sepolia.id):return types.okAsync(chains.sepolia)}return h(e,{chainId:n},{batch:false}).andThen(t=>(types.invariant(t,`Chain ${n} is not supported`),types.okAsync(q(t))))}async function W(e,n,t){let a=await thirdweb.Engine.serverWallet({client:e,chain:n,address:t.from}).sendTransaction({type:"eip1559",chainId:n.id,to:t.to,value:BigInt(t.value),data:t.data});return types.txHash(a.transactionHash)}function p(e,n,t){return b(e,t.chainId).andThen(r=>types.ResultAsync.fromPromise(W(n,r,t),a=>core.SigningError.from(a)).map(async a=>thirdweb.waitForReceipt({client:n,chain:r,transactionHash:a})).andThen(a=>{let y=types.txHash(a.transactionHash);return a.status==="reverted"?types.errAsync(core.TransactionError.new({txHash:y,request:t})):types.okAsync({txHash:y,operations:t.operations})}))}function T(e,n,t){switch(t.__typename){case "TransactionRequest":return p(e,n,t);case "Erc20ApprovalRequired":case "PreContractActionRequired":return p(e,n,t.transaction).andThen(()=>p(e,n,t.originalTransaction));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(t))}}function G(e,n,t){return t?T(e,n,t):T.bind(null,e,n)}async function D(e,n){let t=await e.signTypedData({types:n.types,domain:n.domain,primaryType:n.primaryType,message:n.message});return types.signatureFrom(t)}function V(e){return function(t){return types.ResultAsync.fromPromise(D(e,t),r=>core.SigningError.from(r)).map(r=>({deadline:t.message.deadline,value:r}))}}function x(e,n){let t=async()=>{let r=await e.signTypedData({types:n.types,domain:n.domain,primaryType:n.primaryType,message:n.message});return types.signatureFrom(r)};return types.ResultAsync.fromPromise(t(),r=>core.SigningError.from(r)).map(types.signatureFrom)}function j(e,n){return n?x(e,n):x.bind(null,e)}exports.sendWith=G;exports.signERC20PermitWith=V;exports.signSwapTypedDataWith=j;exports.toThirdwebChain=q;//# sourceMappingURL=thirdweb.cjs.map
3
2
  //# sourceMappingURL=thirdweb.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/thirdweb.ts"],"names":["sendTransaction","wallet","request","txResponse","txHash","sendTransactionAndWait","client","Engine","ResultAsync","err","SigningError","hash","waitForReceipt","receipt","errAsync","TransactionError","okAsync","executePlan","result","ValidationError","sendWith","signTypedData","signature","defineChain","signatureFrom","signERC20Permit","value","signERC20PermitWith","signSwapTypedData","message","signTypedDataPromise","signSwapTypedDataWith"],"mappings":"sGA8BA,eAAeA,CAAAA,CACbC,EACAC,CAAAA,CACiB,CACjB,IAAMC,CAAAA,CAAa,MAAMF,EAAO,eAAA,CAAgB,CAC9C,KAAM,SAAA,CACN,OAAA,CAASC,EAAQ,OAAA,CACjB,EAAA,CAAIA,CAAAA,CAAQ,EAAA,CACZ,KAAA,CAAO,MAAA,CAAOA,EAAQ,KAAK,CAAA,CAC3B,KAAMA,CAAAA,CAAQ,IAChB,CAAC,CAAA,CACD,OAAOE,aAAOD,CAAAA,CAAW,eAAe,CAC1C,CAEA,SAASE,EACPC,CAAAA,CACAJ,CAAAA,CACiE,CACjE,IAAMD,CAAAA,CAASM,eAAAA,CAAO,YAAA,CAAa,CACjC,MAAA,CAAAD,EACA,OAAA,CAASJ,CAAAA,CAAQ,IACnB,CAAC,CAAA,CAED,OAAOM,iBAAAA,CAAY,WAAA,CAAYR,CAAAA,CAAgBC,CAAAA,CAAQC,CAAO,CAAA,CAAIO,GAChEC,iBAAAA,CAAa,IAAA,CAAKD,CAAG,CACvB,CAAA,CACG,IAAI,MAAOE,CAAAA,EACVC,uBAAAA,CAAe,CACb,MAAA,CAAAN,CAAAA,CACA,MAAO,CACL,EAAA,CAAIJ,EAAQ,OAAA,CACZ,GAAA,CAAK,WAAWA,CAAAA,CAAQ,OAAO,qBAAqBI,CAAAA,CAAO,QAAQ,EACrE,CAAA,CACA,eAAA,CAAiBK,CACnB,CAAC,CACH,EACC,OAAA,CAASE,CAAAA,EAAY,CACpB,IAAMF,CAAAA,CAAOP,YAAAA,CAAOS,EAAQ,eAAe,CAAA,CAE3C,OAAIA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A,CACyD,CACzD,OAAOA,CAAAA,CACHU,EAAkBtB,CAAAA,CAAQY,CAAM,EAChCU,CAAAA,CAAkB,IAAA,CAAK,IAAA,CAAMtB,CAAM,CACzC","file":"thirdweb.cjs","sourcesContent":["import { SigningError, TransactionError, ValidationError } from '@aave/core';\nimport type {\n CancelSwapTypedData,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapByIntentTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport {\n errAsync,\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 ThirdwebClient,\n waitForReceipt,\n} from 'thirdweb';\nimport type {\n ERC20PermitHandler,\n ExecutionPlanHandler,\n SwapSignatureHandler,\n TransactionResult,\n} from './types';\n\nasync function sendTransaction(\n wallet: Engine.ServerWallet,\n request: TransactionRequest,\n): Promise<TxHash> {\n const txResponse = await wallet.sendTransaction({\n type: 'eip1559',\n chainId: request.chainId,\n to: request.to,\n value: BigInt(request.value),\n data: request.data,\n });\n return txHash(txResponse.transactionHash);\n}\n\nfunction sendTransactionAndWait(\n client: ThirdwebClient,\n request: TransactionRequest,\n): ResultAsync<TransactionResult, SigningError | TransactionError> {\n const wallet = Engine.serverWallet({\n client,\n address: request.from,\n });\n\n return ResultAsync.fromPromise(sendTransaction(wallet, request), (err) =>\n SigningError.from(err),\n )\n .map(async (hash) =>\n waitForReceipt({\n client,\n chain: {\n id: request.chainId,\n rpc: `https://${request.chainId}.rpc.thirdweb.com/${client.clientId}`,\n },\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\nfunction executePlan(\n client: ThirdwebClient,\n result: ExecutionPlan,\n): ReturnType<ExecutionPlanHandler> {\n switch (result.__typename) {\n case 'TransactionRequest':\n return sendTransactionAndWait(client, result);\n\n case 'Erc20ApprovalRequired':\n case 'PreContractActionRequired':\n return sendTransactionAndWait(client, result.transaction).andThen(() =>\n sendTransactionAndWait(client, 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 Thirdweb client and account.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n client: ThirdwebClient,\n): ExecutionPlanHandler<T>;\n/**\n * Sends execution plan transactions using the provided Thirdweb client.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n client: ThirdwebClient,\n result: T,\n): ReturnType<ExecutionPlanHandler<T>>;\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n client: ThirdwebClient,\n result?: T,\n): ExecutionPlanHandler<T> | ReturnType<ExecutionPlanHandler<T>> {\n return result ? executePlan(client, result) : executePlan.bind(null, client);\n}\n\nasync function signTypedData(\n client: ThirdwebClient,\n result: PermitTypedDataResponse,\n): Promise<Signature> {\n const wallet = Engine.serverWallet({\n client,\n chain: defineChain({ id: 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: defineChain({ id: 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"]}
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","toThirdwebChain","chainId","mainnet","sepolia","defineChain","fetchThirdwebChain","id","okAsync","invariant","sendTransaction","thirdwebClient","txResponse","Engine","txHash","sendTransactionAndWait","aaveClient","ResultAsync","err","SigningError","hash","waitForReceipt","receipt","errAsync","TransactionError","executePlan","result","ValidationError","sendWith","signTypedData","wallet","signature","signatureFrom","signERC20PermitWith","value","signSwapTypedData","signTypedDataPromise","signSwapTypedDataWith"],"mappings":"yKA+CO,IAAMA,CAAAA,CAAwB,CACnC,SAAUC,gBAAAA,CAAS,GAA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,CAAML,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 Chain,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapTypedData,\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\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 wallet: Engine.ServerWallet,\n result: PermitTypedDataResponse,\n): Promise<Signature> {\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\n/**\n * Creates an ERC20 permit handler that signs ERC20 permits using the provided Thirdweb client and account.\n */\nexport function signERC20PermitWith(\n wallet: Engine.ServerWallet,\n): ERC20PermitHandler {\n return function signERC20Permit(\n result: PermitTypedDataResponse,\n ): ReturnType<ERC20PermitHandler> {\n return ResultAsync.fromPromise(signTypedData(wallet, result), (err) =>\n SigningError.from(err),\n ).map((value) => ({\n deadline: result.message.deadline,\n value,\n }));\n };\n}\n\nfunction signSwapTypedData(\n wallet: Engine.ServerWallet,\n result: SwapTypedData,\n): ReturnType<SwapSignatureHandler> {\n const signTypedDataPromise = async (): Promise<Signature> => {\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\n return ResultAsync.fromPromise(signTypedDataPromise(), (err) =>\n SigningError.from(err),\n ).map(signatureFrom);\n}\n\n/**\n * Creates a swap signature handler that signs swap typed data using the provided Thirdweb client.\n */\nexport function signSwapTypedDataWith(\n wallet: Engine.ServerWallet,\n): SwapSignatureHandler;\n/**\n * Signs swap typed data using the provided Thirdweb client.\n */\nexport function signSwapTypedDataWith(\n wallet: Engine.ServerWallet,\n result: SwapTypedData,\n): ReturnType<SwapSignatureHandler>;\nexport function signSwapTypedDataWith(\n wallet: Engine.ServerWallet,\n result?: SwapTypedData,\n): SwapSignatureHandler | ReturnType<SwapSignatureHandler> {\n return result\n ? signSwapTypedData(wallet, result)\n : signSwapTypedData.bind(null, wallet);\n}\n"]}
@@ -1,30 +1,34 @@
1
- import { ExecutionPlan, SwapByIntentTypedData, CancelSwapTypedData } from '@aave/graphql';
2
- import { ThirdwebClient } from 'thirdweb';
3
- import { E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-Bu63z0x6.cjs';
1
+ import { Chain, ExecutionPlan, SwapTypedData } from '@aave/graphql';
2
+ import { Chain as Chain$1, ThirdwebClient, Engine } from 'thirdweb';
3
+ import { A as AaveClient } from './AaveClient-BIfAdE-4.cjs';
4
+ import { E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-CQvue0x0.cjs';
4
5
  import '@aave/core';
5
6
  import '@aave/types';
7
+ import '@urql/core';
6
8
 
9
+ /**
10
+ * @internal
11
+ */
12
+ declare function toThirdwebChain(chain: Chain): Chain$1;
7
13
  /**
8
14
  * Creates an execution plan handler that sends transactions using the provided Thirdweb client and account.
9
15
  */
10
- declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(client: ThirdwebClient): ExecutionPlanHandler<T>;
16
+ declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(aaveClient: AaveClient, thirdwebClient: ThirdwebClient): ExecutionPlanHandler<T>;
11
17
  /**
12
18
  * Sends execution plan transactions using the provided Thirdweb client.
13
19
  */
14
- declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(client: ThirdwebClient, result: T): ReturnType<ExecutionPlanHandler<T>>;
20
+ declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(aaveClient: AaveClient, thirdwebClient: ThirdwebClient, result: T): ReturnType<ExecutionPlanHandler<T>>;
15
21
  /**
16
22
  * Creates an ERC20 permit handler that signs ERC20 permits using the provided Thirdweb client and account.
17
23
  */
18
- declare function signERC20PermitWith(client: ThirdwebClient): ERC20PermitHandler;
24
+ declare function signERC20PermitWith(wallet: Engine.ServerWallet): ERC20PermitHandler;
19
25
  /**
20
- * @internal
21
26
  * Creates a swap signature handler that signs swap typed data using the provided Thirdweb client.
22
27
  */
23
- declare function signSwapTypedDataWith(client: ThirdwebClient): SwapSignatureHandler;
28
+ declare function signSwapTypedDataWith(wallet: Engine.ServerWallet): SwapSignatureHandler;
24
29
  /**
25
- * @internal
26
30
  * Signs swap typed data using the provided Thirdweb client.
27
31
  */
28
- declare function signSwapTypedDataWith(client: ThirdwebClient, result: SwapByIntentTypedData | CancelSwapTypedData): ReturnType<SwapSignatureHandler>;
32
+ declare function signSwapTypedDataWith(wallet: Engine.ServerWallet, result: SwapTypedData): ReturnType<SwapSignatureHandler>;
29
33
 
30
- export { sendWith, signERC20PermitWith, signSwapTypedDataWith };
34
+ export { sendWith, signERC20PermitWith, signSwapTypedDataWith, toThirdwebChain };
@@ -1,30 +1,34 @@
1
- import { ExecutionPlan, SwapByIntentTypedData, CancelSwapTypedData } from '@aave/graphql';
2
- import { ThirdwebClient } from 'thirdweb';
3
- import { E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-Bu63z0x6.js';
1
+ import { Chain, ExecutionPlan, SwapTypedData } from '@aave/graphql';
2
+ import { Chain as Chain$1, ThirdwebClient, Engine } from 'thirdweb';
3
+ import { A as AaveClient } from './AaveClient-C36zcfbL.js';
4
+ import { E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-CQvue0x0.js';
4
5
  import '@aave/core';
5
6
  import '@aave/types';
7
+ import '@urql/core';
6
8
 
9
+ /**
10
+ * @internal
11
+ */
12
+ declare function toThirdwebChain(chain: Chain): Chain$1;
7
13
  /**
8
14
  * Creates an execution plan handler that sends transactions using the provided Thirdweb client and account.
9
15
  */
10
- declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(client: ThirdwebClient): ExecutionPlanHandler<T>;
16
+ declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(aaveClient: AaveClient, thirdwebClient: ThirdwebClient): ExecutionPlanHandler<T>;
11
17
  /**
12
18
  * Sends execution plan transactions using the provided Thirdweb client.
13
19
  */
14
- declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(client: ThirdwebClient, result: T): ReturnType<ExecutionPlanHandler<T>>;
20
+ declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(aaveClient: AaveClient, thirdwebClient: ThirdwebClient, result: T): ReturnType<ExecutionPlanHandler<T>>;
15
21
  /**
16
22
  * Creates an ERC20 permit handler that signs ERC20 permits using the provided Thirdweb client and account.
17
23
  */
18
- declare function signERC20PermitWith(client: ThirdwebClient): ERC20PermitHandler;
24
+ declare function signERC20PermitWith(wallet: Engine.ServerWallet): ERC20PermitHandler;
19
25
  /**
20
- * @internal
21
26
  * Creates a swap signature handler that signs swap typed data using the provided Thirdweb client.
22
27
  */
23
- declare function signSwapTypedDataWith(client: ThirdwebClient): SwapSignatureHandler;
28
+ declare function signSwapTypedDataWith(wallet: Engine.ServerWallet): SwapSignatureHandler;
24
29
  /**
25
- * @internal
26
30
  * Signs swap typed data using the provided Thirdweb client.
27
31
  */
28
- declare function signSwapTypedDataWith(client: ThirdwebClient, result: SwapByIntentTypedData | CancelSwapTypedData): ReturnType<SwapSignatureHandler>;
32
+ declare function signSwapTypedDataWith(wallet: Engine.ServerWallet, result: SwapTypedData): ReturnType<SwapSignatureHandler>;
29
33
 
30
- export { sendWith, signERC20PermitWith, signSwapTypedDataWith };
34
+ export { sendWith, signERC20PermitWith, signSwapTypedDataWith, toThirdwebChain };
package/dist/thirdweb.js CHANGED
@@ -1,3 +1,2 @@
1
- import {ValidationError,SigningError,TransactionError}from'@aave/core';import {errAsync,ResultAsync,txHash,okAsync,signatureFrom}from'@aave/types';import {Engine,waitForReceipt,defineChain}from'thirdweb';async function P(e,n){let a=await e.sendTransaction({type:"eip1559",chainId:n.chainId,to:n.to,value:BigInt(n.value),data:n.data});return txHash(a.transactionHash)}function r(e,n){let a=Engine.serverWallet({client:e,address:n.from});return ResultAsync.fromPromise(P(a,n),t=>SigningError.from(t)).map(async t=>waitForReceipt({client:e,chain:{id:n.chainId,rpc:`https://${n.chainId}.rpc.thirdweb.com/${e.clientId}`},transactionHash:t})).andThen(t=>{let i=txHash(t.transactionHash);return t.status==="reverted"?errAsync(TransactionError.new({txHash:i,request:n})):okAsync({txHash:i,operations:n.operations})})}function p(e,n){switch(n.__typename){case "TransactionRequest":return r(e,n);case "Erc20ApprovalRequired":case "PreContractActionRequired":return r(e,n.transaction).andThen(()=>r(e,n.originalTransaction));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(n))}}function H(e,n){return n?p(e,n):p.bind(null,e)}async function S(e,n){let t=await Engine.serverWallet({client:e,chain:defineChain({id:n.domain.chainId}),address:n.message.owner}).signTypedData({types:n.types,domain:n.domain,primaryType:n.primaryType,message:n.message});return signatureFrom(t)}function f(e,n){return ResultAsync.fromPromise(S(e,n),a=>SigningError.from(a)).map(a=>({deadline:n.message.deadline,value:a}))}function D(e){return f.bind(null,e)}function c(e,n){let a=JSON.parse(n.message),t=async()=>{let m=await Engine.serverWallet({client:e,chain:defineChain({id:n.domain.chainId}),address:a.user}).signTypedData({types:n.types,domain:n.domain,primaryType:n.primaryType,message:a});return signatureFrom(m)};return ResultAsync.fromPromise(t(),i=>SigningError.from(i)).map(i=>({deadline:a.deadline,value:i}))}function b(e,n){return n?c(e,n):c.bind(null,e)}
2
- export{H as sendWith,D as signERC20PermitWith,b as signSwapTypedDataWith};//# sourceMappingURL=thirdweb.js.map
1
+ import {f}from'./chunk-MKZBFAXA.js';import {SigningError,ValidationError,TransactionError}from'@aave/core';import {chainId,ResultAsync,errAsync,signatureFrom,txHash,okAsync,invariant}from'@aave/types';import {defineChain,waitForReceipt,Engine}from'thirdweb';import {sepolia,mainnet}from'thirdweb/chains';function R(e){switch(e.chainId){case chainId(mainnet.id):return mainnet;case chainId(sepolia.id):return sepolia}return 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 v(e,n){switch(n){case chainId(mainnet.id):return okAsync(mainnet);case chainId(sepolia.id):return okAsync(sepolia)}return f(e,{chainId:n},{batch:false}).andThen(a=>(invariant(a,`Chain ${n} is not supported`),okAsync(R(a))))}async function H(e,n,a){let r=await Engine.serverWallet({client:e,chain:n,address:a.from}).sendTransaction({type:"eip1559",chainId:n.id,to:a.to,value:BigInt(a.value),data:a.data});return txHash(r.transactionHash)}function d(e,n,a){return v(e,a.chainId).andThen(t=>ResultAsync.fromPromise(H(n,t,a),r=>SigningError.from(r)).map(async r=>waitForReceipt({client:n,chain:t,transactionHash:r})).andThen(r=>{let m=txHash(r.transactionHash);return r.status==="reverted"?errAsync(TransactionError.new({txHash:m,request:a})):okAsync({txHash:m,operations:a.operations})}))}function y(e,n,a){switch(a.__typename){case "TransactionRequest":return d(e,n,a);case "Erc20ApprovalRequired":case "PreContractActionRequired":return d(e,n,a.transaction).andThen(()=>d(e,n,a.originalTransaction));case "InsufficientBalanceError":return errAsync(ValidationError.fromGqlNode(a))}}function k(e,n,a){return a?y(e,n,a):y.bind(null,e,n)}async function b(e,n){let a=await e.signTypedData({types:n.types,domain:n.domain,primaryType:n.primaryType,message:n.message});return signatureFrom(a)}function q(e){return function(a){return ResultAsync.fromPromise(b(e,a),t=>SigningError.from(t)).map(t=>({deadline:a.message.deadline,value:t}))}}function h(e,n){let a=async()=>{let t=await e.signTypedData({types:n.types,domain:n.domain,primaryType:n.primaryType,message:n.message});return signatureFrom(t)};return ResultAsync.fromPromise(a(),t=>SigningError.from(t)).map(signatureFrom)}function B(e,n){return n?h(e,n):h.bind(null,e)}export{k as sendWith,q as signERC20PermitWith,B as signSwapTypedDataWith,R as toThirdwebChain};//# sourceMappingURL=thirdweb.js.map
3
2
  //# sourceMappingURL=thirdweb.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/thirdweb.ts"],"names":["sendTransaction","wallet","request","txResponse","txHash","sendTransactionAndWait","client","Engine","ResultAsync","err","SigningError","hash","waitForReceipt","receipt","errAsync","TransactionError","okAsync","executePlan","result","ValidationError","sendWith","signTypedData","signature","defineChain","signatureFrom","signERC20Permit","value","signERC20PermitWith","signSwapTypedData","message","signTypedDataPromise","signSwapTypedDataWith"],"mappings":"4MA8BA,eAAeA,CAAAA,CACbC,EACAC,CAAAA,CACiB,CACjB,IAAMC,CAAAA,CAAa,MAAMF,EAAO,eAAA,CAAgB,CAC9C,KAAM,SAAA,CACN,OAAA,CAASC,EAAQ,OAAA,CACjB,EAAA,CAAIA,CAAAA,CAAQ,EAAA,CACZ,KAAA,CAAO,MAAA,CAAOA,EAAQ,KAAK,CAAA,CAC3B,KAAMA,CAAAA,CAAQ,IAChB,CAAC,CAAA,CACD,OAAOE,OAAOD,CAAAA,CAAW,eAAe,CAC1C,CAEA,SAASE,EACPC,CAAAA,CACAJ,CAAAA,CACiE,CACjE,IAAMD,CAAAA,CAASM,MAAAA,CAAO,YAAA,CAAa,CACjC,MAAA,CAAAD,EACA,OAAA,CAASJ,CAAAA,CAAQ,IACnB,CAAC,CAAA,CAED,OAAOM,WAAAA,CAAY,WAAA,CAAYR,CAAAA,CAAgBC,CAAAA,CAAQC,CAAO,CAAA,CAAIO,GAChEC,YAAAA,CAAa,IAAA,CAAKD,CAAG,CACvB,CAAA,CACG,IAAI,MAAOE,CAAAA,EACVC,cAAAA,CAAe,CACb,MAAA,CAAAN,CAAAA,CACA,MAAO,CACL,EAAA,CAAIJ,EAAQ,OAAA,CACZ,GAAA,CAAK,WAAWA,CAAAA,CAAQ,OAAO,qBAAqBI,CAAAA,CAAO,QAAQ,EACrE,CAAA,CACA,eAAA,CAAiBK,CACnB,CAAC,CACH,EACC,OAAA,CAASE,CAAAA,EAAY,CACpB,IAAMF,CAAAA,CAAOP,MAAAA,CAAOS,EAAQ,eAAe,CAAA,CAE3C,OAAIA,CAAAA,CAAQ,MAAA,GAAW,WAC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tB,CAAAA,CAAQY,CAAM,EAChCU,CAAAA,CAAkB,IAAA,CAAK,IAAA,CAAMtB,CAAM,CACzC","file":"thirdweb.js","sourcesContent":["import { SigningError, TransactionError, ValidationError } from '@aave/core';\nimport type {\n CancelSwapTypedData,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapByIntentTypedData,\n TransactionRequest,\n} from '@aave/graphql';\nimport {\n errAsync,\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 ThirdwebClient,\n waitForReceipt,\n} from 'thirdweb';\nimport type {\n ERC20PermitHandler,\n ExecutionPlanHandler,\n SwapSignatureHandler,\n TransactionResult,\n} from './types';\n\nasync function sendTransaction(\n wallet: Engine.ServerWallet,\n request: TransactionRequest,\n): Promise<TxHash> {\n const txResponse = await wallet.sendTransaction({\n type: 'eip1559',\n chainId: request.chainId,\n to: request.to,\n value: BigInt(request.value),\n data: request.data,\n });\n return txHash(txResponse.transactionHash);\n}\n\nfunction sendTransactionAndWait(\n client: ThirdwebClient,\n request: TransactionRequest,\n): ResultAsync<TransactionResult, SigningError | TransactionError> {\n const wallet = Engine.serverWallet({\n client,\n address: request.from,\n });\n\n return ResultAsync.fromPromise(sendTransaction(wallet, request), (err) =>\n SigningError.from(err),\n )\n .map(async (hash) =>\n waitForReceipt({\n client,\n chain: {\n id: request.chainId,\n rpc: `https://${request.chainId}.rpc.thirdweb.com/${client.clientId}`,\n },\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\nfunction executePlan(\n client: ThirdwebClient,\n result: ExecutionPlan,\n): ReturnType<ExecutionPlanHandler> {\n switch (result.__typename) {\n case 'TransactionRequest':\n return sendTransactionAndWait(client, result);\n\n case 'Erc20ApprovalRequired':\n case 'PreContractActionRequired':\n return sendTransactionAndWait(client, result.transaction).andThen(() =>\n sendTransactionAndWait(client, 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 Thirdweb client and account.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n client: ThirdwebClient,\n): ExecutionPlanHandler<T>;\n/**\n * Sends execution plan transactions using the provided Thirdweb client.\n */\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n client: ThirdwebClient,\n result: T,\n): ReturnType<ExecutionPlanHandler<T>>;\nexport function sendWith<T extends ExecutionPlan = ExecutionPlan>(\n client: ThirdwebClient,\n result?: T,\n): ExecutionPlanHandler<T> | ReturnType<ExecutionPlanHandler<T>> {\n return result ? executePlan(client, result) : executePlan.bind(null, client);\n}\n\nasync function signTypedData(\n client: ThirdwebClient,\n result: PermitTypedDataResponse,\n): Promise<Signature> {\n const wallet = Engine.serverWallet({\n client,\n chain: defineChain({ id: 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: defineChain({ id: 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"]}
1
+ {"version":3,"sources":["../src/thirdweb.ts"],"names":["toThirdwebChain","chain","chainId","mainnet","sepolia","defineChain","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","wallet","signature","signatureFrom","signERC20PermitWith","value","signSwapTypedData","signTypedDataPromise","signSwapTypedDataWith"],"mappings":"gTA6CO,SAASA,CAAAA,CAAgBC,CAAAA,CAA6B,CAE3D,OAAQA,CAAAA,CAAM,OAAA,EACZ,KAAKC,OAAAA,CAAQC,OAAAA,CAAQ,EAAE,CAAA,CACrB,OAAOA,OAAAA,CAET,KAAKD,OAAAA,CAAQ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,CACvB,CAAA,CAAE,GAAA,CAAKgB,CAAAA,GAAW,CAChB,QAAA,CAAUR,CAAAA,CAAO,OAAA,CAAQ,QAAA,CACzB,KAAA,CAAAQ,CACF,CAAA,CAAE,CACJ,CACF,CAEA,SAASC,CAAAA,CACPL,CAAAA,CACAJ,CAAAA,CACkC,CAClC,IAAMU,CAAAA,CAAuB,SAAgC,CAC3D,IAAML,CAAAA,CAAY,MAAMD,CAAAA,CAAO,aAAA,CAAc,CAE3C,KAAA,CAAOJ,CAAAA,CAAO,KAAA,CACd,MAAA,CAAQA,CAAAA,CAAO,MAAA,CACf,WAAA,CAAaA,CAAAA,CAAO,WAAA,CACpB,OAAA,CAASA,CAAAA,CAAO,OAClB,CAAC,CAAA,CAED,OAAOM,aAAAA,CAAcD,CAAS,CAChC,CAAA,CAEA,OAAOd,YAAY,WAAA,CAAYmB,CAAAA,EAAqB,CAAIlB,CAAAA,EACtDC,YAAAA,CAAa,IAAA,CAAKD,CAAG,CACvB,CAAA,CAAE,GAAA,CAAIc,aAAa,CACrB,CAeO,SAASK,CAAAA,CACdP,CAAAA,CACAJ,CAAAA,CACyD,CACzD,OAAOA,CAAAA,CACHS,CAAAA,CAAkBL,CAAAA,CAAQJ,CAAM,CAAA,CAChCS,CAAAA,CAAkB,IAAA,CAAK,IAAA,CAAML,CAAM,CACzC","file":"thirdweb.js","sourcesContent":["import {\n SigningError,\n TransactionError,\n type UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n Chain,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapTypedData,\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\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 wallet: Engine.ServerWallet,\n result: PermitTypedDataResponse,\n): Promise<Signature> {\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\n/**\n * Creates an ERC20 permit handler that signs ERC20 permits using the provided Thirdweb client and account.\n */\nexport function signERC20PermitWith(\n wallet: Engine.ServerWallet,\n): ERC20PermitHandler {\n return function signERC20Permit(\n result: PermitTypedDataResponse,\n ): ReturnType<ERC20PermitHandler> {\n return ResultAsync.fromPromise(signTypedData(wallet, result), (err) =>\n SigningError.from(err),\n ).map((value) => ({\n deadline: result.message.deadline,\n value,\n }));\n };\n}\n\nfunction signSwapTypedData(\n wallet: Engine.ServerWallet,\n result: SwapTypedData,\n): ReturnType<SwapSignatureHandler> {\n const signTypedDataPromise = async (): Promise<Signature> => {\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\n return ResultAsync.fromPromise(signTypedDataPromise(), (err) =>\n SigningError.from(err),\n ).map(signatureFrom);\n}\n\n/**\n * Creates a swap signature handler that signs swap typed data using the provided Thirdweb client.\n */\nexport function signSwapTypedDataWith(\n wallet: Engine.ServerWallet,\n): SwapSignatureHandler;\n/**\n * Signs swap typed data using the provided Thirdweb client.\n */\nexport function signSwapTypedDataWith(\n wallet: Engine.ServerWallet,\n result: SwapTypedData,\n): ReturnType<SwapSignatureHandler>;\nexport function signSwapTypedDataWith(\n wallet: Engine.ServerWallet,\n result?: SwapTypedData,\n): SwapSignatureHandler | ReturnType<SwapSignatureHandler> {\n return result\n ? signSwapTypedData(wallet, result)\n : signSwapTypedData.bind(null, wallet);\n}\n"]}
@@ -1,6 +1,6 @@
1
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';
2
+ import { OperationType, ExecutionPlan, InsufficientBalanceError, PermitTypedDataResponse, ERC20PermitSignature, SwapTypedData, HasProcessedKnownTransactionRequest } from '@aave/graphql';
3
+ import { TxHash, ResultAsync, Signature } from '@aave/types';
4
4
 
5
5
  /**
6
6
  * @internal
@@ -15,7 +15,7 @@ type TransactionResult = {
15
15
  declare function isHasProcessedKnownTransactionRequest(result: TransactionResult): result is HasProcessedKnownTransactionRequest;
16
16
  type SendWithError = CancelError | SigningError | TransactionError | ValidationError<InsufficientBalanceError> | UnexpectedError;
17
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>;
18
+ type ERC20PermitHandler = (data: PermitTypedDataResponse) => ResultAsync<ERC20PermitSignature, SigningError>;
19
+ type SwapSignatureHandler = (result: SwapTypedData) => ResultAsync<Signature, SigningError>;
20
20
 
21
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 };
@@ -1,6 +1,6 @@
1
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';
2
+ import { OperationType, ExecutionPlan, InsufficientBalanceError, PermitTypedDataResponse, ERC20PermitSignature, SwapTypedData, HasProcessedKnownTransactionRequest } from '@aave/graphql';
3
+ import { TxHash, ResultAsync, Signature } from '@aave/types';
4
4
 
5
5
  /**
6
6
  * @internal
@@ -15,7 +15,7 @@ type TransactionResult = {
15
15
  declare function isHasProcessedKnownTransactionRequest(result: TransactionResult): result is HasProcessedKnownTransactionRequest;
16
16
  type SendWithError = CancelError | SigningError | TransactionError | ValidationError<InsufficientBalanceError> | UnexpectedError;
17
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>;
18
+ type ERC20PermitHandler = (data: PermitTypedDataResponse) => ResultAsync<ERC20PermitSignature, SigningError>;
19
+ type SwapSignatureHandler = (result: SwapTypedData) => ResultAsync<Signature, SigningError>;
20
20
 
21
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 };
package/dist/viem.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var core=require('@aave/core'),types=require('@aave/types'),viem=require('viem'),actions=require('viem/actions');function p(n){return types.isObject(n)&&"code"in n&&"message"in n}function U(n){return types.isObject(n)&&"name"in n&&"message"in n&&"originalError"in n?p(n.originalError)&&"code"in n.originalError:true}var m=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/"}}}),T={[types.chainId(m.id)]:m};function _(n,e){return types.ResultAsync.fromPromise(n.getChainId(),a=>core.SigningError.from(a)).andThen(a=>a===e.chainId?types.okAsync():types.ResultAsync.fromPromise(n.switchChain({id:e.chainId}),r=>core.SigningError.from(r)).orElse(r=>(p(r.cause)?r.cause.code:U(r.cause)?r.cause.data?.originalError?.code:void 0)===viem.SwitchChainError.code&&e.chainId in T?types.ResultAsync.fromPromise(n.addChain({chain:T[e.chainId]}),c=>p(c)&&c.code===viem.UserRejectedRequestError.code?core.CancelError.from(c):core.SigningError.from(c)):r.asResultAsync()))}function k(n,e){return types.ResultAsync.fromPromise(actions.estimateGas(n,{account:n.account,data:e.data,to:e.to,value:BigInt(e.value)}),a=>core.SigningError.from(a)).map(a=>a*115n/100n)}function B(n,e){return k(n,e).andThen(a=>types.ResultAsync.fromPromise(actions.sendTransaction(n,{account:n.account,data:e.data,to:e.to,value:BigInt(e.value),chain:n.chain,gas:a}),r=>{if(r instanceof viem.TransactionExecutionError){let t=r.walk(c=>c instanceof viem.UserRejectedRequestError);if(t)return core.CancelError.from(t)}return core.SigningError.from(r)})).map(types.txHash)}function L(n){return n.account!==void 0}function N(n,e){return types.invariant(L(n),"Wallet client with account is required"),_(n,e).andThen(a=>B(n,e))}function q(n,e,a){let r=n?.blockExplorers?.default?.url,t=r&&new URL(`/tx/${e}`,r).toString();return core.TransactionError.new({txHash:e,request:a,link:t})}function O(n,e,a){return types.ResultAsync.fromPromise(actions.waitForTransactionReceipt(n,{hash:a,pollingInterval:100,retryCount:20,retryDelay:50}),r=>core.UnexpectedError.from(r)).andThen(r=>{let t=types.txHash(r.transactionHash);switch(r.status){case "reverted":return a!==t?types.errAsync(core.CancelError.from(`Transaction replaced by ${t}`)):types.errAsync(q(n.chain,t,e));case "success":return types.okAsync({txHash:t,operations:e.operations})}})}function s(n,e){return N(n,e).andThen(a=>O(n,e,a))}function y(n,e){switch(e.__typename){case "TransactionRequest":return s(n,e);case "Erc20ApprovalRequired":case "PreContractActionRequired":return s(n,e.transaction).andThen(()=>s(n,e.originalTransaction));case "InsufficientBalanceError":return types.errAsync(core.ValidationError.fromGqlNode(e))}}function Y(n,e){return e?y(n,e):y.bind(null,n)}function F(n,e){return types.invariant(n.account,"Wallet account is required"),types.ResultAsync.fromPromise(actions.signTypedData(n,{account:n.account,domain:e.domain,types:e.types,primaryType:e.primaryType,message:e.message}),a=>core.SigningError.from(a)).map(a=>({deadline:e.message.deadline,value:types.signatureFrom(a)}))}function J(n){return F.bind(null,n)}function E(n,e){return types.invariant(n.account,"Wallet account is required"),types.ResultAsync.fromPromise(actions.signTypedData(n,{account:n.account,domain:e.domain,types:e.types,primaryType:e.primaryType,message:JSON.parse(e.message)}),a=>core.SigningError.from(a)).map(a=>({deadline:JSON.parse(e.message).deadline,value:types.signatureFrom(a)}))}function K(n,e){return e?E(n,e):E.bind(null,n)}
2
- exports.devnetChain=m;exports.sendTransaction=N;exports.sendWith=Y;exports.signERC20PermitWith=J;exports.signSwapTypedDataWith=K;exports.supportedChains=T;exports.transactionError=q;exports.waitForTransactionResult=O;//# sourceMappingURL=viem.cjs.map
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 F(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 S(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(S)}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:F(i.cause)?i.cause.data?.originalError?.code:void 0)===viem.SwitchChainError.code?types.ResultAsync.fromPromise(n.addChain({chain:S(a)}),s=>m(s)&&s.code===viem.UserRejectedRequestError.code?core.CancelError.from(s):core.SigningError.from(s)):i.asResultAsync()))))}function N(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 K(e,n){return N(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 Y(e){return e.account!==void 0}function G(e,n){return types.invariant(Y(e),"Wallet client with account is required"),K(e,n)}function $(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 j(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($(e.chain,a,n));case "success":return types.okAsync({txHash:a,operations:n.operations})}})}function p(e,n){return G(e,n).andThen(t=>j(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 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:n.message}),t=>core.SigningError.from(t)).map(t=>({deadline:n.message.deadline,value:types.signatureFrom(t)}))}function ye(e,n){return typeof n>"u"?x.bind(null,e):x(e,n)}function g(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(types.signatureFrom)}function he(e,n){return n?g(e,n):g.bind(null,e)}
2
+ exports.ensureChain=de;exports.sendTransaction=G;exports.sendWith=me;exports.signERC20PermitWith=ye;exports.signSwapTypedDataWith=he;exports.supportedChains=pe;exports.toViemChain=S;exports.transactionError=$;exports.viemChainsFrom=le;exports.waitForTransactionResult=j;//# sourceMappingURL=viem.cjs.map
3
3
  //# sourceMappingURL=viem.cjs.map
package/dist/viem.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/viem.ts"],"names":["isRpcError","err","isObject","isProviderRpcError","devnetChain","defineChain","supportedChains","chainId","ensureChain","walletClient","request","ResultAsync","SigningError","okAsync","SwitchChainError","UserRejectedRequestError","CancelError","estimateGas","estimateGasWithViem","gas","sendEip1559Transaction","sendTransactionWithViem","TransactionExecutionError","rejected","txHash","isWalletClientWithAccount","sendTransaction","invariant","_","transactionError","chain","baseUrl","link","TransactionError","waitForTransactionResult","initialTxHash","waitForTransactionReceipt","UnexpectedError","receipt","hash","errAsync","sendTransactionAndWait","executePlan","result","ValidationError","sendWith","signERC20Permit","signTypedData","hex","signatureFrom","signERC20PermitWith","signSwapTypedData","signSwapTypedDataWith"],"mappings":"8HAqDA,SAASA,CAAAA,CAAWC,EAA+B,CACjD,OAAOC,cAAAA,CAASD,CAAG,GAAK,MAAA,GAAUA,CAAAA,EAAO,YAAaA,CACxD,CAEA,SAASE,CAAAA,CACPF,CAAAA,CAC+D,CAC/D,OAAOC,eAASD,CAAG,CAAA,EACjB,SAAUA,CAAAA,EACV,SAAA,GAAaA,GACb,eAAA,GAAmBA,CAAAA,CACjBD,EAAWC,CAAAA,CAAI,aAAa,GAAK,MAAA,GAAUA,CAAAA,CAAI,cAC/C,IACN,KAKaG,CAAAA,CAAqBC,gBAAAA,CAAY,CAC5C,EAAA,CAAI,OAAO,QAAA,CAAS,WAAA,CAA2C,EAAE,CAAA,CACjE,IAAA,CAAM,SACN,OAAA,CAAS,eAAA,CACT,cAAA,CAAgB,CAAE,KAAM,OAAA,CAAS,MAAA,CAAQ,MAAO,QAAA,CAAU,EAAG,EAC7D,OAAA,CAAS,CACP,OAAA,CAAS,CAAE,KAAM,CAAC,2FAA4C,CAAE,CAClE,CAAA,CACA,eAAgB,CACd,OAAA,CAAS,CACP,IAAA,CAAM,iBAAA,CACN,IAAK,mFACP,CACF,CACF,CAAC,CAAA,CAKYC,EAGT,CAIF,CAACC,aAAAA,CAAQH,CAAAA,CAAY,EAAE,CAAC,EAAGA,CAC7B,EAEA,SAASI,EACPC,CAAAA,CACAC,CAAAA,CAC+C,CAC/C,OAAOC,kBAAY,WAAA,CAAYF,CAAAA,CAAa,YAAW,CAAIR,CAAAA,EACzDW,kBAAa,IAAA,CAAKX,CAAG,CACv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AAAA,CAAa,QACtB,MAAA,CAAQkC,CAAAA,CAAO,OACf,KAAA,CAAOA,CAAAA,CAAO,MACd,WAAA,CAAaA,CAAAA,CAAO,YACpB,OAAA,CAAS,IAAA,CAAK,KAAA,CAAMA,CAAAA,CAAO,OAAO,CACpC,CAAC,EACA1C,CAAAA,EAAQW,iBAAAA,CAAa,KAAKX,CAAG,CAChC,EAAE,GAAA,CAAK+C,CAAAA,GAAS,CACd,QAAA,CAAU,IAAA,CAAK,MAAML,CAAAA,CAAO,OAAO,EAAE,QAAA,CACrC,KAAA,CAAOM,mBAAAA,CAAcD,CAAG,CAC1B,CAAA,CAAE,CACJ,CAiBO,SAASI,CAAAA,CACd3C,EACAkC,CAAAA,CACyD,CACzD,OAAOA,CAAAA,CACHQ,CAAAA,CAAkB1C,EAAckC,CAAM,CAAA,CACtCQ,EAAkB,IAAA,CAAK,IAAA,CAAM1C,CAAY,CAC/C","file":"viem.cjs","sourcesContent":["import {\n CancelError,\n SigningError,\n TransactionError,\n UnexpectedError,\n ValidationError,\n} from '@aave/core';\nimport type {\n CancelSwapTypedData,\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 type Chain,\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 WalletClient,\n} from 'viem';\nimport {\n estimateGas as estimateGasWithViem,\n sendTransaction as sendTransactionWithViem,\n signTypedData,\n waitForTransactionReceipt,\n} from 'viem/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\n/**\n * @internal\n */\nexport const devnetChain: Chain = 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 */\nexport const supportedChains: Record<\n ChainId,\n ReturnType<typeof defineChain>\n> = {\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\nfunction ensureChain(\n walletClient: WalletClient,\n request: TransactionRequest,\n): ResultAsync<void, CancelError | SigningError> {\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 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 (\n code === SwitchChainError.code &&\n request.chainId in supportedChains\n ) {\n return ResultAsync.fromPromise(\n walletClient.addChain({ chain: supportedChains[request.chainId] }),\n (err) => {\n if (isRpcError(err) && err.code === UserRejectedRequestError.code) {\n return CancelError.from(err);\n }\n return SigningError.from(err);\n },\n );\n }\n\n return err.asResultAsync();\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, Chain, 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, Chain, 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 ensureChain(walletClient, request).andThen((_) =>\n sendEip1559Transaction(walletClient, request),\n );\n}\n\n/**\n * @internal\n */\nexport function transactionError(\n chain: Chain | 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"]}
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","data","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,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACA,CAAE,KAAA,CAAAC,CAAM,EAAkBN,CAAAA,CACkB,CAC5C,OAAOI,CAAAA,CAAO,KAAA,CAAMG,kBAAAA,CAAY,CAAE,OAAA,CAAAF,CAAQ,CAAA,CAAG,CAAE,KAAA,CAAAC,CAAM,CAAC,CACxD,CCOA,SAASE,CAAAA,CAAWC,CAAAA,CAA+B,CACjD,OAAOC,cAAAA,CAASD,CAAG,CAAA,EAAK,MAAA,GAAUA,CAAAA,EAAO,YAAaA,CACxD,CAEA,SAASE,CAAAA,CACPF,CAAAA,CAC+D,CAC/D,OAAOC,cAAAA,CAASD,CAAG,CAAA,EACjB,MAAA,GAAUA,CAAAA,EACV,SAAA,GAAaA,GACb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ACyD,CACzD,OAAOA,CAAAA,CACHS,CAAAA,CAAkBxC,CAAAA,CAAc+B,CAAM,EACtCS,CAAAA,CAAkB,IAAA,CAAK,IAAA,CAAMxC,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 Chain,\n ExecutionPlan,\n PermitTypedDataResponse,\n SwapTypedData,\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 data: 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: data.domain as TypedDataDomain,\n types: data.types as TypedData,\n primaryType: data.primaryType as keyof typeof data.types,\n message: data.message,\n }),\n (err) => SigningError.from(err),\n ).map((hex) => ({\n deadline: data.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/**\n * Signs ERC20 permits using the provided wallet client.\n */\nexport function signERC20PermitWith(\n walletClient: WalletClient,\n data: PermitTypedDataResponse,\n): ReturnType<ERC20PermitHandler>;\nexport function signERC20PermitWith(\n walletClient: WalletClient,\n data?: PermitTypedDataResponse,\n): ERC20PermitHandler | ReturnType<ERC20PermitHandler> {\n return typeof data === 'undefined'\n ? signERC20Permit.bind(null, walletClient)\n : signERC20Permit(walletClient, data);\n}\n\nfunction signSwapTypedData(\n walletClient: WalletClient,\n result: SwapTypedData,\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: result.message,\n }),\n (err) => SigningError.from(err),\n ).map(signatureFrom);\n}\n\n/**\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 * Signs swap typed data using the provided wallet client.\n */\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n result: SwapTypedData,\n): ReturnType<SwapSignatureHandler>;\nexport function signSwapTypedDataWith(\n walletClient: WalletClient,\n result?: SwapTypedData,\n): SwapSignatureHandler | ReturnType<SwapSignatureHandler> {\n return result\n ? signSwapTypedData(walletClient, result)\n : signSwapTypedData.bind(null, walletClient);\n}\n"]}
package/dist/viem.d.cts CHANGED
@@ -1,17 +1,28 @@
1
- import { CancelError, SigningError, TransactionError, UnexpectedError } from '@aave/core';
2
- import { TransactionRequest, ExecutionPlan, SwapByIntentTypedData, CancelSwapTypedData } from '@aave/graphql';
1
+ import { CancelError, SigningError, UnexpectedError, TransactionError } from '@aave/core';
2
+ import { Chain as Chain$1, TransactionRequest, ExecutionPlan, PermitTypedDataResponse, SwapTypedData } from '@aave/graphql';
3
3
  import { ChainId, ResultAsync, TxHash } from '@aave/types';
4
- import { Chain, defineChain, WalletClient } from 'viem';
5
- import { T as TransactionResult, E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-Bu63z0x6.cjs';
4
+ import { Chain, WalletClient } from 'viem';
5
+ import { A as AaveClient } from './AaveClient-BIfAdE-4.cjs';
6
+ import { T as TransactionResult, E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-CQvue0x0.cjs';
7
+ import '@urql/core';
6
8
 
7
9
  /**
8
10
  * @internal
11
+ * @deprecated
9
12
  */
10
- declare const devnetChain: Chain;
13
+ declare const supportedChains: Record<ChainId, Chain>;
11
14
  /**
12
15
  * @internal
13
16
  */
14
- declare const supportedChains: Record<ChainId, ReturnType<typeof defineChain>>;
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>;
15
26
  /**
16
27
  * @internal
17
28
  */
@@ -37,14 +48,16 @@ declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(walletClient:
37
48
  */
38
49
  declare function signERC20PermitWith(walletClient: WalletClient): ERC20PermitHandler;
39
50
  /**
40
- * @internal
51
+ * Signs ERC20 permits using the provided wallet client.
52
+ */
53
+ declare function signERC20PermitWith(walletClient: WalletClient, data: PermitTypedDataResponse): ReturnType<ERC20PermitHandler>;
54
+ /**
41
55
  * Creates a swap signature handler that signs swap typed data using the provided wallet client.
42
56
  */
43
57
  declare function signSwapTypedDataWith(walletClient: WalletClient): SwapSignatureHandler;
44
58
  /**
45
- * @internal
46
59
  * Signs swap typed data using the provided wallet client.
47
60
  */
48
- declare function signSwapTypedDataWith(walletClient: WalletClient, result: SwapByIntentTypedData | CancelSwapTypedData): ReturnType<SwapSignatureHandler>;
61
+ declare function signSwapTypedDataWith(walletClient: WalletClient, result: SwapTypedData): ReturnType<SwapSignatureHandler>;
49
62
 
50
- export { devnetChain, sendTransaction, sendWith, signERC20PermitWith, signSwapTypedDataWith, supportedChains, transactionError, waitForTransactionResult };
63
+ export { ensureChain, sendTransaction, sendWith, signERC20PermitWith, signSwapTypedDataWith, supportedChains, toViemChain, transactionError, viemChainsFrom, waitForTransactionResult };
package/dist/viem.d.ts CHANGED
@@ -1,17 +1,28 @@
1
- import { CancelError, SigningError, TransactionError, UnexpectedError } from '@aave/core';
2
- import { TransactionRequest, ExecutionPlan, SwapByIntentTypedData, CancelSwapTypedData } from '@aave/graphql';
1
+ import { CancelError, SigningError, UnexpectedError, TransactionError } from '@aave/core';
2
+ import { Chain as Chain$1, TransactionRequest, ExecutionPlan, PermitTypedDataResponse, SwapTypedData } from '@aave/graphql';
3
3
  import { ChainId, ResultAsync, TxHash } from '@aave/types';
4
- import { Chain, defineChain, WalletClient } from 'viem';
5
- import { T as TransactionResult, E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-Bu63z0x6.js';
4
+ import { Chain, WalletClient } from 'viem';
5
+ import { A as AaveClient } from './AaveClient-C36zcfbL.js';
6
+ import { T as TransactionResult, E as ExecutionPlanHandler, a as ERC20PermitHandler, S as SwapSignatureHandler } from './types-CQvue0x0.js';
7
+ import '@urql/core';
6
8
 
7
9
  /**
8
10
  * @internal
11
+ * @deprecated
9
12
  */
10
- declare const devnetChain: Chain;
13
+ declare const supportedChains: Record<ChainId, Chain>;
11
14
  /**
12
15
  * @internal
13
16
  */
14
- declare const supportedChains: Record<ChainId, ReturnType<typeof defineChain>>;
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>;
15
26
  /**
16
27
  * @internal
17
28
  */
@@ -37,14 +48,16 @@ declare function sendWith<T extends ExecutionPlan = ExecutionPlan>(walletClient:
37
48
  */
38
49
  declare function signERC20PermitWith(walletClient: WalletClient): ERC20PermitHandler;
39
50
  /**
40
- * @internal
51
+ * Signs ERC20 permits using the provided wallet client.
52
+ */
53
+ declare function signERC20PermitWith(walletClient: WalletClient, data: PermitTypedDataResponse): ReturnType<ERC20PermitHandler>;
54
+ /**
41
55
  * Creates a swap signature handler that signs swap typed data using the provided wallet client.
42
56
  */
43
57
  declare function signSwapTypedDataWith(walletClient: WalletClient): SwapSignatureHandler;
44
58
  /**
45
- * @internal
46
59
  * Signs swap typed data using the provided wallet client.
47
60
  */
48
- declare function signSwapTypedDataWith(walletClient: WalletClient, result: SwapByIntentTypedData | CancelSwapTypedData): ReturnType<SwapSignatureHandler>;
61
+ declare function signSwapTypedDataWith(walletClient: WalletClient, result: SwapTypedData): ReturnType<SwapSignatureHandler>;
49
62
 
50
- export { devnetChain, sendTransaction, sendWith, signERC20PermitWith, signSwapTypedDataWith, supportedChains, transactionError, waitForTransactionResult };
63
+ export { ensureChain, sendTransaction, sendWith, signERC20PermitWith, signSwapTypedDataWith, supportedChains, toViemChain, transactionError, viemChainsFrom, waitForTransactionResult };
package/dist/viem.js CHANGED
@@ -1,2 +1,2 @@
1
- export{a as devnetChain,c as sendTransaction,f as sendWith,g as signERC20PermitWith,h as signSwapTypedDataWith,b as supportedChains,d as transactionError,e as waitForTransactionResult}from'./chunk-2TNQ52OQ.js';//# sourceMappingURL=viem.js.map
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-3HZQC3YV.js';import'./chunk-MKZBFAXA.js';//# sourceMappingURL=viem.js.map
2
2
  //# sourceMappingURL=viem.js.map