sdk/js-query: fix SolanaPda mock for bad rentEpoch parsing

This commit is contained in:
Evan Gray 2024-03-11 10:51:42 -04:00 committed by Evan Gray
parent 2d141a1247
commit 405bd58580
4 changed files with 19 additions and 4 deletions

View File

@ -1,3 +1,11 @@
## 0.0.12
Fix SolanaPda mock for bad rentEpoch parsing
## 0.0.11
Add Solana PDA support
## 0.0.10 ## 0.0.10
Fix SolanaAccount mock for bad rentEpoch parsing Fix SolanaAccount mock for bad rentEpoch parsing

View File

@ -1,12 +1,12 @@
{ {
"name": "@wormhole-foundation/wormhole-query-sdk", "name": "@wormhole-foundation/wormhole-query-sdk",
"version": "0.0.11", "version": "0.0.12",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@wormhole-foundation/wormhole-query-sdk", "name": "@wormhole-foundation/wormhole-query-sdk",
"version": "0.0.11", "version": "0.0.12",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@ethersproject/keccak256": "^5.7.0", "@ethersproject/keccak256": "^5.7.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@wormhole-foundation/wormhole-query-sdk", "name": "@wormhole-foundation/wormhole-query-sdk",
"version": "0.0.11", "version": "0.0.12",
"description": "Wormhole cross-chain query SDK", "description": "Wormhole cross-chain query SDK",
"homepage": "https://wormhole.com", "homepage": "https://wormhole.com",
"main": "./lib/cjs/index.js", "main": "./lib/cjs/index.js",

View File

@ -559,11 +559,18 @@ export class QueryProxyMock {
let results: SolanaPdaResult[] = []; let results: SolanaPdaResult[] = [];
let idx = 0; let idx = 0;
response.data.result.value.forEach((val) => { response.data.result.value.forEach((val) => {
const rentEpoch = BigInt(val.rentEpoch);
results.push({ results.push({
account: Uint8Array.from(base58.decode(accounts[idx].toString())), account: Uint8Array.from(base58.decode(accounts[idx].toString())),
bump: bumps[idx], bump: bumps[idx],
lamports: BigInt(val.lamports), lamports: BigInt(val.lamports),
rentEpoch: BigInt(val.rentEpoch), rentEpoch:
// this is a band-aid for an axios / JSON.parse effect where numbers > Number.MAX_SAFE_INTEGER are not parsed correctly
// e.g. 18446744073709551615 becomes 18446744073709552000
// https://github.com/axios/axios/issues/4846
rentEpoch > SOLANA_MAX_RENT_EPOCH
? SOLANA_MAX_RENT_EPOCH
: rentEpoch,
executable: Boolean(val.executable), executable: Boolean(val.executable),
owner: Uint8Array.from(base58.decode(val.owner.toString())), owner: Uint8Array.from(base58.decode(val.owner.toString())),
data: Uint8Array.from( data: Uint8Array.from(