-
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.
fix(sdk): improvements & fixes for v2.0.0 (#70)
* fix: update input size for taproot * fix: add output for recovery mode and update calculation * refactor: update error message * feta: add getInscriptionUTXO RPC call * perf: replace getUnspents w/ getInscriptionUTXO * feat: add data getter on all new classes * fix: remove duplicate class members * refactor: update examples to use new fns * feat: add UTXOManager class * fix: convert inscription id to specific format * refactor: add missing filters to getInscriptions and relay fn * fix: remove unnecessary check * fix: remove unused imports * fix: check inscription ownership * revert: use previous implementation of GetInscriptions * fix: format outpoint to id & revert ownership check
- Loading branch information
1 parent
eb8f19c
commit 75adfb4
Showing
22 changed files
with
296 additions
and
141 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
import { JsonRpcDatasource } from '@sadoprotocol/ordit-sdk'; | ||
import { Ordit, ordit } from '@sadoprotocol/ordit-sdk' | ||
|
||
async function main() { | ||
const MNEMONIC = "<MNEMONIC>"; // Generated HD wallet seed phrase | ||
const wallet = new Ordit({ | ||
bip39: MNEMONIC, | ||
network: "testnet" | ||
}); | ||
const MNEMONIC = "<MNEMONIC>"; // Generated HD wallet seed phrase | ||
const network = "testnet" | ||
const wallet = new Ordit({ | ||
bip39: MNEMONIC, | ||
network | ||
}); | ||
wallet.setDefaultAddress('taproot') | ||
|
||
wallet.setDefaultAddress('taproot') | ||
const datasource = new JsonRpcDatasource({ network }) | ||
|
||
async function main() { | ||
const psbt = await ordit.transactions.createPsbt({ | ||
pubKey: '039ce27aa7666731648421004ba943b90b8273e23a175d9c58e3ec2e643a9b01d1', | ||
address: 'tb1p98dv6f5jp5qr4z2dtaljvwrhq34xrr8zuaqgv4ajf36vg2mmsruqt5m3lv', | ||
outputs: [{ | ||
address: 'tb1qatkgzm0hsk83ysqja5nq8ecdmtwl73zwurawww', | ||
value: 1200 | ||
}], | ||
network: 'testnet', | ||
network, | ||
satsPerByte: 2, | ||
format: 'p2tr' | ||
}) | ||
|
||
const signature = await wallet.signPsbt(psbt.hex) | ||
const txResponse = await wallet.relayTx(signature, 'testnet') | ||
const signedTxHex = await wallet.signPsbt(psbt.hex) | ||
const txId = await datasource.relay({ hex: signedTxHex }) | ||
|
||
console.log("tx >>", txResponse) | ||
console.log({ txId }) | ||
} | ||
|
||
main() |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { JsonRpcDatasource } from "@sadoprotocol/ordit-sdk"; | ||
import { Ordit } from "@sadoprotocol/ordit-sdk"; | ||
import { UTXOManager } from "@sadoprotocol/ordit-sdk"; | ||
|
||
const network = 'testnet' | ||
const wallet = new Ordit({ | ||
bip39: '<mnemonic>', | ||
network | ||
}) | ||
wallet.setDefaultAddress('taproot') | ||
|
||
async function main() { | ||
const datasource = new JsonRpcDatasource({ network }) | ||
const utxoManager = new UTXOManager({ | ||
address: wallet.selectedAddress, | ||
network, | ||
publicKey: wallet.publicKey, | ||
feeRate: 3 | ||
}) | ||
|
||
await utxoManager.splitUTXOForInstantTrade() | ||
const hex = utxoManager.toHex() | ||
const signedTxHex = wallet.signPsbt(hex) | ||
const txId = await datasource.relay({ hex: signedTxHex }) | ||
console.log({ txId }) | ||
} | ||
|
||
main() |
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.