Skip to content

Commit 46627b4

Browse files
committed
Merge remote-tracking branch 'upstream/master' into ja-credentials
2 parents 0f5d330 + 034cb11 commit 46627b4

File tree

91 files changed

+3440
-483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3440
-483
lines changed

@l10n/ja/docs/references/protocol/transactions/transaction-results/tef-codes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ labels:
2828
| `tefINVARIANT_FAILED` | [トランザクションコスト](../../../../concepts/transactions/transaction-cost.md)を請求しようとしたところ、不変性チェックが失敗しました。[EnforceInvariants Amendment][]により追加されました。このエラーを再現できる場合は、[問題を報告](https://github.com/XRPLF/rippled/issues)してください。 |
2929
| `tefMASTER_DISABLED` | トランザクションはアカウントのマスターキーで署名されていましたが、アカウントに`lsfDisableMaster`フィールドが設定されていました。 |
3030
| `tefMAX_LEDGER` | トランザクションには[`LastLedgerSequence`](../../../../concepts/transactions/reliable-transaction-submission.md#lastledgersequence)パラメーターが指定されていましたが、現在のレジャーのシーケンス番号はすでに指定値を上回っています。 |
31-
| `tefNO_AUTH_REQUIRED` | [TrustSetトランザクション][]がトラストラインを承認済みとしてマークしようとしましたが、対応するアカウントに対して`lsfRequireAuth`フラグが有効になっていないため、承認は不要です|
31+
| `tefNO_AUTH_REQUIRED` | [TrustSetトランザクション][]で相手トラストラインを承認済みとしてマークしようとしましたが、自身のアカウントにおいて`lsfRequireAuth`フラグが有効になっていないため、承認できません|
3232
| `tefNOT_MULTI_SIGNING` | トランザクションは[マルチシグ](../../../../concepts/accounts/multi-signing.md)トランザクションでしたが、送信側アカウントでSignerListが定義されていません。 |
3333
| `tefPAST_SEQ` | トランザクションのシーケンス番号は、トランザクションの送信元アカウントの現在のシーケンス番号よりも小さい番号です。 |
3434
| `tefTOO_BIG` | レジャー内にある、トランザクションの影響を受けるオブジェクトが多過ぎます。例えば、これは[AccountDeleteトランザクション][]でしたが、削除されるアカウントのレジャーには1,000個を超えるオブジェクトがあります。 |

_code-samples/build-a-browser-wallet/js/index.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,25 @@ txHistoryButton.addEventListener('click', () => {
3636
});
3737

3838
// Fetch the wallet details
39-
getWalletDetails({ client })
40-
.then(({ account_data, accountReserves, xAddress, address }) => {
41-
walletElement.querySelector('.wallet_address').textContent = `Wallet Address: ${account_data.Account}`;
42-
walletElement.querySelector('.wallet_balance').textContent = `Wallet Balance: ${dropsToXrp(account_data.Balance)} XRP`;
43-
walletElement.querySelector('.wallet_reserve').textContent = `Wallet Reserve: ${accountReserves} XRP`;
44-
walletElement.querySelector('.wallet_xaddress').textContent = `X-Address: ${xAddress}`;
39+
let wallet_details
40+
try {
41+
wallet_details = await getWalletDetails({ client })
42+
} catch(error) {
43+
alert(`Error loading wallet: ${error}.\n\nMake sure you set the SEED in your .env file.`)
44+
return
45+
}
46+
const { account_data, accountReserve, xAddress, address } = wallet_details;
47+
walletElement.querySelector('.wallet_address').textContent = `Wallet Address: ${account_data.Account}`;
48+
walletElement.querySelector('.wallet_balance').textContent = `Wallet Balance: ${dropsToXrp(account_data.Balance)} XRP`;
49+
walletElement.querySelector('.wallet_reserve').textContent = `Wallet Reserve: ${accountReserve} XRP`;
50+
walletElement.querySelector('.wallet_xaddress').textContent = `X-Address: ${xAddress}`;
4551

46-
// Redirect on View More link click
47-
walletElement.querySelector('#view_more_button').addEventListener('click', () => {
48-
window.open(`https://${process.env.EXPLORER_NETWORK}.xrpl.org/accounts/${address}`, '_blank');
49-
});
50-
})
51-
.finally(() => {
52-
walletLoadingDiv.style.display = 'none';
53-
});
52+
// Redirect on View More link click
53+
walletElement.querySelector('#view_more_button').addEventListener('click', () => {
54+
window.open(`https://${process.env.EXPLORER_NETWORK}.xrpl.org/accounts/${address}`, '_blank');
55+
});
56+
57+
walletLoadingDiv.style.display = 'none';
5458

5559

5660
// Fetch the latest ledger details

_code-samples/build-a-browser-wallet/js/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
"dev": "vite"
66
},
77
"devDependencies": {
8-
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
98
"crypto-browserify": "^3.12.0",
109
"events": "^3.3.0",
1110
"https-browserify": "^1.0.0",
12-
"rollup-plugin-polyfill-node": "^0.12.0",
1311
"stream-browserify": "^3.0.0",
1412
"stream-http": "^3.2.0",
15-
"vite": "^4.5.5"
13+
"vite": "^4.5.9"
1614
},
1715
"dependencies": {
1816
"dotenv": "^16.0.3",
Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1-
import { Client, Wallet, classicAddressToXAddress } from 'xrpl';
1+
import { Wallet, classicAddressToXAddress } from 'xrpl';
22

33
export default async function getWalletDetails({ client }) {
4-
try {
5-
const wallet = Wallet.fromSeed(process.env.SEED); // Convert the seed to a wallet : https://xrpl.org/cryptographic-keys.html
4+
const wallet = Wallet.fromSeed(process.env.SEED);
65

7-
// Get the wallet details: https://xrpl.org/account_info.html
8-
const {
9-
result: { account_data },
10-
} = await client.request({
11-
command: 'account_info',
12-
account: wallet.address,
13-
ledger_index: 'validated',
14-
});
6+
// Get the wallet details
7+
const {
8+
result: { account_data },
9+
} = await client.request({
10+
command: 'account_info',
11+
account: wallet.address,
12+
ledger_index: 'validated',
13+
});
1514

16-
const ownerCount = account_data.OwnerCount || 0;
15+
const ownerCount = account_data.OwnerCount || 0;
1716

18-
// Get the reserve base and increment
19-
const {
20-
result: {
21-
info: {
22-
validated_ledger: { reserve_base_xrp, reserve_inc_xrp },
23-
},
17+
// Get the reserve base and increment
18+
const {
19+
result: {
20+
info: {
21+
validated_ledger: { reserve_base_xrp, reserve_inc_xrp },
2422
},
25-
} = await client.request({
26-
command: 'server_info',
27-
});
23+
},
24+
} = await client.request({
25+
command: 'server_info',
26+
});
2827

29-
// Calculate the reserves by multiplying the owner count by the increment and adding the base reserve to it.
30-
const accountReserves = ownerCount * reserve_inc_xrp + reserve_base_xrp;
28+
// Calculate the total reserve amount
29+
const accountReserve = ownerCount * reserve_inc_xrp + reserve_base_xrp;
3130

32-
console.log('Got wallet details!');
31+
console.log('Got wallet details!');
3332

34-
return {
35-
account_data,
36-
accountReserves,
37-
xAddress: classicAddressToXAddress(wallet.address, false, false), // Learn more: https://xrpaddress.info/
38-
address: wallet.address
39-
};
40-
} catch (error) {
41-
console.log('Error getting wallet details', error);
42-
return error;
43-
}
33+
return {
34+
account_data,
35+
accountReserve,
36+
xAddress: classicAddressToXAddress(wallet.address, false, false),
37+
address: wallet.address
38+
};
4439
}

_code-samples/build-a-browser-wallet/js/src/helpers/submit-transaction.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { Wallet } from 'xrpl';
33
export default async function submitTransaction({ client, tx }) {
44
try {
55
// Create a wallet using the seed
6-
const wallet = await Wallet.fromSeed(process.env.SEED);
6+
const wallet = Wallet.fromSeed(process.env.SEED);
77
tx.Account = wallet.address;
88

9-
// Sign and submit the transaction : https://xrpl.org/send-xrp.html#send-xrp
9+
// Sign and submit the transaction
1010
const response = await client.submit(tx, { wallet });
1111
console.log(response);
1212

_code-samples/build-a-browser-wallet/js/src/send-xrp/send-xrp.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import submitTransaction from '../helpers/submit-transaction';
77
// Optional: Render the XRPL logo
88
renderXrplLogo();
99

10-
const client = new Client(process.env.CLIENT); // Get the client from the environment variables
10+
// Get the client from the environment variables
11+
const client = new Client(process.env.CLIENT);
1112

1213
// Self-invoking function to connect to the client
1314
(async () => {
1415
try {
15-
await client.connect(); // Connect to the client
16+
await client.connect();
1617

17-
const wallet = Wallet.fromSeed(process.env.SEED); // Convert the seed to a wallet : https://xrpl.org/cryptographic-keys.html
18+
const wallet = Wallet.fromSeed(process.env.SEED);
1819

1920
// Subscribe to account transaction stream
2021
await client.request({
@@ -23,8 +24,10 @@ const client = new Client(process.env.CLIENT); // Get the client from the enviro
2324
});
2425

2526
// Fetch the wallet details and show the available balance
26-
await getWalletDetails({ client }).then(({ accountReserves, account_data }) => {
27-
availableBalanceElement.textContent = `Available Balance: ${dropsToXrp(account_data.Balance) - accountReserves} XRP`;
27+
await getWalletDetails({ client }).then((
28+
{ accountReserve, account_data }) => {
29+
const bal = dropsToXrp(account_data.Balance) - accountReserve;
30+
availableBalanceElement.textContent = `Available Balance: ${bal} XRP`;
2831
});
2932

3033
} catch (error) {
@@ -58,9 +61,10 @@ txHistoryButton.addEventListener('click', () => {
5861

5962
// Update the account balance on successful transaction
6063
client.on('transaction', (response) => {
61-
if (response.validated && response.transaction.TransactionType === 'Payment') {
62-
getWalletDetails({ client }).then(({ accountReserves, account_data }) => {
63-
availableBalanceElement.textContent = `Available Balance: ${dropsToXrp(account_data.Balance) - accountReserves} XRP`;
64+
if (response.validated && response.tx_json.TransactionType === 'Payment') {
65+
getWalletDetails({ client }).then(({ accountReserve, account_data }) => {
66+
const bal = dropsToXrp(account_data.Balance) - accountReserve;
67+
availableBalanceElement.textContent = `Available Balance: ${bal} XRP`;
6468
});
6569
}
6670
});
@@ -113,23 +117,25 @@ submitTxBtn.addEventListener('click', async () => {
113117
submitTxBtn.disabled = true;
114118
submitTxBtn.textContent = 'Submitting...';
115119

116-
// Create the transaction object: https://xrpl.org/transaction-common-fields.html
120+
// Create the transaction object
117121
const txJson = {
118122
TransactionType: 'Payment',
119-
Amount: xrpToDrops(amount.value), // Convert XRP to drops: https://xrpl.org/basic-data-types.html#specifying-currency-amounts
123+
Amount: xrpToDrops(amount.value),
120124
Destination: destinationAddress.value,
121125
};
122126

123127
// Get the destination tag if it exists
124128
if (destinationTag?.value !== '') {
125-
txJson.DestinationTag = destinationTag.value;
129+
txJson.DestinationTag = parseInt(destinationTag.value);
126130
}
131+
console.log("Sending...", txJson);
127132

128133
// Submit the transaction to the ledger
129134
const { result } = await submitTransaction({ client, tx: txJson });
130-
const txResult = result?.meta?.TransactionResult || result?.engine_result || ''; // Response format: https://xrpl.org/transaction-results.html
135+
const txResult = result?.meta?.TransactionResult || result?.engine_result || '';
131136

132-
// Check if the transaction was successful or not and show the appropriate message to the user
137+
// Check if the transaction was successful or not
138+
// and show the appropriate message to the user
133139
if (txResult === 'tesSUCCESS') {
134140
alert('Transaction submitted successfully!');
135141
} else {
@@ -138,8 +144,10 @@ submitTxBtn.addEventListener('click', async () => {
138144
} catch (error) {
139145
alert('Error submitting transaction, Please try again.');
140146
console.error(error);
147+
submitTxBtn.disabled = false;
141148
} finally {
142-
// Re-enable the submit button after the transaction is submitted so the user can submit another transaction
149+
// Re-enable the submit button after the transaction is submitted
150+
// so the user can submit another transaction
143151
submitTxBtn.disabled = false;
144152
submitTxBtn.textContent = 'Submit Transaction';
145153
}

_code-samples/build-a-browser-wallet/js/src/transaction-history/transaction-history.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ async function fetchTxHistory() {
102102

103103
// Add the transactions to the table
104104
const values = transactions.map((transaction) => {
105-
const { meta, tx } = transaction;
105+
const { hash, meta, tx_json } = transaction;
106106
return {
107-
Account: tx.Account,
108-
Destination: tx.Destination,
109-
Fee: tx.Fee,
110-
Hash: tx.hash,
111-
TransactionType: tx.TransactionType,
107+
Account: tx_json.Account,
108+
Destination: tx_json.Destination,
109+
Fee: tx_json.Fee,
110+
Hash: hash,
111+
TransactionType: tx_json.TransactionType,
112112
result: meta?.TransactionResult,
113113
delivered: meta?.delivered_amount
114114
};

_code-samples/build-a-browser-wallet/js/vite.config.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,11 @@
11
import { defineConfig, loadEnv } from 'vite';
22

3-
import polyfillNode from 'rollup-plugin-polyfill-node';
4-
53
const viteConfig = ({ mode }) => {
64
process.env = { ...process.env, ...loadEnv(mode, '', '') };
75
return defineConfig({
86
define: {
97
'process.env': process.env,
108
},
11-
optimizeDeps: {
12-
esbuildOptions: {
13-
define: {
14-
global: 'globalThis',
15-
},
16-
},
17-
},
18-
build: {
19-
rollupOptions: {
20-
plugins: [polyfillNode()],
21-
},
22-
},
239
resolve: {
2410
alias: {
2511
ws: 'xrpl/dist/npm/client/WSWrapper',

0 commit comments

Comments
 (0)