From 6f36284fbd6acb4fb1adae97a3b3b01d0c8f5f91 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Tue, 11 Apr 2023 15:57:37 +0300 Subject: [PATCH] Add update_royalty_info() among sg721 contract helpers --- contracts/sg721/contract.ts | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/contracts/sg721/contract.ts b/contracts/sg721/contract.ts index f15d8c2..ba342d8 100644 --- a/contracts/sg721/contract.ts +++ b/contracts/sg721/contract.ts @@ -14,6 +14,11 @@ export interface MigrateResponse { readonly logs: readonly logs.Log[] } +export interface RoyaltyInfo { + payment_address: string + share_bps: number +} + export type Expiration = { at_height: number } | { at_time: string } | { never: Record } export interface SG721Instance { @@ -70,6 +75,7 @@ export interface SG721Instance { revokeAll: (operator: string) => Promise /// Mint a new NFT, can only be called by the contract minter mint: (tokenId: string, owner: string, tokenURI?: string) => Promise //MintMsg + updateRoyaltyInfo: (royaltyInfo: RoyaltyInfo) => Promise /// Burn an NFT the sender has access to burn: (tokenId: string) => Promise @@ -90,6 +96,18 @@ export interface Sg721Messages { batchTransfer: (recipient: string, tokenIds: string) => BatchTransferMessage } +export interface UpdateRoyaltyInfoMessage { + sender: string + contract: string + msg: { + update_royalty_info: { + payment_address: string + share_bps: string + } + } + funds: Coin[] +} + export interface TransferNFTMessage { sender: string contract: string @@ -425,6 +443,22 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con return res.transactionHash } + const updateRoyaltyInfo = async (royaltyInfo: RoyaltyInfo): Promise => { + const res = await client.execute( + txSigner, + contractAddress, + { + update_royalty_info: { + payment_address: royaltyInfo.payment_address, + share_bps: royaltyInfo.share_bps, + }, + }, + 'auto', + '', + ) + return res.transactionHash + } + const burn = async (tokenId: string): Promise => { const res = await client.execute( txSigner, @@ -546,6 +580,7 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con approveAll, revokeAll, mint, + updateRoyaltyInfo, burn, batchBurn, batchTransfer, @@ -684,6 +719,20 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con } } + const updateRoyaltyInfo = (royaltyInfo: RoyaltyInfo) => { + return { + sender: txSigner, + contract: contractAddress, + msg: { + update_royalty_info: { + payment_address: royaltyInfo.payment_address, + share_bps: royaltyInfo.share_bps, + }, + }, + funds: [], + } + } + const burn = (tokenId: string) => { return { sender: txSigner, @@ -753,6 +802,7 @@ export const SG721 = (client: SigningCosmWasmClient, txSigner: string): SG721Con approveAll, revokeAll, mint, + updateRoyaltyInfo, burn, batchBurn, batchTransfer,