@wormhole-foundation/sdk-solana 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/utils/utils/account.d.ts +5 -2
- package/dist/cjs/utils/utils/account.d.ts.map +1 -1
- package/dist/cjs/utils/utils/account.js +2 -8
- package/dist/cjs/utils/utils/account.js.map +1 -1
- package/dist/cjs/utils/utils/bpfLoaderUpgradeable.d.ts +22 -4
- package/dist/cjs/utils/utils/bpfLoaderUpgradeable.d.ts.map +1 -1
- package/dist/cjs/utils/utils/bpfLoaderUpgradeable.js +34 -8
- package/dist/cjs/utils/utils/bpfLoaderUpgradeable.js.map +1 -1
- package/dist/esm/utils/utils/account.d.ts +5 -2
- package/dist/esm/utils/utils/account.d.ts.map +1 -1
- package/dist/esm/utils/utils/account.js +2 -8
- package/dist/esm/utils/utils/account.js.map +1 -1
- package/dist/esm/utils/utils/bpfLoaderUpgradeable.d.ts +22 -4
- package/dist/esm/utils/utils/bpfLoaderUpgradeable.d.ts.map +1 -1
- package/dist/esm/utils/utils/bpfLoaderUpgradeable.js +32 -5
- package/dist/esm/utils/utils/bpfLoaderUpgradeable.js.map +1 -1
- package/package.json +2 -2
|
@@ -4,11 +4,13 @@ import { PublicKey } from '@solana/web3.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Find valid program address. See {@link PublicKey.findProgramAddressSync} for details.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {string | Buffer | Uint8Array |
|
|
8
|
+
* readonly (string | Buffer | Uint8Array)[]} seeds - seeds for PDA
|
|
8
9
|
* @param {PublicKeyInitData} programId - program address
|
|
9
10
|
* @returns PDA
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
type Seed = string | Buffer | Uint8Array;
|
|
13
|
+
export declare function deriveAddress(seeds: Seed | readonly Seed[], programId: PublicKeyInitData): PublicKey;
|
|
12
14
|
/**
|
|
13
15
|
* Factory to create AccountMeta with `isWritable` set to `true`
|
|
14
16
|
*
|
|
@@ -32,4 +34,5 @@ export declare function newReadOnlyAccountMeta(pubkey: PublicKeyInitData, isSign
|
|
|
32
34
|
* @returns serialized data as Buffer
|
|
33
35
|
*/
|
|
34
36
|
export declare function getAccountData(info: AccountInfo<Buffer> | null): Buffer;
|
|
37
|
+
export {};
|
|
35
38
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/account.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/account.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;GAOG;AACH,KAAK,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAEzC,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,GAAG,SAAS,IAAI,EAAE,EAC7B,SAAS,EAAE,iBAAiB,GAC3B,SAAS,CAKX;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,OAAO,GAChB,WAAW,CAMb;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,OAAO,GAChB,WAAW,CAMb;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,MAAM,CAKvE"}
|
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAccountData = exports.newReadOnlyAccountMeta = exports.newAccountMeta = exports.deriveAddress = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
|
|
6
|
-
* Find valid program address. See {@link PublicKey.findProgramAddressSync} for details.
|
|
7
|
-
*
|
|
8
|
-
* @param {(Buffer | Uint8Array)[]} seeds - seeds for PDA
|
|
9
|
-
* @param {PublicKeyInitData} programId - program address
|
|
10
|
-
* @returns PDA
|
|
11
|
-
*/
|
|
5
|
+
const toBytes = (s) => typeof s === "string" ? Buffer.from(s) : s;
|
|
12
6
|
function deriveAddress(seeds, programId) {
|
|
13
|
-
return web3_js_1.PublicKey.findProgramAddressSync(seeds, new web3_js_1.PublicKey(programId))[0];
|
|
7
|
+
return web3_js_1.PublicKey.findProgramAddressSync(Array.isArray(seeds) ? seeds.map(toBytes) : [toBytes(seeds)], new web3_js_1.PublicKey(programId))[0];
|
|
14
8
|
}
|
|
15
9
|
exports.deriveAddress = deriveAddress;
|
|
16
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/utils/utils/account.ts"],"names":[],"mappings":";;;AAKA,6CAA4C;
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/utils/utils/account.ts"],"names":[],"mappings":";;;AAKA,6CAA4C;AAW5C,MAAM,OAAO,GAAG,CAAC,CAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,SAAgB,aAAa,CAC3B,KAA6B,EAC7B,SAA4B;IAE5B,OAAO,mBAAS,CAAC,sBAAsB,CACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAa,CAAC,CAAC,EACpE,IAAI,mBAAS,CAAC,SAAS,CAAC,CACzB,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AARD,sCAQC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,MAAyB,EACzB,QAAiB;IAEjB,OAAO;QACL,MAAM,EAAE,IAAI,mBAAS,CAAC,MAAM,CAAC;QAC7B,UAAU,EAAE,IAAI;QAChB,QAAQ;KACT,CAAC;AACJ,CAAC;AATD,wCASC;AAED;;;;;;GAMG;AACH,SAAgB,sBAAsB,CACpC,MAAyB,EACzB,QAAiB;IAEjB,OAAO;QACL,MAAM,EAAE,IAAI,mBAAS,CAAC,MAAM,CAAC;QAC7B,UAAU,EAAE,KAAK;QACjB,QAAQ;KACT,CAAC;AACJ,CAAC;AATD,wDASC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,IAAgC;IAC7D,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AALD,wCAKC"}
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import type { PublicKeyInitData } from '@solana/web3.js';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export declare const BPF_LOADER_UPGRADEABLE_PROGRAM_ID: PublicKey;
|
|
4
|
+
export declare function deriveProgramDataAddress(programId: PublicKeyInitData): PublicKey;
|
|
5
|
+
export declare const programDataLayout: readonly [{
|
|
6
|
+
readonly name: "slot";
|
|
7
|
+
readonly binary: "uint";
|
|
8
|
+
readonly endianness: "little";
|
|
9
|
+
readonly size: 8;
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "upgradeAuthority";
|
|
12
|
+
readonly binary: "switch";
|
|
13
|
+
readonly idSize: 1;
|
|
14
|
+
readonly idTag: "isSome";
|
|
15
|
+
readonly layouts: readonly [readonly [readonly [0, false], readonly []], readonly [readonly [1, true], readonly [{
|
|
16
|
+
readonly name: "value";
|
|
17
|
+
readonly binary: "bytes";
|
|
18
|
+
readonly size: 32;
|
|
19
|
+
readonly custom: {
|
|
20
|
+
readonly to: (encoded: Uint8Array) => PublicKey;
|
|
21
|
+
readonly from: (decoded: PublicKey) => Uint8Array;
|
|
22
|
+
};
|
|
23
|
+
}]]];
|
|
24
|
+
}];
|
|
7
25
|
//# sourceMappingURL=bpfLoaderUpgradeable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bpfLoaderUpgradeable.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/bpfLoaderUpgradeable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"bpfLoaderUpgradeable.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/bpfLoaderUpgradeable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,eAAO,MAAM,iCAAiC,WAE7C,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,iBAAiB,GAAG,SAAS,CAKhF;AASD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;mCANd,UAAU;qCACR,SAAS;;;EA2BA,CAAC"}
|
|
@@ -1,14 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.programDataLayout = exports.deriveProgramDataAddress = exports.BPF_LOADER_UPGRADEABLE_PROGRAM_ID = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const account_js_1 = require("./account.js");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
exports.BPF_LOADER_UPGRADEABLE_PROGRAM_ID = new web3_js_1.PublicKey("BPFLoaderUpgradeab1e11111111111111111111111");
|
|
7
|
+
function deriveProgramDataAddress(programId) {
|
|
8
|
+
return (0, account_js_1.deriveAddress)([new web3_js_1.PublicKey(programId).toBuffer()], exports.BPF_LOADER_UPGRADEABLE_PROGRAM_ID);
|
|
8
9
|
}
|
|
9
|
-
exports.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
exports.deriveProgramDataAddress = deriveProgramDataAddress;
|
|
11
|
+
const pubKeyConversion = {
|
|
12
|
+
to: (encoded) => new web3_js_1.PublicKey(encoded),
|
|
13
|
+
from: (decoded) => decoded.toBytes(),
|
|
14
|
+
};
|
|
15
|
+
//neither anchor nor solana web3 have a built-in way to parse this
|
|
16
|
+
//see here: https://docs.rs/solana-program/latest/solana_program/bpf_loader_upgradeable/enum.UpgradeableLoaderState.html
|
|
17
|
+
exports.programDataLayout = [
|
|
18
|
+
{ name: "slot", binary: "uint", endianness: "little", size: 8 },
|
|
19
|
+
{
|
|
20
|
+
name: "upgradeAuthority",
|
|
21
|
+
binary: "switch",
|
|
22
|
+
idSize: 1,
|
|
23
|
+
idTag: "isSome",
|
|
24
|
+
layouts: [
|
|
25
|
+
[[0, false], []],
|
|
26
|
+
[
|
|
27
|
+
[1, true],
|
|
28
|
+
[
|
|
29
|
+
{
|
|
30
|
+
name: "value",
|
|
31
|
+
binary: "bytes",
|
|
32
|
+
size: 32,
|
|
33
|
+
custom: pubKeyConversion,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
],
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
];
|
|
14
40
|
//# sourceMappingURL=bpfLoaderUpgradeable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bpfLoaderUpgradeable.js","sourceRoot":"","sources":["../../../../src/utils/utils/bpfLoaderUpgradeable.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAC5C,6CAA6C;
|
|
1
|
+
{"version":3,"file":"bpfLoaderUpgradeable.js","sourceRoot":"","sources":["../../../../src/utils/utils/bpfLoaderUpgradeable.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAC5C,6CAA6C;AAIhC,QAAA,iCAAiC,GAAG,IAAI,mBAAS,CAC5D,6CAA6C,CAC9C,CAAC;AAEF,SAAgB,wBAAwB,CAAC,SAA4B;IACnE,OAAO,IAAA,0BAAa,EAClB,CAAC,IAAI,mBAAS,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,EACrC,yCAAiC,CAClC,CAAC;AACJ,CAAC;AALD,4DAKC;AAED,MAAM,gBAAgB,GAAG;IACvB,EAAE,EAAE,CAAC,OAAmB,EAAE,EAAE,CAAC,IAAI,mBAAS,CAAC,OAAO,CAAC;IACnD,IAAI,EAAE,CAAC,OAAkB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE;CACW,CAAC;AAE7D,kEAAkE;AAClE,wHAAwH;AAC3G,QAAA,iBAAiB,GAAG;IAC/B,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;IAC/D;QACE,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE;YACP,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YAChB;gBACE,CAAC,CAAC,EAAE,IAAI,CAAC;gBACT;oBACE;wBACE,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,OAAO;wBACf,IAAI,EAAE,EAAE;wBACR,MAAM,EAAE,gBAAgB;qBACzB;iBACF;aACF;SACF;KACF;CACwB,CAAC"}
|
|
@@ -4,11 +4,13 @@ import { PublicKey } from '@solana/web3.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Find valid program address. See {@link PublicKey.findProgramAddressSync} for details.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {string | Buffer | Uint8Array |
|
|
8
|
+
* readonly (string | Buffer | Uint8Array)[]} seeds - seeds for PDA
|
|
8
9
|
* @param {PublicKeyInitData} programId - program address
|
|
9
10
|
* @returns PDA
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
type Seed = string | Buffer | Uint8Array;
|
|
13
|
+
export declare function deriveAddress(seeds: Seed | readonly Seed[], programId: PublicKeyInitData): PublicKey;
|
|
12
14
|
/**
|
|
13
15
|
* Factory to create AccountMeta with `isWritable` set to `true`
|
|
14
16
|
*
|
|
@@ -32,4 +34,5 @@ export declare function newReadOnlyAccountMeta(pubkey: PublicKeyInitData, isSign
|
|
|
32
34
|
* @returns serialized data as Buffer
|
|
33
35
|
*/
|
|
34
36
|
export declare function getAccountData(info: AccountInfo<Buffer> | null): Buffer;
|
|
37
|
+
export {};
|
|
35
38
|
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/account.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/account.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;GAOG;AACH,KAAK,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC;AAEzC,wBAAgB,aAAa,CAC3B,KAAK,EAAE,IAAI,GAAG,SAAS,IAAI,EAAE,EAC7B,SAAS,EAAE,iBAAiB,GAC3B,SAAS,CAKX;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,OAAO,GAChB,WAAW,CAMb;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,OAAO,GAChB,WAAW,CAMb;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,MAAM,CAKvE"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
-
|
|
3
|
-
* Find valid program address. See {@link PublicKey.findProgramAddressSync} for details.
|
|
4
|
-
*
|
|
5
|
-
* @param {(Buffer | Uint8Array)[]} seeds - seeds for PDA
|
|
6
|
-
* @param {PublicKeyInitData} programId - program address
|
|
7
|
-
* @returns PDA
|
|
8
|
-
*/
|
|
2
|
+
const toBytes = (s) => typeof s === "string" ? Buffer.from(s) : s;
|
|
9
3
|
export function deriveAddress(seeds, programId) {
|
|
10
|
-
return PublicKey.findProgramAddressSync(seeds, new PublicKey(programId))[0];
|
|
4
|
+
return PublicKey.findProgramAddressSync(Array.isArray(seeds) ? seeds.map(toBytes) : [toBytes(seeds)], new PublicKey(programId))[0];
|
|
11
5
|
}
|
|
12
6
|
/**
|
|
13
7
|
* Factory to create AccountMeta with `isWritable` set to `true`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/utils/utils/account.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../src/utils/utils/account.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,GAAG,CAAC,CAAO,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,MAAM,UAAU,aAAa,CAC3B,KAA6B,EAC7B,SAA4B;IAE5B,OAAO,SAAS,CAAC,sBAAsB,CACrC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAa,CAAC,CAAC,EACpE,IAAI,SAAS,CAAC,SAAS,CAAC,CACzB,CAAC,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAyB,EACzB,QAAiB;IAEjB,OAAO;QACL,MAAM,EAAE,IAAI,SAAS,CAAC,MAAM,CAAC;QAC7B,UAAU,EAAE,IAAI;QAChB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAyB,EACzB,QAAiB;IAEjB,OAAO;QACL,MAAM,EAAE,IAAI,SAAS,CAAC,MAAM,CAAC;QAC7B,UAAU,EAAE,KAAK;QACjB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAgC;IAC7D,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import type { PublicKeyInitData } from '@solana/web3.js';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export declare const BPF_LOADER_UPGRADEABLE_PROGRAM_ID: PublicKey;
|
|
4
|
+
export declare function deriveProgramDataAddress(programId: PublicKeyInitData): PublicKey;
|
|
5
|
+
export declare const programDataLayout: readonly [{
|
|
6
|
+
readonly name: "slot";
|
|
7
|
+
readonly binary: "uint";
|
|
8
|
+
readonly endianness: "little";
|
|
9
|
+
readonly size: 8;
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "upgradeAuthority";
|
|
12
|
+
readonly binary: "switch";
|
|
13
|
+
readonly idSize: 1;
|
|
14
|
+
readonly idTag: "isSome";
|
|
15
|
+
readonly layouts: readonly [readonly [readonly [0, false], readonly []], readonly [readonly [1, true], readonly [{
|
|
16
|
+
readonly name: "value";
|
|
17
|
+
readonly binary: "bytes";
|
|
18
|
+
readonly size: 32;
|
|
19
|
+
readonly custom: {
|
|
20
|
+
readonly to: (encoded: Uint8Array) => PublicKey;
|
|
21
|
+
readonly from: (decoded: PublicKey) => Uint8Array;
|
|
22
|
+
};
|
|
23
|
+
}]]];
|
|
24
|
+
}];
|
|
7
25
|
//# sourceMappingURL=bpfLoaderUpgradeable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bpfLoaderUpgradeable.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/bpfLoaderUpgradeable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"bpfLoaderUpgradeable.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/bpfLoaderUpgradeable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5C,eAAO,MAAM,iCAAiC,WAE7C,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,iBAAiB,GAAG,SAAS,CAKhF;AASD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;mCANd,UAAU;qCACR,SAAS;;;EA2BA,CAAC"}
|
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { deriveAddress } from './account.js';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function deriveUpgradeableProgramKey(programId) {
|
|
7
|
-
return deriveAddress([new PublicKey(programId).toBuffer()], BpfLoaderUpgradeable.programId);
|
|
3
|
+
export const BPF_LOADER_UPGRADEABLE_PROGRAM_ID = new PublicKey("BPFLoaderUpgradeab1e11111111111111111111111");
|
|
4
|
+
export function deriveProgramDataAddress(programId) {
|
|
5
|
+
return deriveAddress([new PublicKey(programId).toBuffer()], BPF_LOADER_UPGRADEABLE_PROGRAM_ID);
|
|
8
6
|
}
|
|
7
|
+
const pubKeyConversion = {
|
|
8
|
+
to: (encoded) => new PublicKey(encoded),
|
|
9
|
+
from: (decoded) => decoded.toBytes(),
|
|
10
|
+
};
|
|
11
|
+
//neither anchor nor solana web3 have a built-in way to parse this
|
|
12
|
+
//see here: https://docs.rs/solana-program/latest/solana_program/bpf_loader_upgradeable/enum.UpgradeableLoaderState.html
|
|
13
|
+
export const programDataLayout = [
|
|
14
|
+
{ name: "slot", binary: "uint", endianness: "little", size: 8 },
|
|
15
|
+
{
|
|
16
|
+
name: "upgradeAuthority",
|
|
17
|
+
binary: "switch",
|
|
18
|
+
idSize: 1,
|
|
19
|
+
idTag: "isSome",
|
|
20
|
+
layouts: [
|
|
21
|
+
[[0, false], []],
|
|
22
|
+
[
|
|
23
|
+
[1, true],
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
name: "value",
|
|
27
|
+
binary: "bytes",
|
|
28
|
+
size: 32,
|
|
29
|
+
custom: pubKeyConversion,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
],
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
9
36
|
//# sourceMappingURL=bpfLoaderUpgradeable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bpfLoaderUpgradeable.js","sourceRoot":"","sources":["../../../../src/utils/utils/bpfLoaderUpgradeable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"bpfLoaderUpgradeable.js","sourceRoot":"","sources":["../../../../src/utils/utils/bpfLoaderUpgradeable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,CAAC,MAAM,iCAAiC,GAAG,IAAI,SAAS,CAC5D,6CAA6C,CAC9C,CAAC;AAEF,MAAM,UAAU,wBAAwB,CAAC,SAA4B;IACnE,OAAO,aAAa,CAClB,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,EACrC,iCAAiC,CAClC,CAAC;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG;IACvB,EAAE,EAAE,CAAC,OAAmB,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC;IACnD,IAAI,EAAE,CAAC,OAAkB,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE;CACW,CAAC;AAE7D,kEAAkE;AAClE,wHAAwH;AACxH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE;IAC/D;QACE,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,CAAC;QACT,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE;YACP,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YAChB;gBACE,CAAC,CAAC,EAAE,IAAI,CAAC;gBACT;oBACE;wBACE,IAAI,EAAE,OAAO;wBACb,MAAM,EAAE,OAAO;wBACf,IAAI,EAAE,EAAE;wBACR,MAAM,EAAE,gBAAgB;qBACzB;iBACF;aACF;SACF;KACF;CACwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wormhole-foundation/sdk-solana",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@coral-xyz/borsh": "0.29.0",
|
|
54
54
|
"@solana/spl-token": "0.3.9",
|
|
55
55
|
"@solana/web3.js": "^1.95.2",
|
|
56
|
-
"@wormhole-foundation/sdk-connect": "0.10.
|
|
56
|
+
"@wormhole-foundation/sdk-connect": "0.10.4",
|
|
57
57
|
"rpc-websockets": "^7.10.0"
|
|
58
58
|
},
|
|
59
59
|
"type": "module",
|