diff --git a/lib/package.json b/lib/package.json index 2b9ec5b..13e1542 100644 --- a/lib/package.json +++ b/lib/package.json @@ -15,7 +15,7 @@ "axios": "^1.3.4" }, "devDependencies": { - "@ledgerhq/wallet-api-client": "^1.5.7", + "@ledgerhq/wallet-api-client": "^1.5.9", "@ledgerhq/wallet-api-exchange-module": "0.6.0-nightly.2", "@rollup/plugin-commonjs": "^25.0.4", "@rollup/plugin-node-resolve": "^15.2.1", diff --git a/lib/src/sdk.test.ts b/lib/src/sdk.test.ts index 6bbdd47..4253152 100644 --- a/lib/src/sdk.test.ts +++ b/lib/src/sdk.test.ts @@ -37,6 +37,11 @@ const accounts: Array> = [ spendableBalance: new BigNumber(100000000), }, ]; + +const device = { + modelId: "nanoX", + deviceId: "device-id", +}; const mockAccountList = jest.spyOn(AccountModule.prototype, "list"); const mockCurrenciesList = jest.spyOn(CurrencyModule.prototype, "list"); const mockStartExchange = jest @@ -44,10 +49,15 @@ const mockStartExchange = jest .mockResolvedValue("DeviceTransactionId"); const mockStartSwapExchange = jest .spyOn(ExchangeModule.prototype, "startSwap") - .mockResolvedValue("DeviceTransactionId"); -const mockCompleteSwap = jest.spyOn(ExchangeModule.prototype, "completeSwap") + .mockResolvedValue({ + device, + transactionId: "DeviceTransactionId", + }); +const mockCompleteSwap = jest + .spyOn(ExchangeModule.prototype, "completeSwap") .mockResolvedValue("TransactionId"); -const mockCompleteSell = jest.spyOn(ExchangeModule.prototype, "completeSell") +const mockCompleteSell = jest + .spyOn(ExchangeModule.prototype, "completeSell") .mockResolvedValue("TransactionId"); const mockedTransport = { @@ -57,7 +67,7 @@ const mockedTransport = { const walletApiClient = new WalletAPIClient( mockedTransport, defaultLogger, - getCustomModule + getCustomModule, ); const sdk = new ExchangeSDK("provider-id", mockedTransport, walletApiClient); diff --git a/lib/src/wallet-api.ts b/lib/src/wallet-api.ts index d62e9a3..0dcca4c 100644 --- a/lib/src/wallet-api.ts +++ b/lib/src/wallet-api.ts @@ -36,7 +36,7 @@ type TransactionWithCustomFee = TransactionCommon & { // Define a specific type for the strategy functions, assuming they might need parameters type TransactionStrategyFunction = ( - params: TransactionWithCustomFee + params: TransactionWithCustomFee, ) => Transaction; const transactionStrategy: { @@ -62,6 +62,8 @@ const transactionStrategy: { tezos: modeSendTransaction, tron: defaultTransaction, vechain: defaultTransaction, + casper: defaultTransaction, + internet_computer: defaultTransaction, }; type StartType = InstanceType["exchange"]["start"]; @@ -90,7 +92,7 @@ export type WalletApiDecorator = { }; export default function walletApiDecorator( - walletAPIClient: WalletAPIClient + walletAPIClient: WalletAPIClient, ): WalletApiDecorator { const walletAPI = walletAPIClient; @@ -140,9 +142,10 @@ export default function walletApiDecorator( currencyIds: [currency.parent], }); - family = (currencies[0] as CryptoCurrency).family; + family = (currencies[0] as CryptoCurrency) + .family as Transaction["family"]; } else { - family = currency.family; + family = currency.family as Transaction["family"]; } // TODO: remove next line when wallet-api support btc utxoStrategy diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd5a8b6..6d044c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,8 +138,8 @@ importers: version: 1.3.4 devDependencies: '@ledgerhq/wallet-api-client': - specifier: ^1.5.7 - version: 1.5.7 + specifier: ^1.5.9 + version: 1.5.9 '@ledgerhq/wallet-api-exchange-module': specifier: 0.6.0-nightly.2 version: 0.6.0-nightly.2 @@ -1101,6 +1101,7 @@ packages: '@ledgerhq/hw-transport': 6.30.5 '@ledgerhq/wallet-api-core': 1.9.0 bignumber.js: 9.1.2 + dev: false /@ledgerhq/wallet-api-client@1.5.9: resolution: {integrity: sha512-q95okG1R2mDIJc1n7lw06GDWpJmQIDdTrBUxxeeRzzcdEp1ZaVitS8O6tuHfE/Rva88iKhaT7ZMpkaZ3VELKBQ==} @@ -1135,6 +1136,7 @@ packages: bignumber.js: 9.1.2 uuid: 9.0.1 zod: 3.22.4 + dev: false /@ledgerhq/wallet-api-exchange-module@0.5.0-nightly.3: resolution: {integrity: sha512-Gpd+jU/og0Bx+WNou/eWbw0vw3Ra3wwvw5gYMT4zkuKhlW1Y4Xcb18VbRuHjw4boRsK6J14P2H9hOFOIrnE0iQ==}