@lifi/sdk-provider-bitcoin 4.0.0-beta.6 → 4.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BitcoinProvider.js.map +1 -1
- package/dist/cjs/client/publicClient.js.map +1 -1
- package/dist/cjs/core/BitcoinStepExecutor.js.map +1 -1
- package/dist/cjs/errors/parseBitcoinErrors.js.map +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/BitcoinProvider.js.map +1 -1
- package/dist/esm/client/publicClient.js.map +1 -1
- package/dist/esm/core/BitcoinStepExecutor.js.map +1 -1
- package/dist/esm/errors/parseBitcoinErrors.js.map +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +2 -2
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinProvider.js","names":["ChainType","isUTXOAddress","resolveBitcoinAddress","getBitcoinBalance","BitcoinStepExecutor"],"sources":["../../src/BitcoinProvider.ts"],"sourcesContent":["import { isUTXOAddress } from '@bigmi/core'\nimport { ChainType, type StepExecutorOptions } from '@lifi/sdk'\nimport { getBitcoinBalance } from './actions/getBitcoinBalance.js'\nimport { resolveBitcoinAddress } from './actions/resolveBitcoinAddress.js'\nimport { BitcoinStepExecutor } from './core/BitcoinStepExecutor.js'\nimport type { BitcoinProviderOptions, BitcoinSDKProvider } from './types.js'\n\nexport function BitcoinProvider(\n options?: BitcoinProviderOptions\n): BitcoinSDKProvider {\n const _options: BitcoinProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.UTXO\n },\n isAddress: isUTXOAddress,\n resolveAddress: resolveBitcoinAddress,\n getBalance: getBitcoinBalance,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<BitcoinStepExecutor> {\n if (!_options.getWalletClient) {\n throw new Error('Client is not provided.')\n }\n\n const walletClient = await _options.getWalletClient()\n\n const executor = new BitcoinStepExecutor({\n client: walletClient,\n routeId: options.routeId,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: BitcoinProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,gBACd,SACoB;CACpB,MAAM,WAAmC,WAAW,EAAE;AACtD,QAAO;EACL,IAAI,OAAO;AACT,UAAOA,UAAAA,UAAU;;EAEnB,WAAWC,YAAAA;EACX,gBAAgBC,sCAAAA;EAChB,YAAYC,kCAAAA;EACZ,MAAM,gBACJ,SAC8B;AAC9B,OAAI,CAAC,SAAS,gBACZ,OAAM,IAAI,MAAM,0BAA0B;AAa5C,
|
|
1
|
+
{"version":3,"file":"BitcoinProvider.js","names":["ChainType","isUTXOAddress","resolveBitcoinAddress","getBitcoinBalance","BitcoinStepExecutor"],"sources":["../../src/BitcoinProvider.ts"],"sourcesContent":["import { isUTXOAddress } from '@bigmi/core'\nimport { ChainType, type StepExecutorOptions } from '@lifi/sdk'\nimport { getBitcoinBalance } from './actions/getBitcoinBalance.js'\nimport { resolveBitcoinAddress } from './actions/resolveBitcoinAddress.js'\nimport { BitcoinStepExecutor } from './core/BitcoinStepExecutor.js'\nimport type { BitcoinProviderOptions, BitcoinSDKProvider } from './types.js'\n\nexport function BitcoinProvider(\n options?: BitcoinProviderOptions\n): BitcoinSDKProvider {\n const _options: BitcoinProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.UTXO\n },\n isAddress: isUTXOAddress,\n resolveAddress: resolveBitcoinAddress,\n getBalance: getBitcoinBalance,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<BitcoinStepExecutor> {\n if (!_options.getWalletClient) {\n throw new Error('Client is not provided.')\n }\n\n const walletClient = await _options.getWalletClient()\n\n const executor = new BitcoinStepExecutor({\n client: walletClient,\n routeId: options.routeId,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: BitcoinProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,gBACd,SACoB;CACpB,MAAM,WAAmC,WAAW,EAAE;AACtD,QAAO;EACL,IAAI,OAAO;AACT,UAAOA,UAAAA,UAAU;;EAEnB,WAAWC,YAAAA;EACX,gBAAgBC,sCAAAA;EAChB,YAAYC,kCAAAA;EACZ,MAAM,gBACJ,SAC8B;AAC9B,OAAI,CAAC,SAAS,gBACZ,OAAM,IAAI,MAAM,0BAA0B;AAa5C,UAAO,IARcC,iCAAAA,oBAAoB;IACvC,QAAQ,MAHiB,SAAS,iBAAiB;IAInD,SAAS,QAAQ;IACjB,kBAAkB,EAChB,GAAG,QAAQ,kBACZ;IACF,CAEc;;EAEjB,WAAW,SAAiC;AAC1C,UAAO,OAAO,UAAU,QAAQ;;EAEnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicClient.js","names":["toBigmiChainId","publicActions","walletActions"],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import {\n type Account,\n blockchair,\n blockcypher,\n type Chain,\n type Client,\n createClient,\n type FallbackTransport,\n fallback,\n type HttpTransport,\n http,\n mempool,\n type PublicActions,\n publicActions,\n rpcSchema,\n type UTXOSchema,\n type WalletActions,\n walletActions,\n} from '@bigmi/core'\nimport type { SDKClient } from '@lifi/sdk'\nimport { toBigmiChainId } from '../utils/toBigmiChainId.js'\n\nexport type PublicClient = Client<\n FallbackTransport<readonly HttpTransport[]>,\n Chain,\n Account | undefined,\n UTXOSchema,\n PublicActions & WalletActions\n>\n\n// cached providers\nconst publicClients: Record<number, PublicClient> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getBitcoinPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<PublicClient> => {\n if (!publicClients[chainId]) {\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n http(url, {\n fetchOptions: {\n method: 'POST',\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n id: toBigmiChainId(_chain.id),\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n const bigmiClient = createClient({\n chain,\n rpcSchema: rpcSchema<UTXOSchema>(),\n transport: fallback([\n blockchair(),\n blockcypher(),\n mempool(),\n ...fallbackTransports,\n ]),\n pollingInterval: 10_000,\n })\n .extend(publicActions)\n .extend(walletActions)\n publicClients[chainId] = bigmiClient\n }\n\n if (!publicClients[chainId]) {\n throw new Error(`Unable to configure provider for chain ${chainId}`)\n }\n\n return publicClients[chainId]\n}\n"],"mappings":";;;;;AA+BA,MAAM,gBAA8C,EAAE;;;;;;;AAQtD,MAAa,yBAAyB,OACpC,QACA,YAC0B;AAC1B,KAAI,CAAC,cAAc,UAAU;EAE3B,MAAM,
|
|
1
|
+
{"version":3,"file":"publicClient.js","names":["toBigmiChainId","publicActions","walletActions"],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import {\n type Account,\n blockchair,\n blockcypher,\n type Chain,\n type Client,\n createClient,\n type FallbackTransport,\n fallback,\n type HttpTransport,\n http,\n mempool,\n type PublicActions,\n publicActions,\n rpcSchema,\n type UTXOSchema,\n type WalletActions,\n walletActions,\n} from '@bigmi/core'\nimport type { SDKClient } from '@lifi/sdk'\nimport { toBigmiChainId } from '../utils/toBigmiChainId.js'\n\nexport type PublicClient = Client<\n FallbackTransport<readonly HttpTransport[]>,\n Chain,\n Account | undefined,\n UTXOSchema,\n PublicActions & WalletActions\n>\n\n// cached providers\nconst publicClients: Record<number, PublicClient> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getBitcoinPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<PublicClient> => {\n if (!publicClients[chainId]) {\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n http(url, {\n fetchOptions: {\n method: 'POST',\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n id: toBigmiChainId(_chain.id),\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n const bigmiClient = createClient({\n chain,\n rpcSchema: rpcSchema<UTXOSchema>(),\n transport: fallback([\n blockchair(),\n blockcypher(),\n mempool(),\n ...fallbackTransports,\n ]),\n pollingInterval: 10_000,\n })\n .extend(publicActions)\n .extend(walletActions)\n publicClients[chainId] = bigmiClient\n }\n\n if (!publicClients[chainId]) {\n throw new Error(`Unable to configure provider for chain ${chainId}`)\n }\n\n return publicClients[chainId]\n}\n"],"mappings":";;;;;AA+BA,MAAM,gBAA8C,EAAE;;;;;;;AAQtD,MAAa,yBAAyB,OACpC,QACA,YAC0B;AAC1B,KAAI,CAAC,cAAc,UAAU;EAE3B,MAAM,sBAAqB,MADR,OAAO,oBAAoB,QAAQ,EACtB,KAAK,SAAA,GAAA,YAAA,MAC9B,KAAK,EACR,cAAc,EACZ,QAAQ,QACT,EACF,CAAC,CACH;EACD,MAAM,SAAS,MAAM,OAAO,aAAa,QAAQ;AAwBjD,gBAAc,YAAA,GAAA,YAAA,cAbmB;GAC/B,OAAA;IAVA,GAAG;IACH,GAAG,OAAO;IACV,IAAIA,6BAAAA,eAAe,OAAO,GAAG;IAC7B,MAAM,OAAO,SAAS;IACtB,SAAS;KACP,SAAS,EAAE,MAAM,OAAO,SAAS,SAAS;KAC1C,QAAQ,EAAE,MAAM,OAAO,SAAS,SAAS;KAC1C;IAGI;GACL,YAAA,GAAA,YAAA,YAAkC;GAClC,YAAA,GAAA,YAAA,UAAoB;iCACN;kCACC;8BACJ;IACT,GAAG;IACJ,CAAC;GACF,iBAAiB;GAClB,CAAC,CACC,OAAOC,YAAAA,cAAc,CACrB,OAAOC,YAAAA,cAC0B;;AAGtC,KAAI,CAAC,cAAc,SACjB,OAAM,IAAI,MAAM,0CAA0C,UAAU;AAGtE,QAAO,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinStepExecutor.js","names":["BaseStepExecutor","TransactionError","LiFiErrorCode","CheckBalanceTask","PrepareTransactionTask","BitcoinSignAndExecuteTask","BitcoinWaitForTransactionTask","WaitForTransactionStatusTask","TaskPipeline","parseBitcoinErrors","getBitcoinPublicClient"],"sources":["../../../src/core/BitcoinStepExecutor.ts"],"sourcesContent":["import type { Client } from '@bigmi/core'\nimport {\n BaseStepExecutor,\n CheckBalanceTask,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n PrepareTransactionTask,\n type SDKError,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n WaitForTransactionStatusTask,\n} from '@lifi/sdk'\nimport { getBitcoinPublicClient } from '../client/publicClient.js'\nimport { parseBitcoinErrors } from '../errors/parseBitcoinErrors.js'\nimport type { BitcoinStepExecutorContext } from '../types.js'\nimport { BitcoinSignAndExecuteTask } from './tasks/BitcoinSignAndExecuteTask.js'\nimport { BitcoinWaitForTransactionTask } from './tasks/BitcoinWaitForTransactionTask.js'\n\ninterface BitcoinStepExecutorOptions extends StepExecutorOptions {\n client: Client\n}\n\nexport class BitcoinStepExecutor extends BaseStepExecutor {\n private client: Client\n\n constructor(options: BitcoinStepExecutorOptions) {\n super(options)\n this.client = options.client\n }\n\n checkClient = (step: LiFiStepExtended): void => {\n // TODO: check chain and possibly implement chain switch?\n // Prevent execution of the quote by wallet different from the one which requested the quote\n if (this.client.account?.address !== step.action.fromAddress) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n }\n\n override createPipeline = (\n context: BitcoinStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution } = context\n\n const tasks = [\n new CheckBalanceTask(),\n new PrepareTransactionTask(),\n new BitcoinSignAndExecuteTask(),\n new BitcoinWaitForTransactionTask(),\n new WaitForTransactionStatusTask(\n isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'\n ),\n ]\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n const taskName = swapOrBridgeAction?.txHash\n ? swapOrBridgeAction?.status === 'DONE'\n ? WaitForTransactionStatusTask.name\n : BitcoinWaitForTransactionTask.name\n : CheckBalanceTask.name\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction\n ): Promise<SDKError> => parseBitcoinErrors(error, step, action)\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<BitcoinStepExecutorContext> => {\n const { client, fromChain } = baseContext\n\n const publicClient = await getBitcoinPublicClient(client, fromChain.id)\n\n return {\n ...baseContext,\n pollingIntervalMs: 10_000,\n checkClient: this.checkClient,\n walletClient: this.client,\n publicClient,\n }\n }\n}\n"],"mappings":";;;;;;;;AAyBA,IAAa,sBAAb,cAAyCA,UAAAA,iBAAiB;CACxD;CAEA,YAAY,SAAqC;AAC/C,QAAM,QAAQ;AACd,OAAK,SAAS,QAAQ;;CAGxB,eAAe,SAAiC;AAG9C,MAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,YAC/C,OAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,8BACd,oHACD;;CAIL,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAIC,UAAAA,kBAAkB;GACtB,IAAIC,UAAAA,wBAAwB;GAC5B,IAAIC,6CAAAA,2BAA2B;GAC/B,IAAIC,iDAAAA,+BAA+B;GACnC,IAAIC,UAAAA,6BACF,oBAAoB,oBAAoB,OACzC;GACF;EACD,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;EAED,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7BA,UAAAA,6BAA6B,OAC7BD,iDAAAA,8BAA8B,OAChCH,UAAAA,iBAAiB;EAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;AAID,SAAO,IAAIK,UAAAA,aAFQ,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"BitcoinStepExecutor.js","names":["BaseStepExecutor","TransactionError","LiFiErrorCode","CheckBalanceTask","PrepareTransactionTask","BitcoinSignAndExecuteTask","BitcoinWaitForTransactionTask","WaitForTransactionStatusTask","TaskPipeline","parseBitcoinErrors","getBitcoinPublicClient"],"sources":["../../../src/core/BitcoinStepExecutor.ts"],"sourcesContent":["import type { Client } from '@bigmi/core'\nimport {\n BaseStepExecutor,\n CheckBalanceTask,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n PrepareTransactionTask,\n type SDKError,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n WaitForTransactionStatusTask,\n} from '@lifi/sdk'\nimport { getBitcoinPublicClient } from '../client/publicClient.js'\nimport { parseBitcoinErrors } from '../errors/parseBitcoinErrors.js'\nimport type { BitcoinStepExecutorContext } from '../types.js'\nimport { BitcoinSignAndExecuteTask } from './tasks/BitcoinSignAndExecuteTask.js'\nimport { BitcoinWaitForTransactionTask } from './tasks/BitcoinWaitForTransactionTask.js'\n\ninterface BitcoinStepExecutorOptions extends StepExecutorOptions {\n client: Client\n}\n\nexport class BitcoinStepExecutor extends BaseStepExecutor {\n private client: Client\n\n constructor(options: BitcoinStepExecutorOptions) {\n super(options)\n this.client = options.client\n }\n\n checkClient = (step: LiFiStepExtended): void => {\n // TODO: check chain and possibly implement chain switch?\n // Prevent execution of the quote by wallet different from the one which requested the quote\n if (this.client.account?.address !== step.action.fromAddress) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n }\n\n override createPipeline = (\n context: BitcoinStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution } = context\n\n const tasks = [\n new CheckBalanceTask(),\n new PrepareTransactionTask(),\n new BitcoinSignAndExecuteTask(),\n new BitcoinWaitForTransactionTask(),\n new WaitForTransactionStatusTask(\n isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'\n ),\n ]\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n const taskName = swapOrBridgeAction?.txHash\n ? swapOrBridgeAction?.status === 'DONE'\n ? WaitForTransactionStatusTask.name\n : BitcoinWaitForTransactionTask.name\n : CheckBalanceTask.name\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction\n ): Promise<SDKError> => parseBitcoinErrors(error, step, action)\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<BitcoinStepExecutorContext> => {\n const { client, fromChain } = baseContext\n\n const publicClient = await getBitcoinPublicClient(client, fromChain.id)\n\n return {\n ...baseContext,\n pollingIntervalMs: 10_000,\n checkClient: this.checkClient,\n walletClient: this.client,\n publicClient,\n }\n }\n}\n"],"mappings":";;;;;;;;AAyBA,IAAa,sBAAb,cAAyCA,UAAAA,iBAAiB;CACxD;CAEA,YAAY,SAAqC;AAC/C,QAAM,QAAQ;AACd,OAAK,SAAS,QAAQ;;CAGxB,eAAe,SAAiC;AAG9C,MAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,YAC/C,OAAM,IAAIC,UAAAA,iBACRC,UAAAA,cAAc,8BACd,oHACD;;CAIL,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAIC,UAAAA,kBAAkB;GACtB,IAAIC,UAAAA,wBAAwB;GAC5B,IAAIC,6CAAAA,2BAA2B;GAC/B,IAAIC,iDAAAA,+BAA+B;GACnC,IAAIC,UAAAA,6BACF,oBAAoB,oBAAoB,OACzC;GACF;EACD,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;EAED,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7BA,UAAAA,6BAA6B,OAC7BD,iDAAAA,8BAA8B,OAChCH,UAAAA,iBAAiB;EAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;AAID,SAAO,IAAIK,UAAAA,aAFQ,MAAM,MAAM,eAEG,CAAC;;CAGrC,eACE,OACA,MACA,WACsBC,kCAAAA,mBAAmB,OAAO,MAAM,OAAO;CAE/D,gBAAyB,OACvB,gBACwC;EACxC,MAAM,EAAE,QAAQ,cAAc;EAE9B,MAAM,eAAe,MAAMC,4BAAAA,uBAAuB,QAAQ,UAAU,GAAG;AAEvE,SAAO;GACL,GAAG;GACH,mBAAmB;GACnB,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB;GACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBitcoinErrors.js","names":["SDKError","TransactionError","LiFiErrorCode","BaseError","UnknownError","ErrorMessage"],"sources":["../../../src/errors/parseBitcoinErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseBitcoinErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = (e: any) => {\n // txn-mempool-conflict\n if (\n e.details?.includes?.('conflict') ||\n e.cause?.message?.includes?.('conflict')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionConflict,\n 'Your transaction conflicts with another transaction already in the mempool. One or more inputs have been spent by another transaction.',\n e\n )\n }\n if (e.code === 4001 || e.code === -32000 || e.cause?.includes?.('rejected')) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n if (e.code === -5 || e.code === -32700 || e.code === -32064) {\n return new TransactionError(LiFiErrorCode.NotFound, e.message, e)\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;;;AAWA,MAAa,qBAAqB,OAChC,GACA,MACA,WACsB;AACtB,KAAI,aAAaA,UAAAA,UAAU;AACzB,IAAE,OAAO,EAAE,QAAQ;AACnB,IAAE,SAAS,EAAE,UAAU;AACvB,SAAO;;AAKT,QAAO,IAAIA,UAAAA,SAFO,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"parseBitcoinErrors.js","names":["SDKError","TransactionError","LiFiErrorCode","BaseError","UnknownError","ErrorMessage"],"sources":["../../../src/errors/parseBitcoinErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseBitcoinErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = (e: any) => {\n // txn-mempool-conflict\n if (\n e.details?.includes?.('conflict') ||\n e.cause?.message?.includes?.('conflict')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionConflict,\n 'Your transaction conflicts with another transaction already in the mempool. One or more inputs have been spent by another transaction.',\n e\n )\n }\n if (e.code === 4001 || e.code === -32000 || e.cause?.includes?.('rejected')) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n if (e.code === -5 || e.code === -32700 || e.code === -32064) {\n return new TransactionError(LiFiErrorCode.NotFound, e.message, e)\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;;;AAWA,MAAa,qBAAqB,OAChC,GACA,MACA,WACsB;AACtB,KAAI,aAAaA,UAAAA,UAAU;AACzB,IAAE,OAAO,EAAE,QAAQ;AACnB,IAAE,SAAS,EAAE,UAAU;AACvB,SAAO;;AAKT,QAAO,IAAIA,UAAAA,SAFO,qBAAqB,EAEV,EAAE,MAAM,OAAO;;AAG9C,MAAM,wBAAwB,MAAW;AAEvC,KACE,EAAE,SAAS,WAAW,WAAW,IACjC,EAAE,OAAO,SAAS,WAAW,WAAW,CAExC,QAAO,IAAIC,UAAAA,iBACTC,UAAAA,cAAc,qBACd,0IACA,EACD;AAEH,KAAI,EAAE,SAAS,QAAQ,EAAE,SAAS,SAAU,EAAE,OAAO,WAAW,WAAW,CACzE,QAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,mBAAmB,EAAE,SAAS,EAAE;AAE5E,KAAI,EAAE,SAAS,MAAM,EAAE,SAAS,UAAU,EAAE,SAAS,OACnD,QAAO,IAAID,UAAAA,iBAAiBC,UAAAA,cAAc,UAAU,EAAE,SAAS,EAAE;AAGnE,KAAI,aAAaC,UAAAA,UACf,QAAO;AAGT,QAAO,IAAIC,UAAAA,aAAa,EAAE,WAAWC,UAAAA,aAAa,cAAc,EAAE"}
|
package/dist/cjs/version.d.ts
CHANGED
package/dist/cjs/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/version.ts
|
|
3
3
|
const name = "@lifi/sdk-provider-bitcoin";
|
|
4
|
-
const version = "4.0.0-beta.
|
|
4
|
+
const version = "4.0.0-beta.8";
|
|
5
5
|
//#endregion
|
|
6
6
|
exports.name = name;
|
|
7
7
|
exports.version = version;
|
package/dist/cjs/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-bitcoin'\nexport const version = '4.0.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-bitcoin'\nexport const version = '4.0.0-beta.8'\n"],"mappings":";;AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinProvider.js","names":[],"sources":["../../src/BitcoinProvider.ts"],"sourcesContent":["import { isUTXOAddress } from '@bigmi/core'\nimport { ChainType, type StepExecutorOptions } from '@lifi/sdk'\nimport { getBitcoinBalance } from './actions/getBitcoinBalance.js'\nimport { resolveBitcoinAddress } from './actions/resolveBitcoinAddress.js'\nimport { BitcoinStepExecutor } from './core/BitcoinStepExecutor.js'\nimport type { BitcoinProviderOptions, BitcoinSDKProvider } from './types.js'\n\nexport function BitcoinProvider(\n options?: BitcoinProviderOptions\n): BitcoinSDKProvider {\n const _options: BitcoinProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.UTXO\n },\n isAddress: isUTXOAddress,\n resolveAddress: resolveBitcoinAddress,\n getBalance: getBitcoinBalance,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<BitcoinStepExecutor> {\n if (!_options.getWalletClient) {\n throw new Error('Client is not provided.')\n }\n\n const walletClient = await _options.getWalletClient()\n\n const executor = new BitcoinStepExecutor({\n client: walletClient,\n routeId: options.routeId,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: BitcoinProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,gBACd,SACoB;CACpB,MAAM,WAAmC,WAAW,EAAE;AACtD,QAAO;EACL,IAAI,OAAO;AACT,UAAO,UAAU;;EAEnB,WAAW;EACX,gBAAgB;EAChB,YAAY;EACZ,MAAM,gBACJ,SAC8B;AAC9B,OAAI,CAAC,SAAS,gBACZ,OAAM,IAAI,MAAM,0BAA0B;AAa5C,
|
|
1
|
+
{"version":3,"file":"BitcoinProvider.js","names":[],"sources":["../../src/BitcoinProvider.ts"],"sourcesContent":["import { isUTXOAddress } from '@bigmi/core'\nimport { ChainType, type StepExecutorOptions } from '@lifi/sdk'\nimport { getBitcoinBalance } from './actions/getBitcoinBalance.js'\nimport { resolveBitcoinAddress } from './actions/resolveBitcoinAddress.js'\nimport { BitcoinStepExecutor } from './core/BitcoinStepExecutor.js'\nimport type { BitcoinProviderOptions, BitcoinSDKProvider } from './types.js'\n\nexport function BitcoinProvider(\n options?: BitcoinProviderOptions\n): BitcoinSDKProvider {\n const _options: BitcoinProviderOptions = options ?? {}\n return {\n get type() {\n return ChainType.UTXO\n },\n isAddress: isUTXOAddress,\n resolveAddress: resolveBitcoinAddress,\n getBalance: getBitcoinBalance,\n async getStepExecutor(\n options: StepExecutorOptions\n ): Promise<BitcoinStepExecutor> {\n if (!_options.getWalletClient) {\n throw new Error('Client is not provided.')\n }\n\n const walletClient = await _options.getWalletClient()\n\n const executor = new BitcoinStepExecutor({\n client: walletClient,\n routeId: options.routeId,\n executionOptions: {\n ...options.executionOptions,\n },\n })\n\n return executor\n },\n setOptions(options: BitcoinProviderOptions) {\n Object.assign(_options, options)\n },\n }\n}\n"],"mappings":";;;;;;AAOA,SAAgB,gBACd,SACoB;CACpB,MAAM,WAAmC,WAAW,EAAE;AACtD,QAAO;EACL,IAAI,OAAO;AACT,UAAO,UAAU;;EAEnB,WAAW;EACX,gBAAgB;EAChB,YAAY;EACZ,MAAM,gBACJ,SAC8B;AAC9B,OAAI,CAAC,SAAS,gBACZ,OAAM,IAAI,MAAM,0BAA0B;AAa5C,UAAO,IARc,oBAAoB;IACvC,QAAQ,MAHiB,SAAS,iBAAiB;IAInD,SAAS,QAAQ;IACjB,kBAAkB,EAChB,GAAG,QAAQ,kBACZ;IACF,CAEc;;EAEjB,WAAW,SAAiC;AAC1C,UAAO,OAAO,UAAU,QAAQ;;EAEnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicClient.js","names":[],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import {\n type Account,\n blockchair,\n blockcypher,\n type Chain,\n type Client,\n createClient,\n type FallbackTransport,\n fallback,\n type HttpTransport,\n http,\n mempool,\n type PublicActions,\n publicActions,\n rpcSchema,\n type UTXOSchema,\n type WalletActions,\n walletActions,\n} from '@bigmi/core'\nimport type { SDKClient } from '@lifi/sdk'\nimport { toBigmiChainId } from '../utils/toBigmiChainId.js'\n\nexport type PublicClient = Client<\n FallbackTransport<readonly HttpTransport[]>,\n Chain,\n Account | undefined,\n UTXOSchema,\n PublicActions & WalletActions\n>\n\n// cached providers\nconst publicClients: Record<number, PublicClient> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getBitcoinPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<PublicClient> => {\n if (!publicClients[chainId]) {\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n http(url, {\n fetchOptions: {\n method: 'POST',\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n id: toBigmiChainId(_chain.id),\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n const bigmiClient = createClient({\n chain,\n rpcSchema: rpcSchema<UTXOSchema>(),\n transport: fallback([\n blockchair(),\n blockcypher(),\n mempool(),\n ...fallbackTransports,\n ]),\n pollingInterval: 10_000,\n })\n .extend(publicActions)\n .extend(walletActions)\n publicClients[chainId] = bigmiClient\n }\n\n if (!publicClients[chainId]) {\n throw new Error(`Unable to configure provider for chain ${chainId}`)\n }\n\n return publicClients[chainId]\n}\n"],"mappings":";;;AA+BA,MAAM,gBAA8C,EAAE;;;;;;;AAQtD,MAAa,yBAAyB,OACpC,QACA,YAC0B;AAC1B,KAAI,CAAC,cAAc,UAAU;EAE3B,MAAM,
|
|
1
|
+
{"version":3,"file":"publicClient.js","names":[],"sources":["../../../src/client/publicClient.ts"],"sourcesContent":["import {\n type Account,\n blockchair,\n blockcypher,\n type Chain,\n type Client,\n createClient,\n type FallbackTransport,\n fallback,\n type HttpTransport,\n http,\n mempool,\n type PublicActions,\n publicActions,\n rpcSchema,\n type UTXOSchema,\n type WalletActions,\n walletActions,\n} from '@bigmi/core'\nimport type { SDKClient } from '@lifi/sdk'\nimport { toBigmiChainId } from '../utils/toBigmiChainId.js'\n\nexport type PublicClient = Client<\n FallbackTransport<readonly HttpTransport[]>,\n Chain,\n Account | undefined,\n UTXOSchema,\n PublicActions & WalletActions\n>\n\n// cached providers\nconst publicClients: Record<number, PublicClient> = {}\n\n/**\n * Get an instance of a provider for a specific chain\n * @param client - The SDK client\n * @param chainId - Id of the chain the provider is for\n * @returns The public client for the given chain\n */\nexport const getBitcoinPublicClient = async (\n client: SDKClient,\n chainId: number\n): Promise<PublicClient> => {\n if (!publicClients[chainId]) {\n const urls = await client.getRpcUrlsByChainId(chainId)\n const fallbackTransports = urls.map((url) =>\n http(url, {\n fetchOptions: {\n method: 'POST',\n },\n })\n )\n const _chain = await client.getChainById(chainId)\n const chain: Chain = {\n ..._chain,\n ..._chain.metamask,\n id: toBigmiChainId(_chain.id),\n name: _chain.metamask.chainName,\n rpcUrls: {\n default: { http: _chain.metamask.rpcUrls },\n public: { http: _chain.metamask.rpcUrls },\n },\n }\n const bigmiClient = createClient({\n chain,\n rpcSchema: rpcSchema<UTXOSchema>(),\n transport: fallback([\n blockchair(),\n blockcypher(),\n mempool(),\n ...fallbackTransports,\n ]),\n pollingInterval: 10_000,\n })\n .extend(publicActions)\n .extend(walletActions)\n publicClients[chainId] = bigmiClient\n }\n\n if (!publicClients[chainId]) {\n throw new Error(`Unable to configure provider for chain ${chainId}`)\n }\n\n return publicClients[chainId]\n}\n"],"mappings":";;;AA+BA,MAAM,gBAA8C,EAAE;;;;;;;AAQtD,MAAa,yBAAyB,OACpC,QACA,YAC0B;AAC1B,KAAI,CAAC,cAAc,UAAU;EAE3B,MAAM,sBAAqB,MADR,OAAO,oBAAoB,QAAQ,EACtB,KAAK,QACnC,KAAK,KAAK,EACR,cAAc,EACZ,QAAQ,QACT,EACF,CAAC,CACH;EACD,MAAM,SAAS,MAAM,OAAO,aAAa,QAAQ;AAwBjD,gBAAc,WAbM,aAAa;GAC/B,OAAA;IAVA,GAAG;IACH,GAAG,OAAO;IACV,IAAI,eAAe,OAAO,GAAG;IAC7B,MAAM,OAAO,SAAS;IACtB,SAAS;KACP,SAAS,EAAE,MAAM,OAAO,SAAS,SAAS;KAC1C,QAAQ,EAAE,MAAM,OAAO,SAAS,SAAS;KAC1C;IAGI;GACL,WAAW,WAAuB;GAClC,WAAW,SAAS;IAClB,YAAY;IACZ,aAAa;IACb,SAAS;IACT,GAAG;IACJ,CAAC;GACF,iBAAiB;GAClB,CAAC,CACC,OAAO,cAAc,CACrB,OAAO,cAC0B;;AAGtC,KAAI,CAAC,cAAc,SACjB,OAAM,IAAI,MAAM,0CAA0C,UAAU;AAGtE,QAAO,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BitcoinStepExecutor.js","names":[],"sources":["../../../src/core/BitcoinStepExecutor.ts"],"sourcesContent":["import type { Client } from '@bigmi/core'\nimport {\n BaseStepExecutor,\n CheckBalanceTask,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n PrepareTransactionTask,\n type SDKError,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n WaitForTransactionStatusTask,\n} from '@lifi/sdk'\nimport { getBitcoinPublicClient } from '../client/publicClient.js'\nimport { parseBitcoinErrors } from '../errors/parseBitcoinErrors.js'\nimport type { BitcoinStepExecutorContext } from '../types.js'\nimport { BitcoinSignAndExecuteTask } from './tasks/BitcoinSignAndExecuteTask.js'\nimport { BitcoinWaitForTransactionTask } from './tasks/BitcoinWaitForTransactionTask.js'\n\ninterface BitcoinStepExecutorOptions extends StepExecutorOptions {\n client: Client\n}\n\nexport class BitcoinStepExecutor extends BaseStepExecutor {\n private client: Client\n\n constructor(options: BitcoinStepExecutorOptions) {\n super(options)\n this.client = options.client\n }\n\n checkClient = (step: LiFiStepExtended): void => {\n // TODO: check chain and possibly implement chain switch?\n // Prevent execution of the quote by wallet different from the one which requested the quote\n if (this.client.account?.address !== step.action.fromAddress) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n }\n\n override createPipeline = (\n context: BitcoinStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution } = context\n\n const tasks = [\n new CheckBalanceTask(),\n new PrepareTransactionTask(),\n new BitcoinSignAndExecuteTask(),\n new BitcoinWaitForTransactionTask(),\n new WaitForTransactionStatusTask(\n isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'\n ),\n ]\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n const taskName = swapOrBridgeAction?.txHash\n ? swapOrBridgeAction?.status === 'DONE'\n ? WaitForTransactionStatusTask.name\n : BitcoinWaitForTransactionTask.name\n : CheckBalanceTask.name\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction\n ): Promise<SDKError> => parseBitcoinErrors(error, step, action)\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<BitcoinStepExecutorContext> => {\n const { client, fromChain } = baseContext\n\n const publicClient = await getBitcoinPublicClient(client, fromChain.id)\n\n return {\n ...baseContext,\n pollingIntervalMs: 10_000,\n checkClient: this.checkClient,\n walletClient: this.client,\n publicClient,\n }\n }\n}\n"],"mappings":";;;;;;AAyBA,IAAa,sBAAb,cAAyC,iBAAiB;CACxD;CAEA,YAAY,SAAqC;AAC/C,QAAM,QAAQ;AACd,OAAK,SAAS,QAAQ;;CAGxB,eAAe,SAAiC;AAG9C,MAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,YAC/C,OAAM,IAAI,iBACR,cAAc,8BACd,oHACD;;CAIL,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAI,kBAAkB;GACtB,IAAI,wBAAwB;GAC5B,IAAI,2BAA2B;GAC/B,IAAI,+BAA+B;GACnC,IAAI,6BACF,oBAAoB,oBAAoB,OACzC;GACF;EACD,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;EAED,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7B,6BAA6B,OAC7B,8BAA8B,OAChC,iBAAiB;EAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;AAID,SAAO,IAAI,aAFQ,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"BitcoinStepExecutor.js","names":[],"sources":["../../../src/core/BitcoinStepExecutor.ts"],"sourcesContent":["import type { Client } from '@bigmi/core'\nimport {\n BaseStepExecutor,\n CheckBalanceTask,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStepExtended,\n PrepareTransactionTask,\n type SDKError,\n type StepExecutorBaseContext,\n type StepExecutorOptions,\n TaskPipeline,\n TransactionError,\n WaitForTransactionStatusTask,\n} from '@lifi/sdk'\nimport { getBitcoinPublicClient } from '../client/publicClient.js'\nimport { parseBitcoinErrors } from '../errors/parseBitcoinErrors.js'\nimport type { BitcoinStepExecutorContext } from '../types.js'\nimport { BitcoinSignAndExecuteTask } from './tasks/BitcoinSignAndExecuteTask.js'\nimport { BitcoinWaitForTransactionTask } from './tasks/BitcoinWaitForTransactionTask.js'\n\ninterface BitcoinStepExecutorOptions extends StepExecutorOptions {\n client: Client\n}\n\nexport class BitcoinStepExecutor extends BaseStepExecutor {\n private client: Client\n\n constructor(options: BitcoinStepExecutorOptions) {\n super(options)\n this.client = options.client\n }\n\n checkClient = (step: LiFiStepExtended): void => {\n // TODO: check chain and possibly implement chain switch?\n // Prevent execution of the quote by wallet different from the one which requested the quote\n if (this.client.account?.address !== step.action.fromAddress) {\n throw new TransactionError(\n LiFiErrorCode.WalletChangedDuringExecution,\n 'The wallet address that requested the quote does not match the wallet address attempting to sign the transaction.'\n )\n }\n }\n\n override createPipeline = (\n context: BitcoinStepExecutorContext\n ): TaskPipeline => {\n const { step, isBridgeExecution } = context\n\n const tasks = [\n new CheckBalanceTask(),\n new PrepareTransactionTask(),\n new BitcoinSignAndExecuteTask(),\n new BitcoinWaitForTransactionTask(),\n new WaitForTransactionStatusTask(\n isBridgeExecution ? 'RECEIVING_CHAIN' : 'SWAP'\n ),\n ]\n const swapOrBridgeAction = this.statusManager.findAction(\n step,\n isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'\n )\n\n const taskName = swapOrBridgeAction?.txHash\n ? swapOrBridgeAction?.status === 'DONE'\n ? WaitForTransactionStatusTask.name\n : BitcoinWaitForTransactionTask.name\n : CheckBalanceTask.name\n\n const firstTaskIndex = tasks.findIndex(\n (task) => task.constructor.name === taskName\n )\n\n const tasksToRun = tasks.slice(firstTaskIndex)\n\n return new TaskPipeline(tasksToRun)\n }\n\n override parseErrors = (\n error: Error,\n step?: LiFiStepExtended,\n action?: ExecutionAction\n ): Promise<SDKError> => parseBitcoinErrors(error, step, action)\n\n override createContext = async (\n baseContext: StepExecutorBaseContext\n ): Promise<BitcoinStepExecutorContext> => {\n const { client, fromChain } = baseContext\n\n const publicClient = await getBitcoinPublicClient(client, fromChain.id)\n\n return {\n ...baseContext,\n pollingIntervalMs: 10_000,\n checkClient: this.checkClient,\n walletClient: this.client,\n publicClient,\n }\n }\n}\n"],"mappings":";;;;;;AAyBA,IAAa,sBAAb,cAAyC,iBAAiB;CACxD;CAEA,YAAY,SAAqC;AAC/C,QAAM,QAAQ;AACd,OAAK,SAAS,QAAQ;;CAGxB,eAAe,SAAiC;AAG9C,MAAI,KAAK,OAAO,SAAS,YAAY,KAAK,OAAO,YAC/C,OAAM,IAAI,iBACR,cAAc,8BACd,oHACD;;CAIL,kBACE,YACiB;EACjB,MAAM,EAAE,MAAM,sBAAsB;EAEpC,MAAM,QAAQ;GACZ,IAAI,kBAAkB;GACtB,IAAI,wBAAwB;GAC5B,IAAI,2BAA2B;GAC/B,IAAI,+BAA+B;GACnC,IAAI,6BACF,oBAAoB,oBAAoB,OACzC;GACF;EACD,MAAM,qBAAqB,KAAK,cAAc,WAC5C,MACA,oBAAoB,gBAAgB,OACrC;EAED,MAAM,WAAW,oBAAoB,SACjC,oBAAoB,WAAW,SAC7B,6BAA6B,OAC7B,8BAA8B,OAChC,iBAAiB;EAErB,MAAM,iBAAiB,MAAM,WAC1B,SAAS,KAAK,YAAY,SAAS,SACrC;AAID,SAAO,IAAI,aAFQ,MAAM,MAAM,eAEG,CAAC;;CAGrC,eACE,OACA,MACA,WACsB,mBAAmB,OAAO,MAAM,OAAO;CAE/D,gBAAyB,OACvB,gBACwC;EACxC,MAAM,EAAE,QAAQ,cAAc;EAE9B,MAAM,eAAe,MAAM,uBAAuB,QAAQ,UAAU,GAAG;AAEvE,SAAO;GACL,GAAG;GACH,mBAAmB;GACnB,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB;GACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBitcoinErrors.js","names":[],"sources":["../../../src/errors/parseBitcoinErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseBitcoinErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = (e: any) => {\n // txn-mempool-conflict\n if (\n e.details?.includes?.('conflict') ||\n e.cause?.message?.includes?.('conflict')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionConflict,\n 'Your transaction conflicts with another transaction already in the mempool. One or more inputs have been spent by another transaction.',\n e\n )\n }\n if (e.code === 4001 || e.code === -32000 || e.cause?.includes?.('rejected')) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n if (e.code === -5 || e.code === -32700 || e.code === -32064) {\n return new TransactionError(LiFiErrorCode.NotFound, e.message, e)\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;AAWA,MAAa,qBAAqB,OAChC,GACA,MACA,WACsB;AACtB,KAAI,aAAa,UAAU;AACzB,IAAE,OAAO,EAAE,QAAQ;AACnB,IAAE,SAAS,EAAE,UAAU;AACvB,SAAO;;AAKT,QAAO,IAAI,SAFO,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"parseBitcoinErrors.js","names":[],"sources":["../../../src/errors/parseBitcoinErrors.ts"],"sourcesContent":["import {\n BaseError,\n ErrorMessage,\n type ExecutionAction,\n LiFiErrorCode,\n type LiFiStep,\n SDKError,\n TransactionError,\n UnknownError,\n} from '@lifi/sdk'\n\nexport const parseBitcoinErrors = async (\n e: Error,\n step?: LiFiStep,\n action?: ExecutionAction\n): Promise<SDKError> => {\n if (e instanceof SDKError) {\n e.step = e.step ?? step\n e.action = e.action ?? action\n return e\n }\n\n const baseError = handleSpecificErrors(e)\n\n return new SDKError(baseError, step, action)\n}\n\nconst handleSpecificErrors = (e: any) => {\n // txn-mempool-conflict\n if (\n e.details?.includes?.('conflict') ||\n e.cause?.message?.includes?.('conflict')\n ) {\n return new TransactionError(\n LiFiErrorCode.TransactionConflict,\n 'Your transaction conflicts with another transaction already in the mempool. One or more inputs have been spent by another transaction.',\n e\n )\n }\n if (e.code === 4001 || e.code === -32000 || e.cause?.includes?.('rejected')) {\n return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)\n }\n if (e.code === -5 || e.code === -32700 || e.code === -32064) {\n return new TransactionError(LiFiErrorCode.NotFound, e.message, e)\n }\n\n if (e instanceof BaseError) {\n return e\n }\n\n return new UnknownError(e.message || ErrorMessage.UnknownError, e)\n}\n"],"mappings":";;AAWA,MAAa,qBAAqB,OAChC,GACA,MACA,WACsB;AACtB,KAAI,aAAa,UAAU;AACzB,IAAE,OAAO,EAAE,QAAQ;AACnB,IAAE,SAAS,EAAE,UAAU;AACvB,SAAO;;AAKT,QAAO,IAAI,SAFO,qBAAqB,EAEV,EAAE,MAAM,OAAO;;AAG9C,MAAM,wBAAwB,MAAW;AAEvC,KACE,EAAE,SAAS,WAAW,WAAW,IACjC,EAAE,OAAO,SAAS,WAAW,WAAW,CAExC,QAAO,IAAI,iBACT,cAAc,qBACd,0IACA,EACD;AAEH,KAAI,EAAE,SAAS,QAAQ,EAAE,SAAS,SAAU,EAAE,OAAO,WAAW,WAAW,CACzE,QAAO,IAAI,iBAAiB,cAAc,mBAAmB,EAAE,SAAS,EAAE;AAE5E,KAAI,EAAE,SAAS,MAAM,EAAE,SAAS,UAAU,EAAE,SAAS,OACnD,QAAO,IAAI,iBAAiB,cAAc,UAAU,EAAE,SAAS,EAAE;AAGnE,KAAI,aAAa,UACf,QAAO;AAGT,QAAO,IAAI,aAAa,EAAE,WAAW,aAAa,cAAc,EAAE"}
|
package/dist/esm/version.d.ts
CHANGED
package/dist/esm/version.js
CHANGED
package/dist/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-bitcoin'\nexport const version = '4.0.0-beta.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../../src/version.ts"],"sourcesContent":["export const name = '@lifi/sdk-provider-bitcoin'\nexport const version = '4.0.0-beta.8'\n"],"mappings":";AAAA,MAAa,OAAO;AACpB,MAAa,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/sdk-provider-bitcoin",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.8",
|
|
4
4
|
"description": "LI.FI Bitcoin SDK Provider for Any-to-Any Cross-Chain-Swap",
|
|
5
5
|
"homepage": "https://github.com/lifinance/sdk",
|
|
6
6
|
"bugs": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@bitcoinerlab/secp256k1": "^1.2.0",
|
|
33
33
|
"bech32": "^2.0.0",
|
|
34
34
|
"bitcoinjs-lib": "^7.0.1",
|
|
35
|
-
"@lifi/sdk": "4.0.0-beta.
|
|
35
|
+
"@lifi/sdk": "4.0.0-beta.8"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk-provider-bitcoin'
|
|
2
|
-
export const version = '4.0.0-beta.
|
|
2
|
+
export const version = '4.0.0-beta.8'
|