import { playgroundHelper } from "../helpers/helpers"; import { MPCSignature } from "chainsig.js"; import { actionCreators, createTransaction, Signature, SignedTransaction, } from "@near-js/transactions"; import { baseDecode } from "@near-js/utils"; import { Account } from "@near-js/accounts"; import { KeyType, PublicKey } from "@near-js/crypto"; const block = await playgroundHelper.provider.block({ finality: "near-final", }); const derivedAccount = new Account( playgroundHelper.vaultContractId, playgroundHelper.provider ); const allKeys = await derivedAccount.getAccessKeyList(); const matchingKey = allKeys.keys.find( (e) => e.public_key === playgroundHelper.vaultPublicKey.toString() ); if (!matchingKey) { throw new Error("Key not found"); } const transaction = createTransaction( playgroundHelper.vaultContractId, playgroundHelper.vaultPublicKey, "guest-book.testnet", BigInt(matchingKey.access_key.nonce) + 1n, [ actionCreators.functionCall( "addMessage", { text: "coming from chain sig", }, 30000000000000n, 0n ), ], baseDecode(block.header.hash) ); const encodedTx = Buffer.from(transaction.encode()).toString("base64"); await playgroundHelper.account.callFunction({ contractId: playgroundHelper.vaultContractId, methodName: "propose_execution", args: { policy_id: "guestbook_testnet_near_native_add_msg", function_args: encodedTx, deadline_hours: 0, }, gas: 60000000000000n }); console.log("DONE")