mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-04 13:05:49 +00:00
Merge branch 'beta' into hooks
This commit is contained in:
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -39,7 +39,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@@ -50,7 +50,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -64,4 +64,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
||||
@@ -101,6 +101,7 @@ import {
|
||||
getXrpBalance,
|
||||
submit,
|
||||
submitAndWait,
|
||||
getNetworkID,
|
||||
} from '../sugar'
|
||||
import fundWallet from '../Wallet/fundWallet'
|
||||
|
||||
@@ -200,6 +201,13 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
public readonly maxFeeXRP: string
|
||||
|
||||
/**
|
||||
* Network ID of the server this sdk is connected to
|
||||
*
|
||||
* @category Fee
|
||||
*/
|
||||
public networkID: number
|
||||
|
||||
/**
|
||||
* Creates a new Client with a websocket connection to a rippled server.
|
||||
*
|
||||
@@ -218,6 +226,7 @@ class Client extends EventEmitter {
|
||||
|
||||
this.feeCushion = options.feeCushion ?? DEFAULT_FEE_CUSHION
|
||||
this.maxFeeXRP = options.maxFeeXRP ?? DEFAULT_MAX_FEE_XRP
|
||||
this.networkID = 1
|
||||
|
||||
this.connection = new Connection(server, options)
|
||||
|
||||
@@ -634,6 +643,11 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
public getLedgerIndex = getLedgerIndex
|
||||
|
||||
/**
|
||||
* @category Abstraction
|
||||
*/
|
||||
public getNetworkID = getNetworkID
|
||||
|
||||
/**
|
||||
* @category Faucet
|
||||
*/
|
||||
|
||||
@@ -136,6 +136,10 @@ export interface ServerInfoResponse extends BaseResponse {
|
||||
* overall network's load factor.
|
||||
*/
|
||||
load_factor?: number
|
||||
/**
|
||||
* The network id of the server.
|
||||
*/
|
||||
network_id?: number
|
||||
/**
|
||||
* Current multiplier to the transaction cost based on
|
||||
* load to this server.
|
||||
|
||||
@@ -159,6 +159,10 @@ export interface BaseTransaction {
|
||||
* account it says it is from.
|
||||
*/
|
||||
TxnSignature?: string
|
||||
/**
|
||||
* The network id of the transaction.
|
||||
*/
|
||||
NetworkID?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,6 +256,9 @@ export function validateBaseTransaction(common: Record<string, unknown>): void {
|
||||
) {
|
||||
throw new ValidationError('BaseTransaction: invalid TxnSignature')
|
||||
}
|
||||
if (common.NetworkID !== undefined && typeof common.NetworkID !== 'number') {
|
||||
throw new ValidationError('BaseTransaction: invalid NetworkID')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ import { getFeeXrp } from './getFeeXrp'
|
||||
|
||||
// Expire unconfirmed transactions after 20 ledger versions, approximately 1 minute, by default
|
||||
const LEDGER_OFFSET = 20
|
||||
const RESTRICTED_NETWORKS = 1024
|
||||
interface ClassicAccountAndTag {
|
||||
classicAccount: string
|
||||
tag: number | false | undefined
|
||||
@@ -39,8 +40,10 @@ async function autofill<T extends Transaction>(
|
||||
setValidAddresses(tx)
|
||||
|
||||
setTransactionFlagsToNumber(tx)
|
||||
|
||||
const promises: Array<Promise<void>> = []
|
||||
if (this.networkID > RESTRICTED_NETWORKS && tx.NetworkID == null) {
|
||||
tx.NetworkID = this.networkID
|
||||
}
|
||||
if (tx.Sequence == null) {
|
||||
promises.push(setNextValidSequenceNumber(this, tx))
|
||||
}
|
||||
|
||||
15
packages/xrpl/src/sugar/getNetworkID.ts
Normal file
15
packages/xrpl/src/sugar/getNetworkID.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { Client } from '..'
|
||||
// import { XrplError } from '../errors'
|
||||
|
||||
/**
|
||||
* Returns the network ID of the rippled server.
|
||||
*
|
||||
* @param this - The Client used to connect to the ledger.
|
||||
* @returns The network id.
|
||||
*/
|
||||
export default async function getNetworkID(this: Client): Promise<number> {
|
||||
const response = await this.request({
|
||||
command: 'server_info',
|
||||
})
|
||||
return response.result.info.network_id ?? 1
|
||||
}
|
||||
@@ -7,6 +7,8 @@ export { default as getLedgerIndex } from './getLedgerIndex'
|
||||
export { default as getOrderbook } from './getOrderbook'
|
||||
export { getFeeXrp, getFeeEstimateXrp } from './getFeeXrp'
|
||||
|
||||
export { default as getNetworkID } from './getNetworkID'
|
||||
|
||||
export * from './submit'
|
||||
|
||||
export * from './utils'
|
||||
|
||||
Reference in New Issue
Block a user