diff --git a/packages/ledger-icp/src/ledger.canister.spec.ts b/packages/ledger-icp/src/ledger.canister.spec.ts index 65bb98fd7..79ad5e3ed 100644 --- a/packages/ledger-icp/src/ledger.canister.spec.ts +++ b/packages/ledger-icp/src/ledger.canister.spec.ts @@ -651,7 +651,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, }); @@ -659,14 +659,14 @@ describe("LedgerCanister", () => { to, amount, fee, - memo, + icrc1Memo, }); expect(service.icrc1_transfer).toBeCalledWith({ to, fee: [fee], amount, - memo: [memo], + memo: [icrc1Memo], created_at_time: [], from_subaccount: [], }); @@ -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, }); @@ -712,7 +712,7 @@ describe("LedgerCanister", () => { to, amount, fee, - memo, + icrc1Memo, createdAt, }); @@ -720,7 +720,7 @@ describe("LedgerCanister", () => { to, fee: [fee], amount, - memo: [memo], + memo: [icrc1Memo], created_at_time: [createdAt], from_subaccount: [], }); @@ -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, @@ -744,7 +744,7 @@ describe("LedgerCanister", () => { to, amount, fee, - memo, + icrc1Memo, fromSubAccount, }); @@ -752,7 +752,7 @@ describe("LedgerCanister", () => { to, fee: [fee], amount, - memo: [memo], + memo: [icrc1Memo], created_at_time: [], from_subaccount: [fromSubAccount], }); @@ -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, @@ -779,7 +779,7 @@ describe("LedgerCanister", () => { }, amount, fee, - memo, + icrc1Memo, }); expect(service.icrc1_transfer).toBeCalledWith({ @@ -789,7 +789,7 @@ describe("LedgerCanister", () => { }, fee: [fee], amount, - memo: [memo], + memo: [icrc1Memo], created_at_time: [], from_subaccount: [], }); @@ -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(); @@ -938,7 +938,7 @@ describe("LedgerCanister", () => { to, fee: [BigInt(10000)], amount, - memo: [memo], + memo: [icrc1Memo], created_at_time: [], from_subaccount: [], }); @@ -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(); @@ -970,7 +970,7 @@ describe("LedgerCanister", () => { to, fee: [fee], amount, - memo: [memo], + memo: [icrc1Memo], created_at_time: [], from_subaccount: [], }); diff --git a/packages/ledger-icp/src/ledger.canister.ts b/packages/ledger-icp/src/ledger.canister.ts index 095352d9e..6a9f3e752 100644 --- a/packages/ledger-icp/src/ledger.canister.ts +++ b/packages/ledger-icp/src/ledger.canister.ts @@ -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.