Skip to content

Commit

Permalink
feat(near): migrate to walletconnect for signing
Browse files Browse the repository at this point in the history
  • Loading branch information
imsk17 committed Oct 22, 2024
1 parent 470ea24 commit 2e14076
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/handlers/near/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export async function nearHandler({
getStorageContract() {
return storage;
},
async mintNft(signer, ma, gasArgs) {
async mintNft(connection, ma, gasArgs) {
const signer = connection.account();
const call = await signer.functionCall({
contractId: ma.contract,
methodName: "nft_mint",
Expand Down Expand Up @@ -139,7 +140,8 @@ export async function nearHandler({
lock_tx_chain: input.lockTxChain,
};
},
async approveNft(signer, tokenId, contract) {
async approveNft(connection, tokenId, contract) {
const signer = connection.account();
const approve = await signer.functionCall({
contractId: contract,
methodName: "nft_approve",
Expand Down Expand Up @@ -184,13 +186,14 @@ export async function nearHandler({
};
},
async lockNft(
signer,
connection,
sourceNft,
destinationChain,
to,
tokenId,
metadata_uri,
) {
const signer = connection.account();
const locked = await signer.functionCall({
contractId: bridge,
methodName: "lock_nft",
Expand All @@ -211,7 +214,8 @@ export async function nearHandler({
},
};
},
async claimNft(signer, claimData, sig) {
async claimNft(connection, claimData, sig) {
const signer = connection.account();
const claimed = await signer.functionCall({
contractId: bridge,
methodName: "claim_nft",
Expand All @@ -228,7 +232,8 @@ export async function nearHandler({
});
return { hash: () => claimed.transaction.hash, ret: claimed };
},
async getBalance(signer, _) {
async getBalance(connection, _) {
const signer = connection.account();
const ab = await signer.getAccountBalance();
return BigInt(ab.available);
},
Expand Down
13 changes: 9 additions & 4 deletions src/handlers/near/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, Near } from "near-api-js";
import { Near, WalletConnection } from "near-api-js";
import { FinalExecutionOutcome } from "near-api-js/lib/providers";
import { BridgeStorage } from "../../contractsTypes/evm";
import {
Expand Down Expand Up @@ -40,15 +40,20 @@ export type NftIssueArgs = {
};

export type TNearHandler = TSingularNftChain<
Account,
WalletConnection,
TNearClaimArgs,
unknown,
FinalExecutionOutcome,
Near
> &
MintNft<Account, NftIssueArgs, { gasLimit: number; value: number }, string> &
MintNft<
WalletConnection,
NftIssueArgs,
{ gasLimit: number; value: number },
string
> &
DeployNFTCollection<
Account,
WalletConnection,
{ name: string; ticker: string },
{ gasLimit: number },
string
Expand Down

0 comments on commit 2e14076

Please sign in to comment.