fix: adapt to binary64 -> base64 rename
This commit is contained in:
parent
d527e39c64
commit
eb83604eaf
|
@ -713,7 +713,7 @@ const GetTokenAccountsByOwner = jsonRpcResultAndContext(
|
||||||
executable: 'boolean',
|
executable: 'boolean',
|
||||||
owner: 'string',
|
owner: 'string',
|
||||||
lamports: 'number',
|
lamports: 'number',
|
||||||
data: ['string', struct.literal('binary64')],
|
data: ['string', struct.literal('base64')],
|
||||||
rentEpoch: 'number?',
|
rentEpoch: 'number?',
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
@ -795,7 +795,7 @@ const ParsedAccountInfoResult = struct.object({
|
||||||
owner: 'string',
|
owner: 'string',
|
||||||
lamports: 'number',
|
lamports: 'number',
|
||||||
data: struct.union([
|
data: struct.union([
|
||||||
['string', struct.literal('binary64')],
|
['string', struct.literal('base64')],
|
||||||
struct.pick({
|
struct.pick({
|
||||||
program: 'string',
|
program: 'string',
|
||||||
parsed: 'any',
|
parsed: 'any',
|
||||||
|
@ -1613,7 +1613,7 @@ export class Connection {
|
||||||
_args.push({programId: filter.programId.toBase58()});
|
_args.push({programId: filter.programId.toBase58()});
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = this._buildArgs(_args, commitment, 'binary64');
|
const args = this._buildArgs(_args, commitment, 'base64');
|
||||||
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);
|
||||||
const res = GetTokenAccountsByOwner(unsafeRes);
|
const res = GetTokenAccountsByOwner(unsafeRes);
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
|
@ -1632,7 +1632,7 @@ export class Connection {
|
||||||
return {
|
return {
|
||||||
context,
|
context,
|
||||||
value: value.map(result => {
|
value: value.map(result => {
|
||||||
assert(result.account.data[1] === 'binary64');
|
assert(result.account.data[1] === 'base64');
|
||||||
return {
|
return {
|
||||||
pubkey: new PublicKey(result.pubkey),
|
pubkey: new PublicKey(result.pubkey),
|
||||||
account: {
|
account: {
|
||||||
|
@ -1755,7 +1755,7 @@ export class Connection {
|
||||||
const args = this._buildArgs(
|
const args = this._buildArgs(
|
||||||
[publicKey.toBase58()],
|
[publicKey.toBase58()],
|
||||||
commitment,
|
commitment,
|
||||||
'binary64',
|
'base64',
|
||||||
);
|
);
|
||||||
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
const unsafeRes = await this._rpcRequest('getAccountInfo', args);
|
||||||
const res = GetAccountInfoAndContextRpcResult(unsafeRes);
|
const res = GetAccountInfoAndContextRpcResult(unsafeRes);
|
||||||
|
@ -1772,7 +1772,7 @@ export class Connection {
|
||||||
let value = null;
|
let value = null;
|
||||||
if (res.result.value) {
|
if (res.result.value) {
|
||||||
const {executable, owner, lamports, data} = res.result.value;
|
const {executable, owner, lamports, data} = res.result.value;
|
||||||
assert(data[1] === 'binary64');
|
assert(data[1] === 'base64');
|
||||||
value = {
|
value = {
|
||||||
executable,
|
executable,
|
||||||
owner: new PublicKey(owner),
|
owner: new PublicKey(owner),
|
||||||
|
@ -1821,7 +1821,7 @@ export class Connection {
|
||||||
|
|
||||||
let data = resultData;
|
let data = resultData;
|
||||||
if (!data.program) {
|
if (!data.program) {
|
||||||
assert(data[1] === 'binary64');
|
assert(data[1] === 'base64');
|
||||||
data = Buffer.from(data[0], 'base64');
|
data = Buffer.from(data[0], 'base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1869,7 +1869,7 @@ export class Connection {
|
||||||
const args = this._buildArgs(
|
const args = this._buildArgs(
|
||||||
[programId.toBase58()],
|
[programId.toBase58()],
|
||||||
commitment,
|
commitment,
|
||||||
'binary64',
|
'base64',
|
||||||
);
|
);
|
||||||
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
const unsafeRes = await this._rpcRequest('getProgramAccounts', args);
|
||||||
const res = GetProgramAccountsRpcResult(unsafeRes);
|
const res = GetProgramAccountsRpcResult(unsafeRes);
|
||||||
|
@ -1886,7 +1886,7 @@ export class Connection {
|
||||||
assert(typeof result !== 'undefined');
|
assert(typeof result !== 'undefined');
|
||||||
|
|
||||||
return result.map(result => {
|
return result.map(result => {
|
||||||
assert(result.account.data[1] === 'binary64');
|
assert(result.account.data[1] === 'base64');
|
||||||
return {
|
return {
|
||||||
pubkey: new PublicKey(result.pubkey),
|
pubkey: new PublicKey(result.pubkey),
|
||||||
account: {
|
account: {
|
||||||
|
@ -1937,7 +1937,7 @@ export class Connection {
|
||||||
|
|
||||||
let data = resultData;
|
let data = resultData;
|
||||||
if (!data.program) {
|
if (!data.program) {
|
||||||
assert(data[1] === 'binary64');
|
assert(data[1] === 'base64');
|
||||||
data = Buffer.from(data[0], 'base64');
|
data = Buffer.from(data[0], 'base64');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2783,7 +2783,7 @@ export class Connection {
|
||||||
this._subscribe(
|
this._subscribe(
|
||||||
sub,
|
sub,
|
||||||
'accountSubscribe',
|
'accountSubscribe',
|
||||||
this._buildArgs([sub.publicKey], sub.commitment, 'binary64'),
|
this._buildArgs([sub.publicKey], sub.commitment, 'base64'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2792,7 +2792,7 @@ export class Connection {
|
||||||
this._subscribe(
|
this._subscribe(
|
||||||
sub,
|
sub,
|
||||||
'programSubscribe',
|
'programSubscribe',
|
||||||
this._buildArgs([sub.programId], sub.commitment, 'binary64'),
|
this._buildArgs([sub.programId], sub.commitment, 'base64'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2906,7 +2906,7 @@ export class Connection {
|
||||||
const {result} = res;
|
const {result} = res;
|
||||||
const {value, context} = result;
|
const {value, context} = result;
|
||||||
|
|
||||||
assert(value.account.data[1] === 'binary64');
|
assert(value.account.data[1] === 'base64');
|
||||||
sub.callback(
|
sub.callback(
|
||||||
{
|
{
|
||||||
accountId: value.pubkey,
|
accountId: value.pubkey,
|
||||||
|
@ -3024,7 +3024,7 @@ export class Connection {
|
||||||
_buildArgs(
|
_buildArgs(
|
||||||
args: Array<any>,
|
args: Array<any>,
|
||||||
override: ?Commitment,
|
override: ?Commitment,
|
||||||
encoding?: 'jsonParsed' | 'binary64',
|
encoding?: 'jsonParsed' | 'base64',
|
||||||
): Array<any> {
|
): Array<any> {
|
||||||
const commitment = override || this._commitment;
|
const commitment = override || this._commitment;
|
||||||
if (commitment || encoding) {
|
if (commitment || encoding) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ test('get account info - not found', async () => {
|
||||||
url,
|
url,
|
||||||
{
|
{
|
||||||
method: 'getAccountInfo',
|
method: 'getAccountInfo',
|
||||||
params: [account.publicKey.toBase58(), {encoding: 'binary64'}],
|
params: [account.publicKey.toBase58(), {encoding: 'base64'}],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
error: null,
|
error: null,
|
||||||
|
@ -255,7 +255,7 @@ test('get program accounts', async () => {
|
||||||
method: 'getProgramAccounts',
|
method: 'getProgramAccounts',
|
||||||
params: [
|
params: [
|
||||||
programId.publicKey.toBase58(),
|
programId.publicKey.toBase58(),
|
||||||
{commitment: 'recent', encoding: 'binary64'},
|
{commitment: 'recent', encoding: 'base64'},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -263,7 +263,7 @@ test('get program accounts', async () => {
|
||||||
result: [
|
result: [
|
||||||
{
|
{
|
||||||
account: {
|
account: {
|
||||||
data: ['', 'binary64'],
|
data: ['', 'base64'],
|
||||||
executable: false,
|
executable: false,
|
||||||
lamports: LAMPORTS_PER_SOL - feeCalculator.lamportsPerSignature,
|
lamports: LAMPORTS_PER_SOL - feeCalculator.lamportsPerSignature,
|
||||||
owner: programId.publicKey.toBase58(),
|
owner: programId.publicKey.toBase58(),
|
||||||
|
@ -273,7 +273,7 @@ test('get program accounts', async () => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
account: {
|
account: {
|
||||||
data: ['', 'binary64'],
|
data: ['', 'base64'],
|
||||||
executable: false,
|
executable: false,
|
||||||
lamports:
|
lamports:
|
||||||
0.5 * LAMPORTS_PER_SOL - feeCalculator.lamportsPerSignature,
|
0.5 * LAMPORTS_PER_SOL - feeCalculator.lamportsPerSignature,
|
||||||
|
@ -1681,7 +1681,7 @@ test('request airdrop', async () => {
|
||||||
method: 'getAccountInfo',
|
method: 'getAccountInfo',
|
||||||
params: [
|
params: [
|
||||||
account.publicKey.toBase58(),
|
account.publicKey.toBase58(),
|
||||||
{commitment: 'recent', encoding: 'binary64'},
|
{commitment: 'recent', encoding: 'base64'},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1693,7 +1693,7 @@ test('request airdrop', async () => {
|
||||||
value: {
|
value: {
|
||||||
owner: '11111111111111111111111111111111',
|
owner: '11111111111111111111111111111111',
|
||||||
lamports: minimumAmount + 42,
|
lamports: minimumAmount + 42,
|
||||||
data: ['', 'binary64'],
|
data: ['', 'base64'],
|
||||||
executable: false,
|
executable: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1727,7 +1727,7 @@ test('request airdrop', async () => {
|
||||||
value: {
|
value: {
|
||||||
owner: '11111111111111111111111111111111',
|
owner: '11111111111111111111111111111111',
|
||||||
lamports: minimumAmount + 42,
|
lamports: minimumAmount + 42,
|
||||||
data: ['', 'binary64'],
|
data: ['', 'base64'],
|
||||||
executable: false,
|
executable: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -22,7 +22,7 @@ const expectedData = (authorizedPubkey: PublicKey): [string, string] => {
|
||||||
const mockNonce = new Account();
|
const mockNonce = new Account();
|
||||||
mockNonce.publicKey.toBuffer().copy(expectedData, 40); // Hash, 32 bytes
|
mockNonce.publicKey.toBuffer().copy(expectedData, 40); // Hash, 32 bytes
|
||||||
expectedData.writeUInt16LE(5000, 72); // feeCalculator, 8 bytes
|
expectedData.writeUInt16LE(5000, 72); // feeCalculator, 8 bytes
|
||||||
return [expectedData.toString('base64'), 'binary64'];
|
return [expectedData.toString('base64'), 'base64'];
|
||||||
};
|
};
|
||||||
|
|
||||||
test('create and query nonce account', async () => {
|
test('create and query nonce account', async () => {
|
||||||
|
@ -121,7 +121,7 @@ test('create and query nonce account', async () => {
|
||||||
method: 'getAccountInfo',
|
method: 'getAccountInfo',
|
||||||
params: [
|
params: [
|
||||||
nonceAccount.publicKey.toBase58(),
|
nonceAccount.publicKey.toBase58(),
|
||||||
{encoding: 'binary64', commitment: 'recent'},
|
{encoding: 'base64', commitment: 'recent'},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -248,7 +248,7 @@ test('create and query nonce account with seed', async () => {
|
||||||
method: 'getAccountInfo',
|
method: 'getAccountInfo',
|
||||||
params: [
|
params: [
|
||||||
noncePubkey.toBase58(),
|
noncePubkey.toBase58(),
|
||||||
{encoding: 'binary64', commitment: 'recent'},
|
{encoding: 'base64', commitment: 'recent'},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue