Skip to content

Commit

Permalink
fix to use transfer-create
Browse files Browse the repository at this point in the history
  • Loading branch information
Takadenoshi committed Mar 25, 2024
1 parent 965fc03 commit cd161a9
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions packages/extension/src/providers/kadena/types/kda-token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { BaseToken, BaseTokenOptions } from "@/types/base-token";
import KadenaAPI from "@/providers/kadena/libs/api";
import { ChainId, ICommand, Pact, addSignatures } from "@kadena/client";
import {
ChainId,
ICommand,
Pact,
addSignatures,
readKeyset,
} from "@kadena/client";
import { EnkryptAccount } from "@enkryptcom/types";
import { blake2AsU8a } from "@polkadot/util-crypto";
import { KadenaNetwork } from "./kadena-network";
Expand Down Expand Up @@ -51,20 +57,23 @@ export class KDAToken extends KDABaseToken {
network: KadenaNetwork
): Promise<ICommand> {
to = network.displayAddress(to);
const toKey = to.replace("k:", "");
const accountDetails = await this.getAccountDetails(to, network);
const api = (await network.api()) as KadenaAPI;
const chainID = await api.getChainId();
const keySetAccount = to.startsWith("k:") ? to.replace("k:", "") : to;
const unsignedTransaction = Pact.builder
.execution(
Pact.modules.coin.transfer(network.displayAddress(from.address), to, {
decimal: amount,
})
Pact.modules.coin["transfer-create"](
network.displayAddress(from.address),
to,
readKeyset("ks"),
{
decimal: amount,
}
)
)
.addData("ks", {
keys: accountDetails.data?.guard.keys || [keySetAccount],
pred: accountDetails.data?.guard.pred || "keys-all",
})
.addKeyset("ks", "keys-all", toKey)
.addSigner(from.publicKey.replace("0x", ""), (withCap: any) => [
withCap("coin.TRANSFER", network.displayAddress(from.address), to, {
decimal: amount,
Expand Down

0 comments on commit cd161a9

Please sign in to comment.