Skip to content

Commit

Permalink
Merge pull request #2847 from XRPLF/api-v2-code
Browse files Browse the repository at this point in the history
apiv2 code updates
  • Loading branch information
oeggert authored Nov 19, 2024
2 parents b6425c1 + 20afacf commit 34ad6e8
Show file tree
Hide file tree
Showing 57 changed files with 78 additions and 104 deletions.
2 changes: 1 addition & 1 deletion _code-samples/airgapped-wallet/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"pbkdf2-hmac": "^1.1.0",
"prompt": "^1.3.0",
"qrcode": "^1.5.1",
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
},
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/airgapped-wallet/py/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cryptography==43.0.1
Pillow==10.3.0
qrcode==7.2
xrpl-py==3.0.0
xrpl-py>=3.0.0
2 changes: 1 addition & 1 deletion _code-samples/auction-slot/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"xrpl": "^3.0.0",
"xrpl": "^4.0.0",
"bignumber.js": "^9.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/build-a-browser-wallet/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
},
"dependencies": {
"dotenv": "^16.0.3",
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/build-a-desktop-wallet/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"pbkdf2-hmac": "^1.1.0",
"open": "^8.4.0",
"toml": "^3.0.0",
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
},
"devDependencies": {
"electron": "22.3.25"
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/build-a-desktop-wallet/py/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
xrpl-py==2.0.0
xrpl-py>=3.0.0
wxPython==4.2.1
toml==0.10.2
requests==2.32.0
2 changes: 1 addition & 1 deletion _code-samples/checks/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"version": "0.0.2",
"license": "MIT",
"dependencies": {
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/create-amm/js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"xrpl": "3.0.0"
"xrpl": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/create-amm/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"dotenv": "^16.3.1",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"xrpl": "3.0.0"
"xrpl": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/escrow/js/create-escrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async function main() {
JSON.stringify(escrowCreateTransaction, null, "\t"), "\n"
);
const response = await client.submitAndWait(escrowCreateTransaction, { wallet });
console.log(`Sequence number: ${response.result.Sequence}`);
console.log(`Sequence number: ${response.result.tx_json.Sequence}`);
console.log(`Finished submitting! ${JSON.stringify(response.result, null, "\t")}`);

await client.disconnect();
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/escrow/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"license": "MIT",
"dependencies": {
"five-bells-condition": "*",
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
}
}
4 changes: 2 additions & 2 deletions _code-samples/escrow/py/create_escrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@


# Parse result and print out the neccesary info
print(stxn_result["Account"])
print(stxn_result["Sequence"])
print(stxn_result["tx_json"]["Account"])
print(stxn_result["tx_json"]["Sequence"])

print(stxn_result["meta"]["TransactionResult"])
print(stxn_result["hash"])
2 changes: 1 addition & 1 deletion _code-samples/escrow/py/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
xrpl-py
xrpl-py>=3.0.0
cryptoconditions
2 changes: 1 addition & 1 deletion _code-samples/freeze/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "0.1.0",
"license": "MIT",
"dependencies": {
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/freeze/py/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
xrpl-py
xrpl-py>=3.0.0
2 changes: 1 addition & 1 deletion _code-samples/get-started/js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/issue-a-token/js/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<title>Code Sample - Issue a Token</title>
<script src="https://unpkg.com/xrpl@2.0.0/build/xrpl-latest-min.js"></script>
<script src="https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js"></script>
<script type="application/javascript" src="issue-a-token.js"></script>
</head>
<body>Open your browser's console (F12) to see the logs.</body>
Expand Down
6 changes: 3 additions & 3 deletions _code-samples/issue-a-token/js/issue-a-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async function main() {
const send_token_tx = {
"TransactionType": "Payment",
"Account": cold_wallet.address,
"Amount": {
"DeliverMax": {
"currency": currency_code,
"value": issue_quantity,
"issuer": cold_wallet.address
Expand All @@ -171,7 +171,7 @@ async function main() {
const send_token_tx2 = {
"TransactionType": "Payment",
"Account": hot_wallet.address,
"Amount": {
"DeliverMax": {
"currency": currency_code,
"value": issue_quantity,
"issuer": cold_wallet.address
Expand All @@ -197,7 +197,7 @@ async function main() {
const send_token_tx3 = {
"TransactionType": "Payment",
"Account": customer_one_wallet.address,
"Amount": {
"DeliverMax": {
"currency": currency_code,
"value": issue_quantity,
"issuer": cold_wallet.address
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/issue-a-token/js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/key-derivation/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"ripple-address-codec": "^5.0.0",
"ripple-keypairs": "^2.0.0",
"secp256k1": "^5.0.0",
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
},
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ async function do_subscribe() {
}

const log_tx = function(tx) {
console.log(tx.transaction.TransactionType + " transaction sent by " +
tx.transaction.Account +
console.log(tx.tx_json.TransactionType + " transaction sent by " +
tx.tx_json.Account +
"\n Result: " + tx.meta.TransactionResult +
" in ledger " + tx.ledger_index +
"\n Validated? " + tx.validated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function CountXRPReceived(tx, address) {
console.log("Transaction failed.")
return
}
if (tx.transaction.TransactionType === "Payment") {
if (tx.transaction.Destination !== address) {
if (tx.tx_json.TransactionType === "Payment") {
if (tx.tx_json.Destination !== address) {
console.log("Not the destination of this payment.")
return
}
Expand All @@ -67,10 +67,10 @@ function CountXRPReceived(tx, address) {
}
} else if (["PaymentChannelClaim", "PaymentChannelFund", "OfferCreate",
"CheckCash", "EscrowFinish"].includes(
tx.transaction.TransactionType)) {
tx.tx_json.TransactionType)) {
CountXRPDifference(tx.meta.AffectedNodes, address)
} else {
console.log("Not a currency-delivering transaction type (" +
tx.transaction.TransactionType + ").")
tx.tx_json.TransactionType + ").")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ def CountXRPReceived(tx, address):
if tx['meta']['TransactionResult'] != 'tesSUCCESS':
print("Transaction failed")
return
if tx['transaction']['TransactionType'] == 'Payment':
if tx['transaction']['Destination'] != address:
if tx['tx_json']['TransactionType'] == 'Payment':
if tx['tx_json']['Destination'] != address:
print("Not the destination of this payment.")
return
if tx['meta']['delivered_amount'] is int or str:
amount_in_drops = int(tx['transaction']['Amount'])
amount_in_drops = int(tx['tx_json']['DeliverMax'])
xrp_amount = (amount_in_drops / 1000000)
print(f"Received {xrp_amount} XRP")
return
else:
print("Received non-XRP currency")
elif tx['transaction']['TransactionType'] == 'PaymentChannelClaim' or 'PaymentChannelFund' or'OfferCreate' or 'CheckCash' or 'EscrowFinish':
elif tx['tx_json']['TransactionType'] == 'PaymentChannelClaim' or 'PaymentChannelFund' or'OfferCreate' or 'CheckCash' or 'EscrowFinish':
FindXRPDifference(tx, address)
else:
print("Not a currency-delivering transaction type", tx['transaction']['TransactionType'])
print("Not a currency-delivering transaction type", tx['tx_json']['TransactionType'])

CountXRPReceived(tx=transaction, address='rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe')

Expand Down
2 changes: 1 addition & 1 deletion _code-samples/non-fungible-token/js/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"xrpl": "^3.0.0"
"xrpl": "^4.0.0"
}
}
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/1.get-accounts-send-xrp.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script>
if (typeof module !== "undefined") {
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/10.check.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex10-check.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/11.create-amm.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex11-create-amm.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/12.add-to-amm.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex11-create-amm.js'></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='https://unpkg.com/bignumber.js@9.1.2/bignumber.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/3.mint-nfts.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/3a.CreateOffer.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex3a-create-offers.js'></script>
<script src='ripplex3b-NameFieldSupport.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/4.transfer-nfts.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/5.broker-nfts.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/6.authorized-minter.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/7.batch-minting.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex3-mint-nfts.js'></script>
<script src='ripplex7-batch-minting.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/8.escrow.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex8-escrow.js'></script>
Expand Down
2 changes: 1 addition & 1 deletion _code-samples/quickstart/js/9.escrow-condition.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
button{font-weight: bold;font-family: "Work Sans", sans-serif;}
td{vertical-align: middle;}
</style>
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
<script src='https://unpkg.com/xrpl@4.0.0/build/xrpl-latest.js'></script>
<script src='ripplex1-send-xrp.js'></script>
<script src='ripplex2-send-currency.js'></script>
<script src='ripplex8-escrow.js'></script>
Expand Down
4 changes: 2 additions & 2 deletions _code-samples/quickstart/js/ripplex1-send-xrp.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async function sendXRP() {
const prepared = await client.autofill({
"TransactionType": "Payment",
"Account": standby_wallet.address,
"Amount": xrpl.xrpToDrops(sendAmount),
"DeliverMax": xrpl.xrpToDrops(sendAmount),
"Destination": standbyDestinationField.value
})

Expand Down Expand Up @@ -178,7 +178,7 @@ async function oPsendXRP() {
const prepared = await client.autofill({
"TransactionType": "Payment",
"Account": operational_wallet.address,
"Amount": xrpl.xrpToDrops(operationalAmountField.value),
"DeliverMax": xrpl.xrpToDrops(operationalAmountField.value),
"Destination": operationalDestinationField.value
})

Expand Down
Loading

0 comments on commit 34ad6e8

Please sign in to comment.