-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add testnet examples to broadcast feed and call_order updates
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import {Apis} from "bitsharesjs-ws"; | ||
import {TransactionBuilder, PrivateKey} from "../lib"; | ||
|
||
const wifKey = "5KBuq5WmHvgePmB7w3onYsqLM8ESomM2Ae7SigYuuwg8MDHW7NN"; | ||
const pKey = PrivateKey.fromWif(wifKey); | ||
|
||
Apis.instance("wss://node.testnet.bitshares.eu", true).init_promise.then( | ||
res => { | ||
console.log("connected to:", res[0].network_name, "network"); | ||
|
||
let tr = new TransactionBuilder(); | ||
tr.add_type_operation("call_order_update", { | ||
funding_account: "1.2.680", | ||
delta_collateral: { | ||
amount: 1000000, | ||
asset_id: "1.3.0" | ||
}, | ||
delta_debt: { | ||
amount: 0, | ||
asset_id: "1.3.1003" | ||
}, | ||
extensions: { | ||
target_collateral_ratio: 250 | ||
} | ||
}); | ||
|
||
tr.set_required_fees().then(() => { | ||
tr.add_signer(pKey, pKey.toPublicKey().toPublicKeyString()); | ||
console.log("serialized transaction:", tr.serialize().operations); | ||
tr | ||
.broadcast() | ||
.then(() => { | ||
console.log("Call order update success!"); | ||
}) | ||
.catch(err => { | ||
console.error(err); | ||
}); | ||
}); | ||
} | ||
); |
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,53 @@ | ||
import {Apis} from "bitsharesjs-ws"; | ||
import {TransactionBuilder, PrivateKey} from "../lib"; | ||
|
||
const wifKey = "5KBuq5WmHvgePmB7w3onYsqLM8ESomM2Ae7SigYuuwg8MDHW7NN"; | ||
const pKey = PrivateKey.fromWif(wifKey); | ||
|
||
Apis.instance("wss://node.testnet.bitshares.eu", true).init_promise.then( | ||
res => { | ||
console.log("connected to:", res[0].network_name, "network"); | ||
let tr = new TransactionBuilder(); | ||
tr.add_type_operation("asset_publish_feed", { | ||
publisher: "1.2.680", | ||
asset_id: "1.3.1003", | ||
feed: { | ||
settlement_price: { | ||
quote: { | ||
amount: 10, | ||
asset_id: "1.3.0" | ||
}, | ||
base: { | ||
amount: 5, | ||
asset_id: "1.3.1003" | ||
} | ||
}, | ||
maintenance_collateral_ratio: 1750, | ||
maximum_short_squeeze_ratio: 1200, | ||
core_exchange_rate: { | ||
quote: { | ||
amount: 10, | ||
asset_id: "1.3.0" | ||
}, | ||
base: { | ||
amount: 5, | ||
asset_id: "1.3.1003" | ||
} | ||
} | ||
} | ||
}); | ||
|
||
tr.set_required_fees().then(() => { | ||
tr.add_signer(pKey, pKey.toPublicKey().toPublicKeyString()); | ||
console.log("serialized transaction:", tr.serialize().operations); | ||
tr | ||
.broadcast() | ||
.then(() => { | ||
console.log("Publish feed success!"); | ||
}) | ||
.catch(err => { | ||
console.error(err); | ||
}); | ||
}); | ||
} | ||
); |
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