import { Client , Provider , Receipt , Result } from "@blockstack/clarity" ; export class NonFungibleTokenClient extends Client { constructor ( provider ) { super ( "SP3GWX3NE58KXHESRYE4DYQ1S31PQJTCRXB3PE9SB.non-fungible-token" , "tokens/non-fungible-token" , provider ) ; } async balanceOf ( owner ) { const query = this . createQuery ( { method : { name : "balance-of" , args : [ `'${ owner }` ] } } ) ; const res = await this . submitQuery ( query ) ; return parseInt ( res . result as string ) ; } async ownerOf ( tokenId ) { const query = this . createQuery ( { method : { name : "owner-of?" , args : [ `${ tokenId }` ] } } ) ; const res = await this . submitQuery ( query ) ; return Result . unwrap ( res ) . replace ( /'/g , "" ) ; } async canTransfer ( actor , tokenId ) { const query = this . createQuery ( { method : { name : "can-transfer" , args : [ `'${ actor }` , `${ tokenId }` ] } } ) ; const res = await this . submitQuery ( query ) ; return Result . unwrap ( res ) === "true" ; } async isSpenderApproved ( spender , tokenId ) { const query = this . createQuery ( { method : { name : "is-spender-approved" , args : [ `'${ spender }` , `${ tokenId }` ] } } ) ; const res = await this . submitQuery ( query ) ; return parseInt ( Result . unwrap ( res ) ) ; } async isOperatorApproved ( owner , operator ) { const query = this . createQuery ( { method : { name : "is-operator-approved" , args : [ `'${ owner }` , `'${ operator }` ] } } ) ; const res = await this . submitQuery ( query ) ; return parseInt ( Result . unwrap ( res ) ) ; } async setSpenderApproval ( spender , tokenId , params ) { const tx = this . createTransaction ( { method : { name : "set-spender-approval" , args : [ `'${ spender }` , `${ tokenId }` ] } } ) ; await tx . sign ( params . sender ) ; const res = await this . submitTransaction ( tx ) ; return res ; } async setOperatorApproval ( operator , isApproved , params ) { const tx = this . createTransaction ( { method : { name : "set-operator-approval" , args : [ `'${ operator }` , `${ isApproved }` ] } } ) ; await tx . sign ( params . sender ) ; const res = await this . submitTransaction ( tx ) ; return res ; } async transferFrom ( from , to , tokenId , params ) { const tx = this . createTransaction ( { method : { name : "transfer-from" , args : [ `'${ from }` , `'${ to }` , `${ tokenId }` ] } } ) ; await tx . sign ( params . sender ) ; const res = await this . submitTransaction ( tx ) ; return res ; } async transfer ( to , tokenId , params ) { const tx = this . createTransaction ( { method : { name : "transfer" , args : [ `'${ to }` , `${ tokenId }` ] } } ) ; await tx . sign ( params . sender ) ; const res = await this . submitTransaction ( tx ) ; return res ; } }