Skip to content

Commit

Permalink
Remove transfer from IcrcTransferParams (#3324)
Browse files Browse the repository at this point in the history
# Motivation

The type `IcrcTransferParams` is defined as
```
export interface IcrcTransferParams {
  to: IcrcAccount;
  amount: bigint;
  memo?: Uint8Array;
  fromSubAccount?: SubAccountArray;
  createdAt?: bigint;
  fee: bigint;
  transfer: (params: TransferParams) => Promise<IcrcBlockIndex>;
}
```

The field `transfer` is only used by `executeIcrcTransfer` and every
other place where `IcrcTransferParams` is used, it's used as
`Omit<IcrcTransferParams, "transfer">`.

# Changes

Remove `transfer` from `IcrcTransferParams` and at it back only to the
params of `executeIcrcTransfer`.

# Tests

`npm run build`
`npm run check`
`npm run test`

All still pass.

# Todos

- [ ] Add entry to changelog (if necessary).
not necessary
  • Loading branch information
dskloetd authored Sep 18, 2023
1 parent bc0a5a7 commit 72c9748
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions frontend/src/lib/api/icrc-ledger.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export interface IcrcTransferParams {
fromSubAccount?: SubAccountArray;
createdAt?: bigint;
fee: bigint;
transfer: (params: TransferParams) => Promise<IcrcBlockIndex>;
}

export const icrcTransfer = async ({
Expand All @@ -91,7 +90,7 @@ export const icrcTransfer = async ({
}: {
identity: Identity;
canisterId: Principal;
} & Omit<IcrcTransferParams, "transfer">): Promise<IcrcBlockIndex> => {
} & IcrcTransferParams): Promise<IcrcBlockIndex> => {
logWithTimestamp("Getting ckBTC transfer: call...");

const {
Expand Down Expand Up @@ -122,7 +121,9 @@ export const executeIcrcTransfer = async ({
createdAt,
transfer: transferApi,
...rest
}: IcrcTransferParams): Promise<IcrcBlockIndex> =>
}: IcrcTransferParams & {
transfer: (params: TransferParams) => Promise<IcrcBlockIndex>;
}): Promise<IcrcBlockIndex> =>
transferApi({
to: {
owner,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/api/sns-ledger.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const snsTransfer = async ({
}: {
identity: Identity;
rootCanisterId: Principal;
} & Omit<IcrcTransferParams, "transfer">): Promise<IcrcBlockIndex> => {
} & IcrcTransferParams): Promise<IcrcBlockIndex> => {
logWithTimestamp("Getting Sns transfer: call...");

const { transfer: transferApi } = await wrapper({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/services/ckbtc-accounts.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const ckBTCTransferTokens = async ({
transfer: async (
params: {
identity: Identity;
} & Omit<IcrcTransferParams, "transfer">
} & IcrcTransferParams
) =>
await icrcTransfer({
...params,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/services/icrc-accounts.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const transferTokens = async ({
transfer: (
params: {
identity: Identity;
} & Omit<IcrcTransferParams, "transfer">
} & IcrcTransferParams
) => Promise<IcrcBlockIndex>;
reloadAccounts: () => Promise<void>;
reloadTransactions: () => Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/services/sns-accounts.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const snsTransferTokens = async ({
transfer: async (
params: {
identity: Identity;
} & Omit<IcrcTransferParams, "transfer">
} & IcrcTransferParams
) =>
await snsTransfer({
...params,
Expand Down

0 comments on commit 72c9748

Please sign in to comment.