kanon-auctionhouse-sdk
v1.2.5
Published
Kanon AuctionHouse SDK for TypeScript
Downloads
24
Readme
kanon-auctionhouse-sdk
Load Auctionhouse program
const { connection } = useConnection();
const { wallet, sendTransaction } = useWallet();
const provider = new Provider(connection, wallet as any, {
preflightCommitment: "confirmed",
});
// initialize KanonAuctionHouseAdapter w/o wallet connected
const program = new KanonAuctionHouseAdapter(provider, {
isAuctionHouseAuthority: true,
auctionHouseKeyString: "AuctionHouse Key",
});
Initialize with connected wallet
// re-initialize KanonAuctionHouseAdapter with updated provider
const program = new KanonAuctionHouseAdapter(provider, {
isAuctionHouseAuthority: true,
auctionHouseKeyString: "AuctionHouse Key",
});
// initialize user reserved PDA addresses
await program.refreshByWallet();
Sign & send transaction w/ connected wallet
try {
const tx = await program.updateAuctionHouse(
auctionHouseAuthorityWalletPubKey,
sellerFeeBasisPoints,
canChangeSalePrice,
requiresSignOff,
newAuthority,
force);
if(tx === null){
console.error('Program has not been initialized.');
}
else{
let signature = await sendTransaction(tx, connection);
await connection.confirmTransaction(signature, "processed");
}
} catch (err) {
// handle custom program error code
}
Withdraw From Fee
try {
const tx = await program.withdrawFromFee(
amount
);
if(tx === null){
console.error('Program has not been initialized.');
}
else{
await sendTransactionWithRetryWithKeypair(
this._program.provider.connection,
auctionHouseAuthoritykeypair,
tx,
signers,
'max',
);
console.info(
'Withdrew',
amountAdjusted.toNumber(),
'from your account with Auction House',
auctionHouse,
);
}
} catch (err) {
// handle custom program error code
}