Skip to content

Commit

Permalink
chore: sync main
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Oct 2, 2023
1 parent ea3843f commit 6f8b7aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
36 changes: 18 additions & 18 deletions packages/ledger-icp/src/ledger.canister.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,22 +651,22 @@ describe("LedgerCanister", () => {
Ok: BigInt(1234),
});
const fee = BigInt(10_000);
const memo = new Uint8Array([3, 4, 5, 6]);
const icrc1Memo = new Uint8Array([3, 4, 5, 6]);
const ledger = LedgerCanister.create({
certifiedServiceOverride: service,
});
await ledger.icrc1Transfer({
to,
amount,
fee,
memo,
icrc1Memo,
});

expect(service.icrc1_transfer).toBeCalledWith({
to,
fee: [fee],
amount,
memo: [memo],
memo: [icrc1Memo],
created_at_time: [],
from_subaccount: [],
});
Expand Down Expand Up @@ -703,7 +703,7 @@ describe("LedgerCanister", () => {
Ok: BigInt(1234),
});
const fee = BigInt(10_000);
const memo = new Uint8Array([3, 4, 5, 6]);
const icrc1Memo = new Uint8Array([3, 4, 5, 6]);
const ledger = LedgerCanister.create({
certifiedServiceOverride: service,
});
Expand All @@ -712,15 +712,15 @@ describe("LedgerCanister", () => {
to,
amount,
fee,
memo,
icrc1Memo,
createdAt,
});

expect(service.icrc1_transfer).toBeCalledWith({
to,
fee: [fee],
amount,
memo: [memo],
memo: [icrc1Memo],
created_at_time: [createdAt],
from_subaccount: [],
});
Expand All @@ -732,7 +732,7 @@ describe("LedgerCanister", () => {
Ok: BigInt(1234),
});
const fee = BigInt(10_000);
const memo = new Uint8Array();
const icrc1Memo = new Uint8Array();
const fromSubAccount = new Uint8Array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1,
Expand All @@ -744,15 +744,15 @@ describe("LedgerCanister", () => {
to,
amount,
fee,
memo,
icrc1Memo,
fromSubAccount,
});

expect(service.icrc1_transfer).toBeCalledWith({
to,
fee: [fee],
amount,
memo: [memo],
memo: [icrc1Memo],
created_at_time: [],
from_subaccount: [fromSubAccount],
});
Expand All @@ -764,7 +764,7 @@ describe("LedgerCanister", () => {
Ok: BigInt(1234),
});
const fee = BigInt(10_000);
const memo = new Uint8Array();
const icrc1Memo = new Uint8Array();
const toSubAccount = new Uint8Array([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1,
Expand All @@ -779,7 +779,7 @@ describe("LedgerCanister", () => {
},
amount,
fee,
memo,
icrc1Memo,
});

expect(service.icrc1_transfer).toBeCalledWith({
Expand All @@ -789,7 +789,7 @@ describe("LedgerCanister", () => {
},
fee: [fee],
amount,
memo: [memo],
memo: [icrc1Memo],
created_at_time: [],
from_subaccount: [],
});
Expand Down Expand Up @@ -925,11 +925,11 @@ describe("LedgerCanister", () => {
hardwareWallet: true,
});

const memo = new Uint8Array();
const icrc1Memo = new Uint8Array();
await ledger.icrc1Transfer({
to,
amount,
memo,
icrc1Memo,
});

expect(service.transfer_fee).not.toBeCalled();
Expand All @@ -938,7 +938,7 @@ describe("LedgerCanister", () => {
to,
fee: [BigInt(10000)],
amount,
memo: [memo],
memo: [icrc1Memo],
created_at_time: [],
from_subaccount: [],
});
Expand All @@ -956,12 +956,12 @@ describe("LedgerCanister", () => {
});

const fee = BigInt(990_000);
const memo = new Uint8Array();
const icrc1Memo = new Uint8Array();
await ledger.icrc1Transfer({
to,
amount,
fee,
memo,
icrc1Memo,
});

expect(service.transfer_fee).not.toBeCalled();
Expand All @@ -970,7 +970,7 @@ describe("LedgerCanister", () => {
to,
fee: [fee],
amount,
memo: [memo],
memo: [icrc1Memo],
created_at_time: [],
from_subaccount: [],
});
Expand Down
5 changes: 5 additions & 0 deletions packages/ledger-icp/src/ledger.canister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ export class LedgerCanister {
return response.Ok;
};

// WARNING: When using the ICRC-1 interface of the ICP ledger, there is no
// relationship between the memo and the icrc1Memo of a transaction. The
// ICRC-1 interface simply cannot set the memo field and the non-ICRC-1
// interface cannot set the icrc1Memo field, even though the icrc1Memo field
// is called just "memo" in canister method params.
/**
* Transfer ICP from the caller to the destination `Account`.
* Returns the index of the block containing the tx if it was successful.
Expand Down

0 comments on commit 6f8b7aa

Please sign in to comment.