-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk)!: introduce royalty payments in instant-trade flow (#66)
* feat: add creator royalty as per OIP-6 ref: https://www.oips.io/oip-06-ordinals-royalty-standard * refactor: set max decimals to 5 * refactor: make royalty optional * fix: update property name * feat: bind royalty payment to seller PSBT * feat: support multiple injectable outputs * fix: check if pct is number * refactor: update publish-collection example * feat: add royalty class member * refactor: rename inscriberMode to autoAdjustment * fix: bind index to collection txid * fix: prevent injectable output from replacing existing output * fix: retrieve more UTXOs only when pre-fetched UTXOs are not enough * refactor!: cleanup & class member visibility change also, replace direct assignment w/ passing param in constructor * refactor: update publish-collection example * refactor: update decimals for royalty pct to 8 * refactor: pay no royalty if amount below dust
- Loading branch information
1 parent
ee32996
commit 32770c2
Showing
8 changed files
with
176 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,19 +17,20 @@ const publisherWallet = new Ordit({ | |
|
||
// set default address types for both wallets | ||
userWallet.setDefaultAddress("taproot"); | ||
publisherWallet.setDefaultAddress("nested-segwit"); | ||
publisherWallet.setDefaultAddress("taproot"); | ||
|
||
async function publish() { | ||
const getPublisherLegacyAddress = () => { | ||
publisherWallet.setDefaultAddress("legacy") | ||
const legacyAddress = publisherWallet.selectedAddress | ||
publisherWallet.setDefaultAddress("nested-segwit") // switch back to default | ||
publisherWallet.setDefaultAddress("taproot") // switch back to default | ||
|
||
return legacyAddress | ||
} | ||
|
||
//publish | ||
const transaction = await publishCollection({ | ||
address: publisherWallet.selectedAddress, | ||
network, | ||
feeRate: 2, | ||
title: "Collection Name", | ||
|
@@ -40,25 +41,24 @@ async function publish() { | |
email: "[email protected]", | ||
name: "Your Name" | ||
}, | ||
royalty: { | ||
address: publisherWallet.selectedAddress, | ||
pct: 0.05 | ||
}, | ||
publishers: [getPublisherLegacyAddress()], | ||
inscriptions: [ | ||
{ | ||
iid: "el-01", | ||
lim: 10, | ||
sri: "sha256-Ujac9y464/qlFmtfLDxORaUtIDH8wrHgv8L9bpPeb28=" | ||
}, | ||
{ | ||
iid: "el-02", | ||
lim: 2, | ||
sri: "sha256-zjQXDuk++5sICrObmfWqAM5EibidXd2emZoUcU2l5Pg=" | ||
} | ||
], | ||
url: "https://example.com", | ||
publicKey: publisherWallet.publicKey, | ||
destination: publisherWallet.selectedAddress, | ||
changeAddress: publisherWallet.selectedAddress, | ||
postage: 1000, | ||
mediaContent: 'Collection Name', // this will be inscribed on-chain as primary content | ||
mediaContent: '5% Royalty Collection', // this will be inscribed on-chain as primary content | ||
mediaType: "text/plain" | ||
}); | ||
|
||
|
@@ -88,6 +88,7 @@ async function mint() { | |
|
||
// publish | ||
const transaction = await mintFromCollection({ | ||
address: userWallet.selectedAddress, | ||
network, | ||
collectionOutpoint: collectionId, | ||
inscriptionIid: "el-01", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.