if (!('contents' in resConfirmedFrontierBlockInfo) || resConfirmedFrontierBlockInfo.contents == null || typeof resConfirmedFrontierBlockInfo.contents !== 'object') {
throw new Error('Confirmed frontier block info contents not found')
}
- const confirmedFrontierContents: Record<string, string> = {}
+ const confirmedFrontierContents: Record<string, string> = Object.create(null)
for (const [k, v] of Object.entries(resConfirmedFrontierBlockInfo.contents)) {
confirmedFrontierContents[k] = v
}
if (!('contents' in resFrontierBlockInfo) || resFrontierBlockInfo.contents == null || typeof resFrontierBlockInfo.contents !== 'object') {
throw new Error('Frontier block info contents not found')
}
- const frontierContents: Record<string, string> = {}
+ const frontierContents: Record<string, string> = Object.create(null)
for (const [k, v] of Object.entries(resFrontierBlockInfo.contents)) {
frontierContents[k] = v
}
return new Promise((resolve, reject) => {
const requests = ids.map(id => db.get(id))
transaction.oncomplete = (event) => {
- const results: Record<string, T> = {}
+ const results: Record<string, T> = Object.create(null)
for (const request of requests) {
if (request?.result?.id != null) {
results[request.result.id] = request.error ?? request.result
} else if (request.result == null) {
reject('getAll request failed')
} else {
- const results: Record<string, T> = {}
+ const results: Record<string, T> = Object.create(null)
for (const result of request.result) {
results[result.id] = request.error ?? result
}
export function accounts_balances (body: unknown): AccountsBalancesResponse {
if (body != null && typeof body === 'object') {
- const response: AccountsBalancesResponse = {}
+ const response: AccountsBalancesResponse = Object.create(null)
if ('errors' in body && body.errors != null && typeof body.errors === 'object') {
for (const [address, error] of Object.entries(body.errors) as [string, unknown][]) {
throw new RpcError(error)
}
} catch (err: any) {
- response.errors ??= {}
+ response.errors ??= Object.create(null)
response.errors[address] = err?.message
}
}
if (data == null || typeof data !== 'object') {
throw new RpcError('Invalid account balance data')
}
- response.balances ??= {}
+ response.balances ??= Object.create(null)
response.balances[address] = account_balance(data)
} catch (err: any) {
- response.errors ??= {}
+ response.errors ??= Object.create(null)
response.errors[address] ??= err?.message
}
}
}
export function accounts_frontiers (body: unknown): AccountsFrontiersResponse {
- const response: AccountsFrontiersResponse = {}
+ const response: AccountsFrontiersResponse = Object.create(null)
if (body == null || typeof body !== 'object') {
return response
}
throw new RpcError('Invalid account address')
}
if (hex.is(frontier, 64)) {
- response.frontiers ??= {}
- response.frontiers[address] = frontier
+ response.frontiers ??= Object.create(null)
+ response.frontiers[address] = frontier
}
} catch (err: any) {
- response.errors ??= {}
+ response.errors ??= Object.create(null)
response.errors[address] = err?.message
}
}
throw new Error(error)
}
} catch (err: any) {
- response.errors ??= {}
+ response.errors ??= Object.create(null)
response.errors[address] = err?.message
}
}
export function blocks_info (body: unknown): BlocksInfoResponse {
if (body != null && typeof body === 'object') {
- const response: BlocksInfoResponse = {}
+ const response: BlocksInfoResponse = Object.create(null)
if ('errors' in body && body.errors != null && typeof body.errors === 'object') {
for (const [hash, error] of Object.entries(body.errors) as [string, unknown][]) {
throw new Error('Invalid blocks_info error')
}
} catch (err: any) {
- response.errors ??= {}
+ response.errors ??= Object.create(null)
response.errors[hash] = err?.message
}
}
for (const [hash, data] of Object.entries(body.blocks) as [string, unknown][]) {
try {
if (hex.is(hash)) {
- response.blocks ??= {}
+ response.blocks ??= Object.create(null)
response.blocks[hash] = block_info(data)
} else {
throw new Error('Invalid blocks_info hash')
}
} catch (err: any) {
- response.errors ??= {}
+ response.errors ??= Object.create(null)
response.errors[hash] ??= err?.message
}
}
}
})
.then((result: Record<string, boolean | number | string | ArrayBuffer> | void) => {
- result ??= {}
+ result ??= Object.create(null)
const transfer: ArrayBuffer[] = []
if (result) {
for (const r of Object.values(result)) {
}
return Promise.all(promises)
.then(results => {
- const data: Record<string, ArrayBuffer> = {}
+ const data: Record<string, ArrayBuffer> = Object.create(null)
for (const result of results) {
data[result.index] = result.publicKey
}
export async function _create (wallet: Wallet, vault: Vault, password?: string, mnemonicSalt?: string): Promise<{ mnemonic?: ArrayBuffer, seed?: ArrayBuffer }>
export async function _create (wallet: Wallet, vault: Vault, password: unknown, mnemonicSalt?: unknown): Promise<{ mnemonic?: ArrayBuffer, seed?: ArrayBuffer }> {
try {
- const result: { mnemonic?: ArrayBuffer, seed?: ArrayBuffer } = {}
+ const result: { mnemonic?: ArrayBuffer, seed?: ArrayBuffer } = Object.create(null)
const record = {
id: wallet.id,
type: wallet.type,
export const rpc = new Rpc(url, auth)
if (globalThis.sessionStorage == null) {
- let _sessionStorage = {}
+ let _sessionStorage = Object.create(null)
Object.defineProperty(globalThis, 'sessionStorage', {
value: {
length: Object.entries(_sessionStorage).length,
setItem: (key, value) => _sessionStorage[key] = value,
getItem: (key) => _sessionStorage[key],
removeItem: (key) => delete _sessionStorage[key],
- clear: () => _sessionStorage = {}
+ clear: () => _sessionStorage = Object.create(null)
},
configurable: true,
enumerable: true