Skip to content

Commit

Permalink
feat: fixes type errors and updates tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andreicovaciu committed May 14, 2024
1 parent 2d30eef commit ba5b985
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 14 additions & 4 deletions lib/src/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,27 @@ const accounts: Array<Partial<Account>> = [
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
.spyOn(ExchangeModule.prototype, "startSell")
.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 = {
Expand All @@ -57,7 +67,7 @@ const mockedTransport = {
const walletApiClient = new WalletAPIClient(
mockedTransport,
defaultLogger,
getCustomModule
getCustomModule,
);
const sdk = new ExchangeSDK("provider-id", mockedTransport, walletApiClient);

Expand Down
11 changes: 7 additions & 4 deletions lib/src/wallet-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -62,6 +62,8 @@ const transactionStrategy: {
tezos: modeSendTransaction,
tron: defaultTransaction,
vechain: defaultTransaction,
casper: defaultTransaction,
internet_computer: defaultTransaction,
};

type StartType = InstanceType<typeof WalletAPIClient>["exchange"]["start"];
Expand Down Expand Up @@ -90,7 +92,7 @@ export type WalletApiDecorator = {
};

export default function walletApiDecorator(
walletAPIClient: WalletAPIClient
walletAPIClient: WalletAPIClient,
): WalletApiDecorator {
const walletAPI = walletAPIClient;

Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ba5b985

Please sign in to comment.