diff --git a/src/handlers/aptos/index.ts b/src/handlers/aptos/index.ts index 176ddaee..62a58ce7 100644 --- a/src/handlers/aptos/index.ts +++ b/src/handlers/aptos/index.ts @@ -21,7 +21,7 @@ export function aptosHandler({ if (!bd) throw new Error("Failed to fetch bridge data"); return bd.validators.data.length; }, - async deployCollection(signer, da) { + async deployNftCollection(signer, da) { const transaction = await aptos.createCollectionTransaction({ creator: signer, description: `Testnet Collection: ${da.name}(${da.symbol}) by XP Network.`, diff --git a/src/handlers/aptos/types.ts b/src/handlers/aptos/types.ts index efdc0bb5..6fec6d99 100644 --- a/src/handlers/aptos/types.ts +++ b/src/handlers/aptos/types.ts @@ -1,7 +1,7 @@ import { Account, Aptos, PendingTransactionResponse } from "@aptos-labs/ts-sdk"; import { Network } from "aptos"; import { BridgeStorage } from "../../contractsTypes/evm"; -import { DeployCollection, MintNft, TNftChain } from "../types"; +import { DeployNFTCollection, MintNft, TNftChain } from "../types"; import { TClaimData } from "./bridge-client"; export type TAptosMintArgs = { @@ -18,7 +18,7 @@ export type TAptosHandler = TNftChain< Aptos > & MintNft & - DeployCollection; + DeployNFTCollection; export type TAptosParams = { bridge: string; diff --git a/src/handlers/cosmwasm/index.ts b/src/handlers/cosmwasm/index.ts index 376ccf22..03c8b28d 100644 --- a/src/handlers/cosmwasm/index.ts +++ b/src/handlers/cosmwasm/index.ts @@ -339,7 +339,7 @@ export async function cosmWasmHandler({ ); return mint; }, - async deployCollection(signer, data, gasArgs) { + async deployNftCollection(signer, data, gasArgs) { const sender = (await signer.getAccounts())[0]; const client = await SigningCosmWasmClient.connectWithSigner(rpc, signer); const msg = { diff --git a/src/handlers/cosmwasm/types.ts b/src/handlers/cosmwasm/types.ts index a503a1d5..896aa4e9 100644 --- a/src/handlers/cosmwasm/types.ts +++ b/src/handlers/cosmwasm/types.ts @@ -4,7 +4,7 @@ import { OfflineDirectSigner } from "@cosmjs/proto-signing"; import { ClaimData } from "@xp/cosmos-client/dist/bridge/Bridge.types"; import { BridgeStorage } from "../../contractsTypes/evm"; import { - DeployCollection, + DeployNFTCollection, MintNft, ReadClaimed721Event, TSingularNftChain, @@ -47,7 +47,7 @@ export type TCosmWasmHandler = TSingularNftChain< CosmWasmExtraArgs, ExecuteResult > & - DeployCollection< + DeployNFTCollection< OfflineDirectSigner, { name: string; symbol: string; codeId?: number }, CosmWasmExtraArgs, diff --git a/src/handlers/evm/index.ts b/src/handlers/evm/index.ts index 042ff417..92222ce7 100644 --- a/src/handlers/evm/index.ts +++ b/src/handlers/evm/index.ts @@ -1,6 +1,7 @@ import { Bridge__factory, ERC721Royalty__factory, + ERC1155Royalty__factory, } from "../../contractsTypes/evm"; import { retryFn } from "../utils"; @@ -86,7 +87,7 @@ export function evmHandler({ lock_tx_chain: claimed.args.lockTxChain, }; }, - async deployCollection(signer, da, ga) { + async deployNftCollection(signer, da, ga) { const contract = await new ERC721Royalty__factory(signer).deploy( da.name, da.symbol, @@ -98,6 +99,16 @@ export function evmHandler({ ); return await contract.getAddress(); }, + async deploySFTCollection(signer, da, ga) { + const contract = await new ERC1155Royalty__factory(signer).deploy( + da.owner ?? signer, + { + ...ga, + from: await signer.getAddress(), + }, + ); + return await contract.getAddress(); + }, async mintNft(signer, ma, gas) { const minter = ERC721Royalty__factory.connect(ma.contract, signer); const response = await minter.mint( diff --git a/src/handlers/hedera/index.ts b/src/handlers/hedera/index.ts index f185d2b0..98689e28 100644 --- a/src/handlers/hedera/index.ts +++ b/src/handlers/hedera/index.ts @@ -218,7 +218,7 @@ export function hederaHandler({ }, ); }, - async deployCollection(signer, da, ga) { + async deployNftCollection(signer, da, ga) { const rif = proxy.connect(signer); const deploy = await rif.deployNft(da.name, da.symbol, { ...ga, diff --git a/src/handlers/hedera/types.ts b/src/handlers/hedera/types.ts index c4a42576..21078e83 100644 --- a/src/handlers/hedera/types.ts +++ b/src/handlers/hedera/types.ts @@ -13,7 +13,7 @@ import { Bridge } from "../../contractsTypes/evm"; import { PayableOverrides } from "../../contractsTypes/evm/common"; import { TEvmParams } from "../evm/types"; import { - DeployCollection, + DeployNFTCollection, MintNft, ReadClaimed721Event, TApproveNFT, @@ -43,7 +43,7 @@ export type THederaHandler = TSingularNftChain< PayableOverrides, ContractTransactionResponse | TransactionResponseJSON > & - DeployCollection< + DeployNFTCollection< Signer, { name: string; diff --git a/src/handlers/icp/index.ts b/src/handlers/icp/index.ts index b74a640a..85653b56 100644 --- a/src/handlers/icp/index.ts +++ b/src/handlers/icp/index.ts @@ -159,7 +159,7 @@ export async function icpHandler({ throw new Error(`Failed to approve, ${approval?.Err}`); return approval.Ok.toString(); }, - async deployCollection(signer, _da) { + async deployNftCollection(signer, _da) { const encoded = init({ IDL })[0].encodeValue({ icrc3_args: [ { diff --git a/src/handlers/icp/types.ts b/src/handlers/icp/types.ts index 54f2caac..5e9a2a8a 100644 --- a/src/handlers/icp/types.ts +++ b/src/handlers/icp/types.ts @@ -5,7 +5,7 @@ import { BridgeStorage } from "../../contractsTypes/evm"; import { ClaimData } from "../../contractsTypes/icp/bridge/bridge.types"; import { Value } from "../../contractsTypes/icp/nft/nft.types"; import { - DeployCollection, + DeployNFTCollection, MintNft, ReadClaimed721Event, TNFTList, @@ -45,7 +45,7 @@ export type TICPHandler = TSingularNftChain< HttpAgent > & MintNft & - DeployCollection< + DeployNFTCollection< HttpAgent, { name: string; symbol: string }, undefined, diff --git a/src/handlers/multiversx/index.ts b/src/handlers/multiversx/index.ts index d612b3a7..c89c6e25 100644 --- a/src/handlers/multiversx/index.ts +++ b/src/handlers/multiversx/index.ts @@ -105,7 +105,7 @@ export function multiversxHandler({ royalty: BigInt(royalties), }; }, - async deployCollection(signer, da, ga) { + async deployNftCollection(signer, da, ga) { const builtInSC = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"; const args: TypedValue[] = [ diff --git a/src/handlers/multiversx/types.ts b/src/handlers/multiversx/types.ts index 94e02ace..05c9c2ac 100644 --- a/src/handlers/multiversx/types.ts +++ b/src/handlers/multiversx/types.ts @@ -2,7 +2,7 @@ import { Transaction } from "@multiversx/sdk-core/out"; import { INetworkProvider } from "@multiversx/sdk-network-providers/out/interface"; import { BridgeStorage } from "../../contractsTypes/evm"; import { - DeployCollection, + DeployNFTCollection, MintNft, ReadClaimed721Event, ReadClaimed1155Event, @@ -61,7 +61,7 @@ export type TMultiversXHandler = TSingularNftChain< { gasLimit: number; value: number }, string > & - DeployCollection< + DeployNFTCollection< TMultiversXSigner, { name: string; ticker: string }, { gasLimit: number }, diff --git a/src/handlers/secret/index.ts b/src/handlers/secret/index.ts index 4a82bf47..0db452d9 100644 --- a/src/handlers/secret/index.ts +++ b/src/handlers/secret/index.ts @@ -55,7 +55,7 @@ export function secretHandler({ ret: tx, }; }, - async deployCollection(signer, da, ga) { + async deployNftCollection(signer, da, ga) { const code = da.codeId ?? nftCodeId; if (!code) { throw new Error("Code not found"); diff --git a/src/handlers/secret/types.ts b/src/handlers/secret/types.ts index 9a1f9d40..90d73785 100644 --- a/src/handlers/secret/types.ts +++ b/src/handlers/secret/types.ts @@ -1,7 +1,7 @@ import { SecretNetworkClient, TxOptions, TxResponse } from "secretjs"; import { BridgeStorage } from "../../contractsTypes/evm"; import { - DeployCollection, + DeployNFTCollection, MintNft, ReadClaimed721Event, ReadClaimed1155Event, @@ -41,7 +41,7 @@ export type TSecretHandler = TNftChain< MintNft & ReadClaimed721Event & ReadClaimed1155Event & - DeployCollection< + DeployNFTCollection< SecretNetworkClient, { name: string; symbol: string; codeId?: number }, TxOptions, diff --git a/src/handlers/tezos/index.ts b/src/handlers/tezos/index.ts index 6458b46b..08498e26 100644 --- a/src/handlers/tezos/index.ts +++ b/src/handlers/tezos/index.ts @@ -285,7 +285,7 @@ export function tezosHandler({ gasArgs, ); }, - async deployCollection(signer, da, ga) { + async deployNftCollection(signer, da, ga) { const metadata = new MichelsonMap(); metadata.set("", tas.bytes(char2Bytes("tezos-storage:data"))); metadata.set( diff --git a/src/handlers/tezos/types.ts b/src/handlers/tezos/types.ts index 436db9be..d99437a9 100644 --- a/src/handlers/tezos/types.ts +++ b/src/handlers/tezos/types.ts @@ -11,7 +11,7 @@ import BigNumber from "bignumber.js"; import { BridgeStorage } from "../../contractsTypes/evm"; import { address, mutez, nat } from "../../contractsTypes/tezos/type-aliases"; import { - DeployCollection, + DeployNFTCollection, MintNft, ReadClaimed721Event, TSingularNftChain, @@ -57,7 +57,7 @@ export type TTezosHandler = TSingularNftChain< TezosToolkit > & MintNft, string> & - DeployCollection< + DeployNFTCollection< TezosSigner, { name: string; diff --git a/src/handlers/ton/index.ts b/src/handlers/ton/index.ts index 7f041e00..4c00fc0e 100644 --- a/src/handlers/ton/index.ts +++ b/src/handlers/ton/index.ts @@ -133,7 +133,7 @@ export function tonHandler({ throw new Error("Claimed event not found"); }, - async deployCollection(signer, da) { + async deployNftCollection(signer, da) { const nft = client.open( await TestnetNftCollection.fromInit( da.owner_address, diff --git a/src/handlers/ton/types.ts b/src/handlers/ton/types.ts index 57358505..efeb1db5 100644 --- a/src/handlers/ton/types.ts +++ b/src/handlers/ton/types.ts @@ -3,7 +3,7 @@ import { TonClient } from "@ton/ton"; import { BridgeStorage } from "../../contractsTypes/evm"; import { ClaimData } from "../../contractsTypes/ton/tonBridge"; import { - DeployCollection, + DeployNFTCollection, MintNft, ReadClaimed721Event, TSingularNftChain, @@ -35,7 +35,7 @@ export type TTonHandler = TSingularNftChain< TonClient > & MintNft & - DeployCollection & + DeployNFTCollection & ReadClaimed721Event; export type TTonParams = { diff --git a/src/handlers/types/chain.ts b/src/handlers/types/chain.ts index 6564f2c3..b023baba 100644 --- a/src/handlers/types/chain.ts +++ b/src/handlers/types/chain.ts @@ -5,14 +5,43 @@ export type MintNft = { mintNft: (signer: Signer, ma: MintArgs, gasArgs?: GasArgs) => Promise; }; -export type DeployCollection = { - deployCollection: ( +export type MintSft = { + mintSft: ( + signer: Signer, + ma: MintArgs, + amount: bigint, + gasArgs?: GasArgs, + ) => Promise; +}; + +export type Mint = MintNft< + Signer, + MintArgs, + GasArgs, + RetTx +> & + MintSft; + +export type DeployNFTCollection = { + deployNftCollection: ( + signer: Signer, + da: DeployArgs, + ga?: GasArgs, + ) => Promise; +}; + +export type DeploySFTCollection = { + deploySFTCollection: ( signer: Signer, da: DeployArgs, ga?: GasArgs, ) => Promise; }; +export type DeployCollection = + DeployNFTCollection & + DeploySFTCollection; + /** * Represents a function that locks an NFT on the chain inside the bridge smart contract. * @template Signer The type of the signer. ie {Signer} on EVM from ethers