Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metadata/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@utxostack/metadata",
"version": "0.0.2",
"version": "0.0.3",
"description": "Encode and decode token information and metadata for UDT assets on Nervos CKB",
"scripts": {
"test": "vitest",
Expand Down
8 changes: 8 additions & 0 deletions metadata/src/token-info.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ describe('encode and decode token info', () => {
};
const actual = encodeTokenInfo(token);
expect(actual).toBe('0x0807426974636f696e0342544301000000100000000040075af07507000000000000000000');

const token2: TokenInfo = {
decimal: 8,
name: 'Bitcoin Fork',
symbol: 'BTCF',
};
const actualData = encodeTokenInfo(token2);
expect(actualData).toBe('0x080c426974636f696e20466f726b04425443460100000010000000');
});

it('decodeTokenInfo', () => {
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/token-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const encodeTokenInfo = (tokenInfo: TokenInfo): string => {
const symbolHex = utf8ToHex(symbol);
const symbolLen = u8ToHex(symbolHex.length / 2);
// total supply with u128
const tagTotalSupply = `${u32ToLe(TAG_TOTAL_SUPPLY)}${u32ToLe(16)}${u128ToLe(totalSupply)}`;
const tagTotalSupply = `${u32ToLe(TAG_TOTAL_SUPPLY)}${u32ToLe(16)}${totalSupply ? u128ToLe(totalSupply) : ''}`;
return `0x${u8ToHex(decimal)}${nameLen}${nameHex}${symbolLen}${symbolHex}${tagTotalSupply}`;
};

Expand Down
2 changes: 1 addition & 1 deletion metadata/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export interface TokenInfo {
decimal: number;
name: string;
symbol: string;
totalSupply: bigint;
totalSupply?: bigint;
}
Loading