Skip to content

Commit

Permalink
feat: token symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Dec 23, 2024
1 parent ff5e86d commit c81046e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/builders/signer.builders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('Signer builders', () => {
expect(message).toEqual(`# Approve the transfer of funds
**Amount:**
0.05
0.05 TKN
**From:**
${mockPrincipalText}
Expand All @@ -60,7 +60,7 @@ ${mockPrincipalText}
s3oqv-3j7id-xjhbm-3owbe-fvwly-oso6u-vej6n-bexck-koyu2-bxb6y-wae
**Fee:**
0.0001`);
0.0001 TKN`);
});

it('should build a consent message with a from subaccount', async () => {
Expand Down Expand Up @@ -88,7 +88,7 @@ s3oqv-3j7id-xjhbm-3owbe-fvwly-oso6u-vej6n-bexck-koyu2-bxb6y-wae
expect(message).toEqual(`# Approve the transfer of funds
**Amount:**
3,200.00000001
3,200.00000001 TKN
**From subaccount:**
${encodeIcrcAccount({owner: owner.getPrincipal(), subaccount: subaccount})}
Expand All @@ -97,7 +97,7 @@ ${encodeIcrcAccount({owner: owner.getPrincipal(), subaccount: subaccount})}
${encodeIcrcAccount({owner: rawArgs.to.owner, subaccount: fromNullable(rawArgs.to.subaccount)})}
**Fee:**
0.0010033`);
0.0010033 TKN`);
});

it('should build a consent message with a to subaccount', async () => {
Expand Down Expand Up @@ -128,7 +128,7 @@ ${encodeIcrcAccount({owner: rawArgs.to.owner, subaccount: fromNullable(rawArgs.t
expect(message).toEqual(`# Approve the transfer of funds
**Amount:**
3,200.00000001
3,200.00000001 TKN
**From:**
${encodeIcrcAccount({owner: owner.getPrincipal()})}
Expand All @@ -137,7 +137,7 @@ ${encodeIcrcAccount({owner: owner.getPrincipal()})}
${encodeIcrcAccount({owner: rawArgs.to.owner, subaccount})}
**Fee:**
0.0010033`);
0.0010033 TKN`);
});

it('should build a consent message with a memo', async () => {
Expand Down Expand Up @@ -165,7 +165,7 @@ ${encodeIcrcAccount({owner: rawArgs.to.owner, subaccount})}
expect(message).toEqual(`# Approve the transfer of funds
**Amount:**
3,200.00000001
3,200.00000001 TKN
**From:**
${encodeIcrcAccount({owner: owner.getPrincipal()})}
Expand All @@ -174,7 +174,7 @@ ${encodeIcrcAccount({owner: owner.getPrincipal()})}
${encodeIcrcAccount({owner: rawArgs.to.owner, subaccount: fromNullable(rawArgs.to.subaccount)})}
**Fee:**
0.0010033
0.0010033 TKN
**Memo:**
0x50555054`);
Expand Down Expand Up @@ -218,7 +218,7 @@ ${encodeIcrcAccount({owner: rawArgs.to.owner, subaccount: fromNullable(rawArgs.t
expect(message).toEqual(`# Approve the transfer of funds
**Amount:**
3,200.00000001
3,200.00000001 TKN
**From:**
${encodeIcrcAccount({owner: owner.getPrincipal()})}
Expand All @@ -227,7 +227,7 @@ ${encodeIcrcAccount({owner: owner.getPrincipal()})}
${encodeIcrcAccount({owner: rawArgs.to.owner, subaccount: fromNullable(rawArgs.to.subaccount)})}
**Fee:**
0.0001`);
0.0001 TKN`);
});
});
});
8 changes: 5 additions & 3 deletions src/builders/signer.builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {decodeIdl} from '../utils/idl.utils';
export const buildContentMessageIcrc1Transfer = async ({
arg,
owner,
token: {name: tokenName, decimals: tokenDecimals, fee: tokenFee}
token: {symbol: tokenSymbol, decimals: tokenDecimals, fee: tokenFee}
}: {
arg: ArrayBuffer;
owner: Principal;
Expand Down Expand Up @@ -47,7 +47,9 @@ export const buildContentMessageIcrc1Transfer = async ({
const section = (text: string): string => `**${text}:**`;

// - Amount
message.push(`${section(amountLabel)}\n${formatAmount({amount, decimals: tokenDecimals})}`);
message.push(
`${section(amountLabel)}\n${formatAmount({amount, decimals: tokenDecimals})} ${tokenSymbol}`
);

// - From
const fromNullishSubaccount = fromNullable(fromSubaccount);
Expand All @@ -68,7 +70,7 @@ export const buildContentMessageIcrc1Transfer = async ({

// - Fee
message.push(
`${section(feeLabel)}\n${formatAmount({amount: fromNullable(fee) ?? tokenFee, decimals: tokenDecimals})}`
`${section(feeLabel)}\n${formatAmount({amount: fromNullable(fee) ?? tokenFee, decimals: tokenDecimals})} ${tokenSymbol}`
);

// - Memo
Expand Down

0 comments on commit c81046e

Please sign in to comment.