Skip to content

Commit

Permalink
Merge pull request #421 from Takadenoshi/fix/create-transfer-with-pac…
Browse files Browse the repository at this point in the history
…t-modules

Fix/create transfer with pact modules
  • Loading branch information
kvhnuke authored Apr 1, 2024
2 parents bcdb319 + 018a705 commit 2667c22
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 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 @@ -57,16 +63,16 @@ export class KDAToken extends KDABaseToken {
const keySetAccount = to.startsWith("k:") ? to.replace("k:", "") : to;
const unsignedTransaction = Pact.builder
.execution(
`(coin.transfer-create "${network.displayAddress(
from.address
)}" "${to}" (read-keyset "ks") ${parseFloat(amount).toFixed(
network.options.decimals
)})`
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", keySetAccount)
.addSigner(from.publicKey.replace("0x", ""), (withCap: any) => [
withCap("coin.TRANSFER", network.displayAddress(from.address), to, {
decimal: amount,
Expand Down

1 comment on commit 2667c22

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.