Skip to content

Commit

Permalink
fix: foreign asset transfer now works (#2844)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnthecat authored Dec 11, 2024
1 parent ce34409 commit 5c1f316
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/renderer/entities/transaction/lib/extrinsicService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
defineMethod,
methods,
} from '@substrate/txwrapper-polkadot';
import sortBy from 'lodash/sortBy';
import { sortBy, zipWith } from 'lodash';

import { type MultisigTxWrapper, type ProxyTxWrapper, type Transaction, TransactionType } from '@/shared/core';
import { toAddress } from '@/shared/lib/utils';
Expand Down Expand Up @@ -61,13 +61,23 @@ export const getUnsignedTransaction: Record<
options,
);
},
[TransactionType.ASSET_TRANSFER]: (transaction, info, options) => {
[TransactionType.ASSET_TRANSFER]: (transaction, info, options, api) => {
const palletName = transaction.args.palletName ?? 'assets';
const methodArgs = api.tx[palletName].transfer.meta.args;
const rawArgs = [transaction.args.asset, transaction.args.target, transaction.args.amount];
const args = zipWith(methodArgs, rawArgs, (method, arg) => {
return [method.name.toString(), api.createType(method.type.toString(), arg)] as const;
});

const argsMap = Object.fromEntries(args);

return defineMethod(
{
method: {
name: 'transfer',
pallet: transaction.args.palletName ?? 'assets',
args: transaction.args,
// @ts-expect-error defineMethod type disallow Codec type
args: argsMap,
},
...info,
},
Expand Down

0 comments on commit 5c1f316

Please sign in to comment.