Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hedera claim nft via hashpack #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"@cosmjs/amino": "^0.32.3",
"@cosmjs/cosmwasm-stargate": "^0.32.3",
"@hashgraph/sdk": "^2.48.1",
"@multiversx/sdk-core": "^13.2.1",
"@multiversx/sdk-network-providers": "^2.2.1",
"@multiversx/sdk-wallet": "^4.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/contractsTypes/Hedera/HederaBridge__factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type {
HederaBridgeInterface,
} from "./HederaBridge";

const _abi = [
export const _abi = [
{
inputs: [
{
Expand Down
27 changes: 26 additions & 1 deletion src/handlers/hedera/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import {
import { evmHandler } from "../evm";
import { raise } from "../ton";
import { THederaHandler, THederaParams } from "./types";
import {
ContractExecuteTransaction,
ContractId,
ContractFunctionParameters,
} from "@hashgraph/sdk";

export function hederaHandler({
provider,
Expand Down Expand Up @@ -67,7 +72,7 @@ export function hederaHandler({
claimData,
sigs.map((e) => e.signature),
{
value: BigInt(claimData.fee) * BigInt(1e10),
value: BigInt(claimData.fee) * BigInt(2e10),
...extraArgs,
},
);
Expand Down Expand Up @@ -129,6 +134,26 @@ export function hederaHandler({
metadata: metadata || "",
};
},
async claimHashPackNft(wallet, claimData, sigs, extraArgs) {
console.log("bridge", bridge, claimData);
console.log("bridge", ContractId.fromString(bridge));

const sendHbarTx = await new ContractExecuteTransaction()
.setContractId(ContractId.fromString(bridge))
.setGas(extraArgs.gasLimit ? Number(extraArgs.gasLimit) : 1_500_000)
.setFunction(
"claimNFT721",
new ContractFunctionParameters()
// ._addParam("data", claimData as any)
.addStringArray(sigs.map((e) => e.signature)),
)
.freezeWithSigner(wallet);
const response = await sendHbarTx.executeWithSigner(wallet);

console.log(response);

return response.transactionHash.toString();
},
};
}

Expand Down
14 changes: 13 additions & 1 deletion src/handlers/hedera/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Signer as HSigner } from "@hashgraph/sdk";
import {
ContractTransactionResponse,
Overrides,
Expand All @@ -14,8 +15,18 @@ import {
ReadClaimed1155Event,
TApproveNFT,
TNftChain,
TSignerAndSignature,
} from "../types";

export type TClaimHashPackNft = {
claimHashPackNft: (
wallet: HSigner,
claimData: Bridge.ClaimDataStruct,
sigs: TSignerAndSignature[],
extraArgs: Overrides,
) => Promise<string>;
};

export type HederaMintArgs = {
contract: string;
uri: string;
Expand Down Expand Up @@ -45,7 +56,8 @@ export type THederaHandler = TNftChain<
string
> &
ReadClaimed721Event &
ReadClaimed1155Event;
ReadClaimed1155Event &
TClaimHashPackNft;

export type THederaParams = TEvmParams & {
royaltySalePrice: number;
Expand Down
Loading