Skip to content

Commit

Permalink
Chains: Mint: Require Mint Gas Args
Browse files Browse the repository at this point in the history
  • Loading branch information
imsk17 committed Feb 29, 2024
1 parent b39bb4f commit 6869fa5
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 26 deletions.
5 changes: 4 additions & 1 deletion src/handlers/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ export function evmHandler({
);
return await contract.getAddress();
},
async mintNft(signer, ma) {
async mintNft(signer, ma, gas) {
const minter = ERC721Royalty__factory.connect(ma.contract, signer);
const response = await minter.mint(
await signer.getAddress(),
ma.tokenId,
ma.royalty,
ma.royaltyReceiver,
ma.uri,
{
...gas,
},
);
await response.wait();
return response;
Expand Down
2 changes: 2 additions & 0 deletions src/handlers/evm/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
} from "ethers";
import { Bridge, BridgeStorage } from "../../contractsTypes/evm";

import { PayableOverrides } from "../../contractsTypes/evm/common";
import { DeployCollection, MintNft, TNftChain } from "../types";

export type TEvmHandler = TNftChain<
Expand All @@ -25,6 +26,7 @@ export type TEvmHandler = TNftChain<
royalty: bigint;
royaltyReceiver: string;
},
PayableOverrides,
ContractTransactionResponse
> &
DeployCollection<
Expand Down
9 changes: 5 additions & 4 deletions src/handlers/multiversx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export function multiversxHandler({
getStorageContract() {
return storage;
},
async mintNft(signer, ma) {
async mintNft(signer, ma, gasArgs) {
const args: TypedValue[] = [
BytesValue.fromUTF8(ma.ticker),
new BigUIntValue(1),
Expand All @@ -169,12 +169,13 @@ export function multiversxHandler({
const tx = new Transaction({
data,
gasLimit:
gasArgs?.gasLimit ??
3_000_000 +
data.length() * 1500 +
(ma.attrs?.length || 0 + (ma.hash?.length ?? 0) || 0) * 50000,
data.length() * 1500 +
(ma.attrs?.length || 0 + (ma.hash?.length ?? 0) || 0) * 50000,
receiver: signer.getAddress(),
sender: signer.getAddress(),
value: 0,
value: gasArgs?.value ?? 0,
chainID: chainId,
});

Expand Down
7 changes: 6 additions & 1 deletion src/handlers/multiversx/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ export type TMultiversXHandler = TSingularNftChain<
string,
INetworkProvider
> &
MintNft<TMultiversXSigner, NftIssueArgs, string> &
MintNft<
TMultiversXSigner,
NftIssueArgs,
{ gasLimit: number; value: number },
string
> &
DeployCollection<
TMultiversXSigner,
{ name: string; ticker: string },
Expand Down
25 changes: 14 additions & 11 deletions src/handlers/secret/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,23 @@ export function secretHandler({
)?.value;
return contractAddress ?? raise("Contract not found");
},
mintNft(signer, ma) {
const mint = signer.tx.snip721.mint({
contract_address: ma.contractAddress,
msg: {
mint_nft: {
public_metadata: {
token_uri: ma.uri,
mintNft(signer, ma, gasArgs) {
const mint = signer.tx.snip721.mint(
{
contract_address: ma.contractAddress,
msg: {
mint_nft: {
public_metadata: {
token_uri: ma.uri,
},
token_id: ma.tokenId,
owner: signer.address,
},
token_id: ma.tokenId,
owner: signer.address,
},
sender: signer.address,
},
sender: signer.address,
});
gasArgs,
);
return mint;
},
transform(input) {
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/secret/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type TSecretHandler = TNftChain<
TxResponse,
SecretNetworkClient
> &
MintNft<SecretNetworkClient, SecretMintArgs, TxResponse> &
MintNft<SecretNetworkClient, SecretMintArgs, TxOptions, TxResponse> &
DeployCollection<
SecretNetworkClient,
{ name: string; symbol: string },
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/tezos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function tezosHandler({
metadata: nft.metadata,
};
},
async mintNft(signer, ma) {
async mintNft(signer, ma, gasArgs) {
Tezos.setSignerProvider(signer);
const contract = await Tezos.contract.at<NFTContractType>(ma.contract);
const tx = contract.methods
Expand All @@ -133,7 +133,7 @@ export function tezosHandler({
token_uri: ma.uri,
},
])
.send();
.send(gasArgs);
return tx;
},
async deployCollection(signer, _da, ga) {
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/tezos/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export type TTezosHandler = TSingularNftChain<
TransactionOperation,
TezosToolkit
> &
MintNft<Signer, TezosMintArgs, TransactionOperation> &
DeployCollection<Signer, object, { gasLimit?: number }, string>;
MintNft<Signer, TezosMintArgs, Partial<SendParams>, TransactionOperation> &
DeployCollection<Signer, object, Partial<SendParams>, string>;

export type TTezosParams = {
Tezos: TezosToolkit;
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/ton/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type TTonHandler = TSingularNftChain<
undefined,
TonClient
> &
MintNft<Sender, TonMintArgs, undefined> &
MintNft<Sender, TonMintArgs, never, undefined> &
DeployCollection<Sender, TonMintArgs, never, string>;

export type TTonParams = {
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/types/chain.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { BridgeStorage } from "../../contractsTypes/evm";
import { TSupportedChain, TSupportedSftChain } from "../../factory/types/utils";

export type MintNft<Signer, MintArgs, RetTx> = {
mintNft: (signer: Signer, ma: MintArgs) => Promise<RetTx>;
export type MintNft<Signer, MintArgs, GasArgs, RetTx> = {
mintNft: (signer: Signer, ma: MintArgs, gasArgs?: GasArgs) => Promise<RetTx>;
};

export type DeployCollection<Signer, DeployArgs, GasArgs, RetTx> = {
deployCollection: (
signer: Signer,
da: DeployArgs,
ga: GasArgs | undefined,
ga?: GasArgs,
) => Promise<RetTx>;
};

Expand Down

0 comments on commit 6869fa5

Please sign in to comment.