File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1- import { nonNullish } from '@dfinity/utils' ;
1+ import { nonNullish , toNullable } from '@dfinity/utils' ;
2+ import { decodeIcrcAccount } from '@icp-sdk/canisters/ledger/icrc' ;
23import { AnonymousIdentity } from '@icp-sdk/core/agent' ;
3- import { Principal } from '@icp-sdk/core/principal' ;
44import { createAgent } from '../../api/agent.api' ;
55import { ICP_LEDGER_CANISTER_ID } from '../../modules/icp-ledger' ;
66import type { CliContext } from '../../types/context' ;
@@ -29,9 +29,11 @@ export const transfer = async ({
2929 const to = searchParams . get ( 'to' ) ?? '' ;
3030 const amount = searchParams . get ( 'amount' ) ;
3131
32+ const { owner, subaccount} = decodeIcrcAccount ( to ) ;
33+
3234 await icrc1_transfer ( {
3335 amount : nonNullish ( amount ) ? BigInt ( amount ) : 5_500_010_000n ,
34- to : { owner : Principal . fromText ( to ) , subaccount : [ ] } ,
36+ to : { owner, subaccount : toNullable ( subaccount ) } ,
3537 fee : [ ] ,
3638 memo : [ ] ,
3739 from_subaccount : [ ] ,
You can’t perform that action at this time.
0 commit comments