@wormhole-foundation/sdk-solana 4.22.0 → 5.0.0-beta.0
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/package.json +15 -48
- package/dist/cjs/address.d.ts +0 -27
- package/dist/cjs/address.d.ts.map +0 -1
- package/dist/cjs/address.js +0 -56
- package/dist/cjs/address.js.map +0 -1
- package/dist/cjs/chain.d.ts +0 -8
- package/dist/cjs/chain.d.ts.map +0 -1
- package/dist/cjs/chain.js +0 -54
- package/dist/cjs/chain.js.map +0 -1
- package/dist/cjs/index.d.ts +0 -8
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/platform.d.ts +0 -36
- package/dist/cjs/platform.d.ts.map +0 -1
- package/dist/cjs/platform.js +0 -195
- package/dist/cjs/platform.js.map +0 -1
- package/dist/cjs/signer.d.ts +0 -91
- package/dist/cjs/signer.d.ts.map +0 -1
- package/dist/cjs/signer.js +0 -380
- package/dist/cjs/signer.js.map +0 -1
- package/dist/cjs/types.d.ts +0 -16
- package/dist/cjs/types.d.ts.map +0 -1
- package/dist/cjs/types.js +0 -10
- package/dist/cjs/types.js.map +0 -1
- package/dist/cjs/unsignedTransaction.d.ts +0 -17
- package/dist/cjs/unsignedTransaction.d.ts.map +0 -1
- package/dist/cjs/unsignedTransaction.js +0 -24
- package/dist/cjs/unsignedTransaction.js.map +0 -1
- package/dist/cjs/utils/anchor/common.d.ts +0 -3
- package/dist/cjs/utils/anchor/common.d.ts.map +0 -1
- package/dist/cjs/utils/anchor/common.js +0 -102
- package/dist/cjs/utils/anchor/common.js.map +0 -1
- package/dist/cjs/utils/anchor/error.d.ts +0 -4
- package/dist/cjs/utils/anchor/error.d.ts.map +0 -1
- package/dist/cjs/utils/anchor/error.js +0 -14
- package/dist/cjs/utils/anchor/error.js.map +0 -1
- package/dist/cjs/utils/anchor/idl.d.ts +0 -126
- package/dist/cjs/utils/anchor/idl.d.ts.map +0 -1
- package/dist/cjs/utils/anchor/idl.js +0 -62
- package/dist/cjs/utils/anchor/idl.js.map +0 -1
- package/dist/cjs/utils/anchor/index.d.ts +0 -4
- package/dist/cjs/utils/anchor/index.d.ts.map +0 -1
- package/dist/cjs/utils/anchor/index.js +0 -20
- package/dist/cjs/utils/anchor/index.js.map +0 -1
- package/dist/cjs/utils/index.d.ts +0 -5
- package/dist/cjs/utils/index.d.ts.map +0 -1
- package/dist/cjs/utils/index.js +0 -43
- package/dist/cjs/utils/index.js.map +0 -1
- package/dist/cjs/utils/utils/account.d.ts +0 -39
- package/dist/cjs/utils/utils/account.d.ts.map +0 -1
- package/dist/cjs/utils/utils/account.js +0 -53
- package/dist/cjs/utils/utils/account.js.map +0 -1
- package/dist/cjs/utils/utils/bpfLoaderUpgradeable.d.ts +0 -40
- package/dist/cjs/utils/utils/bpfLoaderUpgradeable.d.ts.map +0 -1
- package/dist/cjs/utils/utils/bpfLoaderUpgradeable.js +0 -51
- package/dist/cjs/utils/utils/bpfLoaderUpgradeable.js.map +0 -1
- package/dist/cjs/utils/utils/index.d.ts +0 -6
- package/dist/cjs/utils/utils/index.d.ts.map +0 -1
- package/dist/cjs/utils/utils/index.js +0 -27
- package/dist/cjs/utils/utils/index.js.map +0 -1
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.accountSize = void 0;
|
|
4
|
-
const error_js_1 = require("./error.js");
|
|
5
|
-
function accountSize(idl, idlAccount) {
|
|
6
|
-
switch (idlAccount.type.kind) {
|
|
7
|
-
case 'struct': {
|
|
8
|
-
return idlAccount.type.fields
|
|
9
|
-
.map((f) => typeSize(idl, f.type))
|
|
10
|
-
.reduce((acc, size) => acc + size, 0);
|
|
11
|
-
}
|
|
12
|
-
case 'enum': {
|
|
13
|
-
const variantSizes = idlAccount.type.variants.map((variant) => {
|
|
14
|
-
if (!variant.fields) {
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
return variant.fields
|
|
18
|
-
.map((f) => {
|
|
19
|
-
// Unnamed enum variant
|
|
20
|
-
if (!(typeof f === 'object' && 'name' in f)) {
|
|
21
|
-
return typeSize(idl, f);
|
|
22
|
-
}
|
|
23
|
-
// Named enum variant
|
|
24
|
-
return typeSize(idl, f.type);
|
|
25
|
-
})
|
|
26
|
-
.reduce((acc, size) => acc + size, 0);
|
|
27
|
-
});
|
|
28
|
-
return Math.max(...variantSizes) + 1;
|
|
29
|
-
}
|
|
30
|
-
case 'alias': {
|
|
31
|
-
return typeSize(idl, idlAccount.type.value);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.accountSize = accountSize;
|
|
36
|
-
// Returns the size of the type in bytes. For variable length types, just return
|
|
37
|
-
// 1. Users should override this value in such cases.
|
|
38
|
-
function typeSize(idl, ty) {
|
|
39
|
-
switch (ty) {
|
|
40
|
-
case 'bool':
|
|
41
|
-
return 1;
|
|
42
|
-
case 'u8':
|
|
43
|
-
return 1;
|
|
44
|
-
case 'i8':
|
|
45
|
-
return 1;
|
|
46
|
-
case 'i16':
|
|
47
|
-
return 2;
|
|
48
|
-
case 'u16':
|
|
49
|
-
return 2;
|
|
50
|
-
case 'u32':
|
|
51
|
-
return 4;
|
|
52
|
-
case 'i32':
|
|
53
|
-
return 4;
|
|
54
|
-
case 'f32':
|
|
55
|
-
return 4;
|
|
56
|
-
case 'u64':
|
|
57
|
-
return 8;
|
|
58
|
-
case 'i64':
|
|
59
|
-
return 8;
|
|
60
|
-
case 'f64':
|
|
61
|
-
return 8;
|
|
62
|
-
case 'u128':
|
|
63
|
-
return 16;
|
|
64
|
-
case 'i128':
|
|
65
|
-
return 16;
|
|
66
|
-
case 'u256':
|
|
67
|
-
return 32;
|
|
68
|
-
case 'i256':
|
|
69
|
-
return 32;
|
|
70
|
-
case 'bytes':
|
|
71
|
-
return 1;
|
|
72
|
-
case 'string':
|
|
73
|
-
return 1;
|
|
74
|
-
case 'publicKey':
|
|
75
|
-
return 32;
|
|
76
|
-
default:
|
|
77
|
-
if ('vec' in ty) {
|
|
78
|
-
return 1;
|
|
79
|
-
}
|
|
80
|
-
if ('option' in ty) {
|
|
81
|
-
return 1 + typeSize(idl, ty.option);
|
|
82
|
-
}
|
|
83
|
-
if ('coption' in ty) {
|
|
84
|
-
return 4 + typeSize(idl, ty.coption);
|
|
85
|
-
}
|
|
86
|
-
if ('defined' in ty) {
|
|
87
|
-
const filtered = idl.types?.filter((t) => t.name === ty.defined) ?? [];
|
|
88
|
-
if (filtered.length !== 1) {
|
|
89
|
-
throw new error_js_1.IdlError(`Type not found: ${JSON.stringify(ty)}`);
|
|
90
|
-
}
|
|
91
|
-
let typeDef = filtered[0];
|
|
92
|
-
return accountSize(idl, typeDef);
|
|
93
|
-
}
|
|
94
|
-
if ('array' in ty) {
|
|
95
|
-
let arrayTy = ty.array[0];
|
|
96
|
-
let arraySize = ty.array[1];
|
|
97
|
-
return typeSize(idl, arrayTy) * arraySize;
|
|
98
|
-
}
|
|
99
|
-
throw new Error(`Invalid type ${JSON.stringify(ty)}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=common.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../src/utils/anchor/common.ts"],"names":[],"mappings":";;;AACA,yCAAsC;AAEtC,SAAgB,WAAW,CAAC,GAAQ,EAAE,UAAsB;IAC1D,QAAQ,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC7B,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,OAAO,UAAU,CAAC,IAAI,CAAC,MAAM;iBAC1B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;iBACjC,MAAM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AM,KAAK,CAAC,EAAE,CAAC;oBAC1B,MAAM,IAAI,mBAAQ,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gBAC9D,CAAC;gBACD,IAAI,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAE1B,OAAO,WAAW,CAAC,GAAG,EAAE,OAAQ,CAAC,CAAC;YACpC,CAAC;YACD,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;gBAClB,IAAI,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC1B,IAAI,SAAS,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC5B,OAAO,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;YAC5C,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/utils/anchor/error.ts"],"names":[],"mappings":"AAIA,qBAAa,QAAS,SAAQ,KAAK;gBACrB,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Borrowed from coral-xyz/anchor
|
|
3
|
-
//
|
|
4
|
-
// https://github.com/coral-xyz/anchor/blob/master/ts/packages/anchor/src/error.ts
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IdlError = void 0;
|
|
7
|
-
class IdlError extends Error {
|
|
8
|
-
constructor(message) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.name = 'IdlError';
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.IdlError = IdlError;
|
|
14
|
-
//# sourceMappingURL=error.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/utils/anchor/error.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,kFAAkF;;;AAElF,MAAa,QAAS,SAAQ,KAAK;IACjC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AALD,4BAKC"}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { Buffer } from 'buffer';
|
|
5
|
-
export type Idl = {
|
|
6
|
-
version: string;
|
|
7
|
-
name: string;
|
|
8
|
-
docs?: string[];
|
|
9
|
-
instructions: IdlInstruction[];
|
|
10
|
-
accounts?: IdlAccountDef[];
|
|
11
|
-
types?: IdlTypeDef[];
|
|
12
|
-
events?: IdlEvent[];
|
|
13
|
-
errors?: IdlErrorCode[];
|
|
14
|
-
constants?: IdlConstant[];
|
|
15
|
-
metadata?: IdlMetadata;
|
|
16
|
-
};
|
|
17
|
-
export type IdlMetadata = any;
|
|
18
|
-
export type IdlConstant = {
|
|
19
|
-
name: string;
|
|
20
|
-
type: IdlType;
|
|
21
|
-
value: string;
|
|
22
|
-
};
|
|
23
|
-
export type IdlEvent = {
|
|
24
|
-
name: string;
|
|
25
|
-
fields: IdlEventField[];
|
|
26
|
-
};
|
|
27
|
-
export type IdlEventField = {
|
|
28
|
-
name: string;
|
|
29
|
-
type: IdlType;
|
|
30
|
-
index: boolean;
|
|
31
|
-
};
|
|
32
|
-
export type IdlInstruction = {
|
|
33
|
-
name: string;
|
|
34
|
-
docs?: string[];
|
|
35
|
-
accounts: IdlAccountItem[];
|
|
36
|
-
args: IdlField[];
|
|
37
|
-
returns?: IdlType;
|
|
38
|
-
};
|
|
39
|
-
export type IdlStateMethod = IdlInstruction;
|
|
40
|
-
export type IdlAccountItem = IdlAccount | IdlAccounts;
|
|
41
|
-
export declare function isIdlAccounts(accountItem: IdlAccountItem): accountItem is IdlAccounts;
|
|
42
|
-
export type IdlAccount = {
|
|
43
|
-
name: string;
|
|
44
|
-
isMut: boolean;
|
|
45
|
-
isSigner: boolean;
|
|
46
|
-
isOptional?: boolean;
|
|
47
|
-
docs?: string[];
|
|
48
|
-
relations?: string[];
|
|
49
|
-
pda?: IdlPda;
|
|
50
|
-
};
|
|
51
|
-
export type IdlPda = {
|
|
52
|
-
seeds: IdlSeed[];
|
|
53
|
-
programId?: IdlSeed;
|
|
54
|
-
};
|
|
55
|
-
export type IdlSeed = any;
|
|
56
|
-
export type IdlAccounts = {
|
|
57
|
-
name: string;
|
|
58
|
-
docs?: string[];
|
|
59
|
-
accounts: IdlAccountItem[];
|
|
60
|
-
};
|
|
61
|
-
export type IdlField = {
|
|
62
|
-
name: string;
|
|
63
|
-
docs?: string[];
|
|
64
|
-
type: IdlType;
|
|
65
|
-
};
|
|
66
|
-
export type IdlTypeDef = {
|
|
67
|
-
name: string;
|
|
68
|
-
docs?: string[];
|
|
69
|
-
type: IdlTypeDefTy;
|
|
70
|
-
};
|
|
71
|
-
export type IdlAccountDef = {
|
|
72
|
-
name: string;
|
|
73
|
-
docs?: string[];
|
|
74
|
-
type: IdlTypeDefTyStruct;
|
|
75
|
-
};
|
|
76
|
-
export type IdlTypeDefTyStruct = {
|
|
77
|
-
kind: 'struct';
|
|
78
|
-
fields: IdlTypeDefStruct;
|
|
79
|
-
};
|
|
80
|
-
export type IdlTypeDefTyEnum = {
|
|
81
|
-
kind: 'enum';
|
|
82
|
-
variants: IdlEnumVariant[];
|
|
83
|
-
};
|
|
84
|
-
export type IdlTypeDefTyAlias = {
|
|
85
|
-
kind: 'alias';
|
|
86
|
-
value: IdlType;
|
|
87
|
-
};
|
|
88
|
-
export type IdlTypeDefTy = IdlTypeDefTyEnum | IdlTypeDefTyStruct | IdlTypeDefTyAlias;
|
|
89
|
-
export type IdlTypeDefStruct = Array<IdlField>;
|
|
90
|
-
export type IdlType = 'bool' | 'u8' | 'i8' | 'u16' | 'i16' | 'u32' | 'i32' | 'f32' | 'u64' | 'i64' | 'f64' | 'u128' | 'i128' | 'u256' | 'i256' | 'bytes' | 'string' | 'publicKey' | IdlTypeDefined | IdlTypeOption | IdlTypeCOption | IdlTypeVec | IdlTypeArray;
|
|
91
|
-
export type IdlTypeDefined = {
|
|
92
|
-
defined: string;
|
|
93
|
-
};
|
|
94
|
-
export type IdlTypeOption = {
|
|
95
|
-
option: IdlType;
|
|
96
|
-
};
|
|
97
|
-
export type IdlTypeCOption = {
|
|
98
|
-
coption: IdlType;
|
|
99
|
-
};
|
|
100
|
-
export type IdlTypeVec = {
|
|
101
|
-
vec: IdlType;
|
|
102
|
-
};
|
|
103
|
-
export type IdlTypeArray = {
|
|
104
|
-
array: [idlType: IdlType, size: number];
|
|
105
|
-
};
|
|
106
|
-
export type IdlEnumVariant = {
|
|
107
|
-
name: string;
|
|
108
|
-
fields?: IdlEnumFields;
|
|
109
|
-
};
|
|
110
|
-
export type IdlEnumFields = IdlEnumFieldsNamed | IdlEnumFieldsTuple;
|
|
111
|
-
export type IdlEnumFieldsNamed = IdlField[];
|
|
112
|
-
export type IdlEnumFieldsTuple = IdlType[];
|
|
113
|
-
export type IdlErrorCode = {
|
|
114
|
-
code: number;
|
|
115
|
-
name: string;
|
|
116
|
-
msg?: string;
|
|
117
|
-
};
|
|
118
|
-
export declare function idlAddress(programId: PublicKey): Promise<PublicKey>;
|
|
119
|
-
export declare function seed(): string;
|
|
120
|
-
export interface IdlProgramAccount {
|
|
121
|
-
authority: PublicKey;
|
|
122
|
-
data: Buffer;
|
|
123
|
-
}
|
|
124
|
-
export declare function decodeIdlAccount(data: Buffer): IdlProgramAccount;
|
|
125
|
-
export declare function encodeIdlAccount(acc: IdlProgramAccount): Buffer;
|
|
126
|
-
//# sourceMappingURL=idl.d.ts.map
|
|
@@ -1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,CAAC;IACb,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,EAAE,CAAC;AAE5C,MAAM,MAAM,kBAAkB,GAAG,OAAO,EAAE,CAAC;AAE3C,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAGF,wBAAsB,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAGzE;AAGD,wBAAgB,IAAI,IAAI,MAAM,CAE7B;AAGD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd;AAOD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAEhE;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAI/D"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Borrowed from coral-xyz/anchor
|
|
3
|
-
//
|
|
4
|
-
// https://github.com/coral-xyz/anchor/blob/master/ts/packages/anchor/src/idl.ts
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.encodeIdlAccount = exports.decodeIdlAccount = exports.seed = exports.idlAddress = exports.isIdlAccounts = void 0;
|
|
30
|
-
const borsh = __importStar(require("@coral-xyz/borsh"));
|
|
31
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
32
|
-
const buffer_1 = require("buffer");
|
|
33
|
-
function isIdlAccounts(accountItem) {
|
|
34
|
-
return 'accounts' in accountItem;
|
|
35
|
-
}
|
|
36
|
-
exports.isIdlAccounts = isIdlAccounts;
|
|
37
|
-
// Deterministic IDL address as a function of the program id.
|
|
38
|
-
async function idlAddress(programId) {
|
|
39
|
-
const base = (await web3_js_1.PublicKey.findProgramAddress([], programId))[0];
|
|
40
|
-
return await web3_js_1.PublicKey.createWithSeed(base, seed(), programId);
|
|
41
|
-
}
|
|
42
|
-
exports.idlAddress = idlAddress;
|
|
43
|
-
// Seed for generating the idlAddress.
|
|
44
|
-
function seed() {
|
|
45
|
-
return 'anchor:idl';
|
|
46
|
-
}
|
|
47
|
-
exports.seed = seed;
|
|
48
|
-
const IDL_ACCOUNT_LAYOUT = borsh.struct([
|
|
49
|
-
borsh.publicKey('authority'),
|
|
50
|
-
borsh.vecU8('data'),
|
|
51
|
-
]);
|
|
52
|
-
function decodeIdlAccount(data) {
|
|
53
|
-
return IDL_ACCOUNT_LAYOUT.decode(data);
|
|
54
|
-
}
|
|
55
|
-
exports.decodeIdlAccount = decodeIdlAccount;
|
|
56
|
-
function encodeIdlAccount(acc) {
|
|
57
|
-
const buffer = buffer_1.Buffer.alloc(1000); // TODO: use a tighter buffer.
|
|
58
|
-
const len = IDL_ACCOUNT_LAYOUT.encode(acc, buffer);
|
|
59
|
-
return buffer.slice(0, len);
|
|
60
|
-
}
|
|
61
|
-
exports.encodeIdlAccount = encodeIdlAccount;
|
|
62
|
-
//# sourceMappingURL=idl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"idl.js","sourceRoot":"","sources":["../../../../src/utils/anchor/idl.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,gFAAgF;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhF,wDAA0C;AAC1C,6CAA4C;AAC5C,mCAAgC;AA8ChC,SAAgB,aAAa,CAC3B,WAA2B;IAE3B,OAAO,UAAU,IAAI,WAAW,CAAC;AACnC,CAAC;AAJD,sCAIC;AAiID,6DAA6D;AACtD,KAAK,UAAU,UAAU,CAAC,SAAoB;IACnD,MAAM,IAAI,GAAG,CAAC,MAAM,mBAAS,CAAC,kBAAkB,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpE,OAAO,MAAM,mBAAS,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC;AACjE,CAAC;AAHD,gCAGC;AAED,sCAAsC;AACtC,SAAgB,IAAI;IAClB,OAAO,YAAY,CAAC;AACtB,CAAC;AAFD,oBAEC;AAQD,MAAM,kBAAkB,GAAoC,KAAK,CAAC,MAAM,CAAC;IACvE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IAC5B,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,SAAgB,gBAAgB,CAAC,IAAY;IAC3C,OAAO,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAFD,4CAEC;AAED,SAAgB,gBAAgB,CAAC,GAAsB;IACrD,MAAM,MAAM,GAAG,eAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,8BAA8B;IACjE,MAAM,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC;AAJD,4CAIC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/anchor/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./error.js"), exports);
|
|
18
|
-
__exportStar(require("./idl.js"), exports);
|
|
19
|
-
__exportStar(require("./common.js"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/anchor/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAG5C,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS7C;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C"}
|
package/dist/cjs/utils/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.upperFirst = exports.camelCase = exports.anchor = exports.utils = void 0;
|
|
27
|
-
exports.utils = __importStar(require("./utils/index.js"));
|
|
28
|
-
exports.anchor = __importStar(require("./anchor/index.js"));
|
|
29
|
-
// camel case a string (from https://stackoverflow.com/a/2970667)
|
|
30
|
-
function camelCase(str) {
|
|
31
|
-
return (str
|
|
32
|
-
.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
33
|
-
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
34
|
-
})
|
|
35
|
-
// replace any spaces, hyphens, or underscores with an empty string
|
|
36
|
-
.replace(/[\s\-_]+/g, ''));
|
|
37
|
-
}
|
|
38
|
-
exports.camelCase = camelCase;
|
|
39
|
-
function upperFirst(str) {
|
|
40
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
41
|
-
}
|
|
42
|
-
exports.upperFirst = upperFirst;
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAA0C;AAC1C,4DAA4C;AAE5C,iEAAiE;AACjE,SAAgB,SAAS,CAAC,GAAW;IACnC,OAAO,CACL,GAAG;SACA,OAAO,CAAC,qBAAqB,EAAE,UAAU,IAAI,EAAE,KAAK;QACnD,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAC/D,CAAC,CAAC;QACF,mEAAmE;SAClE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAC5B,CAAC;AACJ,CAAC;AATD,8BASC;AAED,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC;AAFD,gCAEC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import type { AccountMeta, AccountInfo, PublicKeyInitData } from '@solana/web3.js';
|
|
4
|
-
import { PublicKey } from '@solana/web3.js';
|
|
5
|
-
/**
|
|
6
|
-
* Find valid program address. See {@link PublicKey.findProgramAddressSync} for details.
|
|
7
|
-
*
|
|
8
|
-
* @param {string | Buffer | Uint8Array |
|
|
9
|
-
* readonly (string | Buffer | Uint8Array)[]} seeds - seeds for PDA
|
|
10
|
-
* @param {PublicKeyInitData} programId - program address
|
|
11
|
-
* @returns PDA
|
|
12
|
-
*/
|
|
13
|
-
type Seed = string | Buffer | Uint8Array;
|
|
14
|
-
export declare function deriveAddress(seeds: Seed | readonly Seed[], programId: PublicKeyInitData): PublicKey;
|
|
15
|
-
/**
|
|
16
|
-
* Factory to create AccountMeta with `isWritable` set to `true`
|
|
17
|
-
*
|
|
18
|
-
* @param {PublicKEyInitData} pubkey - account address
|
|
19
|
-
* @param {boolean} isSigner - whether account authorized transaction
|
|
20
|
-
* @returns metadata for writable account
|
|
21
|
-
*/
|
|
22
|
-
export declare function newAccountMeta(pubkey: PublicKeyInitData, isSigner: boolean): AccountMeta;
|
|
23
|
-
/**
|
|
24
|
-
* Factory to create AccountMeta with `isWritable` set to `false`
|
|
25
|
-
*
|
|
26
|
-
* @param {PublicKEyInitData} pubkey - account address
|
|
27
|
-
* @param {boolean} isSigner - whether account authorized transaction
|
|
28
|
-
* @returns metadata for read-only account
|
|
29
|
-
*/
|
|
30
|
-
export declare function newReadOnlyAccountMeta(pubkey: PublicKeyInitData, isSigner: boolean): AccountMeta;
|
|
31
|
-
/**
|
|
32
|
-
* Get serialized data from account
|
|
33
|
-
*
|
|
34
|
-
* @param {AccountInfo<Buffer>} info - Solana AccountInfo
|
|
35
|
-
* @returns serialized data as Buffer
|
|
36
|
-
*/
|
|
37
|
-
export declare function getAccountData(info: AccountInfo<Buffer> | null): Buffer;
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccountData = exports.newReadOnlyAccountMeta = exports.newAccountMeta = exports.deriveAddress = void 0;
|
|
4
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
const toBytes = (s) => typeof s === "string" ? Buffer.from(s) : s;
|
|
6
|
-
function deriveAddress(seeds, programId) {
|
|
7
|
-
return web3_js_1.PublicKey.findProgramAddressSync(Array.isArray(seeds) ? seeds.map(toBytes) : [toBytes(seeds)], new web3_js_1.PublicKey(programId))[0];
|
|
8
|
-
}
|
|
9
|
-
exports.deriveAddress = deriveAddress;
|
|
10
|
-
/**
|
|
11
|
-
* Factory to create AccountMeta with `isWritable` set to `true`
|
|
12
|
-
*
|
|
13
|
-
* @param {PublicKEyInitData} pubkey - account address
|
|
14
|
-
* @param {boolean} isSigner - whether account authorized transaction
|
|
15
|
-
* @returns metadata for writable account
|
|
16
|
-
*/
|
|
17
|
-
function newAccountMeta(pubkey, isSigner) {
|
|
18
|
-
return {
|
|
19
|
-
pubkey: new web3_js_1.PublicKey(pubkey),
|
|
20
|
-
isWritable: true,
|
|
21
|
-
isSigner,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.newAccountMeta = newAccountMeta;
|
|
25
|
-
/**
|
|
26
|
-
* Factory to create AccountMeta with `isWritable` set to `false`
|
|
27
|
-
*
|
|
28
|
-
* @param {PublicKEyInitData} pubkey - account address
|
|
29
|
-
* @param {boolean} isSigner - whether account authorized transaction
|
|
30
|
-
* @returns metadata for read-only account
|
|
31
|
-
*/
|
|
32
|
-
function newReadOnlyAccountMeta(pubkey, isSigner) {
|
|
33
|
-
return {
|
|
34
|
-
pubkey: new web3_js_1.PublicKey(pubkey),
|
|
35
|
-
isWritable: false,
|
|
36
|
-
isSigner,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
exports.newReadOnlyAccountMeta = newReadOnlyAccountMeta;
|
|
40
|
-
/**
|
|
41
|
-
* Get serialized data from account
|
|
42
|
-
*
|
|
43
|
-
* @param {AccountInfo<Buffer>} info - Solana AccountInfo
|
|
44
|
-
* @returns serialized data as Buffer
|
|
45
|
-
*/
|
|
46
|
-
function getAccountData(info) {
|
|
47
|
-
if (info === null) {
|
|
48
|
-
throw Error('account info is null');
|
|
49
|
-
}
|
|
50
|
-
return info.data;
|
|
51
|
-
}
|
|
52
|
-
exports.getAccountData = getAccountData;
|
|
53
|
-
//# sourceMappingURL=account.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,40 +0,0 @@
|
|
|
1
|
-
import type { PublicKeyInitData } from '@solana/web3.js';
|
|
2
|
-
import { PublicKey } from '@solana/web3.js';
|
|
3
|
-
export declare const BPF_LOADER_UPGRADEABLE_PROGRAM_ID: PublicKey;
|
|
4
|
-
export declare function deriveProgramDataAddress(programId: PublicKeyInitData): PublicKey;
|
|
5
|
-
export declare function programDataAddress(programId: PublicKeyInitData): PublicKey;
|
|
6
|
-
export declare const programDataLayout: readonly [{
|
|
7
|
-
readonly size: 4;
|
|
8
|
-
readonly custom: 3;
|
|
9
|
-
readonly omit: true;
|
|
10
|
-
readonly binary: "uint";
|
|
11
|
-
readonly endianness: "little";
|
|
12
|
-
readonly name: "programDataEnumVariant";
|
|
13
|
-
}, {
|
|
14
|
-
readonly size: 8;
|
|
15
|
-
readonly binary: "uint";
|
|
16
|
-
readonly endianness: "little";
|
|
17
|
-
readonly name: "slot";
|
|
18
|
-
}, {
|
|
19
|
-
readonly name: "upgradeAuthority";
|
|
20
|
-
readonly binary: "switch";
|
|
21
|
-
readonly idSize: 1;
|
|
22
|
-
readonly idTag: "isSome";
|
|
23
|
-
readonly layouts: readonly [readonly [readonly [0, false], readonly [{
|
|
24
|
-
readonly name: "_lastValueBeforeImmutability";
|
|
25
|
-
readonly binary: "bytes";
|
|
26
|
-
readonly size: 32;
|
|
27
|
-
}]], readonly [readonly [1, true], readonly [{
|
|
28
|
-
readonly name: "value";
|
|
29
|
-
readonly binary: "bytes";
|
|
30
|
-
readonly size: 32;
|
|
31
|
-
readonly custom: {
|
|
32
|
-
readonly to: (encoded: Uint8Array) => PublicKey;
|
|
33
|
-
readonly from: (decoded: PublicKey) => Uint8Array;
|
|
34
|
-
};
|
|
35
|
-
}]]];
|
|
36
|
-
}, {
|
|
37
|
-
readonly name: "bytecode";
|
|
38
|
-
readonly binary: "bytes";
|
|
39
|
-
}];
|
|
40
|
-
//# sourceMappingURL=bpfLoaderUpgradeable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AAKD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,aAE9D;AAsBD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;mCAjBd,UAAU;qCACR,SAAS;;;;;;EA8BA,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.programDataLayout = exports.programDataAddress = exports.deriveProgramDataAddress = exports.BPF_LOADER_UPGRADEABLE_PROGRAM_ID = void 0;
|
|
4
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
const account_js_1 = require("./account.js");
|
|
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);
|
|
9
|
-
}
|
|
10
|
-
exports.deriveProgramDataAddress = deriveProgramDataAddress;
|
|
11
|
-
//the program data pda coincides with the address that's stored in the program id account (i.e. the
|
|
12
|
-
// account that's found at the program id address), which is of type UpgradeLoaderState::Program:
|
|
13
|
-
// https://docs.rs/solana-program/latest/src/solana_program/bpf_loader_upgradeable.rs.html#40-43
|
|
14
|
-
function programDataAddress(programId) {
|
|
15
|
-
return web3_js_1.PublicKey.findProgramAddressSync([new web3_js_1.PublicKey(programId).toBytes()], exports.BPF_LOADER_UPGRADEABLE_PROGRAM_ID)[0];
|
|
16
|
-
}
|
|
17
|
-
exports.programDataAddress = programDataAddress;
|
|
18
|
-
const onChainUint = { binary: "uint", endianness: "little" };
|
|
19
|
-
const pubKeyConversion = {
|
|
20
|
-
to: (encoded) => new web3_js_1.PublicKey(encoded),
|
|
21
|
-
from: (decoded) => decoded.toBytes(),
|
|
22
|
-
};
|
|
23
|
-
//Describes the layout of an account that holds a UpgradeableLoaderState::ProgramData enum:
|
|
24
|
-
// https://docs.rs/solana-program/latest/src/solana_program/bpf_loader_upgradeable.rs.html#45-52
|
|
25
|
-
// because neither Anchor nor Solana web3 seem to have a built-in way to parse this.
|
|
26
|
-
//The bpf_loader_upgradeable program uses Rust's serde crate and bincode to serialize its structs,
|
|
27
|
-
// which encodes enum variants as 4 byte little endian uints:
|
|
28
|
-
// https://github.com/serde-rs/serde/blob/9f8c579bf5f7478f91108c1186cd0d3f85aff29d/serde_derive/src/ser.rs#L399-L408
|
|
29
|
-
// and Options with a single byte 0 or 1 tag:
|
|
30
|
-
// https://docs.rs/bincode/latest/src/bincode/ser/mod.rs.html#137-147
|
|
31
|
-
//However, even if the program is made immutable the bpf_loader_upgradeable program will keep the
|
|
32
|
-
// last value of the enum variant and only set the option byte tag to 0, presumably so they don't
|
|
33
|
-
// have to memcopy the entire subsequent bytecode (they didn't really think that one through).
|
|
34
|
-
//See https://explorer.solana.com/address/GDDMwNyyx8uB6zrqwBFHjLLG3TBYk2F8Az4yrQC5RzMp
|
|
35
|
-
// as an example of an immutable program data account.
|
|
36
|
-
exports.programDataLayout = [
|
|
37
|
-
{ name: "programDataEnumVariant", ...onChainUint, size: 4, custom: 3, omit: true },
|
|
38
|
-
{ name: "slot", ...onChainUint, size: 8 },
|
|
39
|
-
{
|
|
40
|
-
name: "upgradeAuthority",
|
|
41
|
-
binary: "switch",
|
|
42
|
-
idSize: 1,
|
|
43
|
-
idTag: "isSome",
|
|
44
|
-
layouts: [
|
|
45
|
-
[[0, false], [{ name: "_lastValueBeforeImmutability", binary: "bytes", size: 32 }]],
|
|
46
|
-
[[1, true], [{ name: "value", binary: "bytes", size: 32, custom: pubKeyConversion }]],
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
{ name: "bytecode", binary: "bytes" },
|
|
50
|
-
];
|
|
51
|
-
//# sourceMappingURL=bpfLoaderUpgradeable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,mGAAmG;AACnG,kGAAkG;AAClG,iGAAiG;AACjG,SAAgB,kBAAkB,CAAC,SAA4B;IAC7D,OAAO,mBAAS,CAAC,sBAAsB,CAAC,CAAC,IAAI,mBAAS,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,yCAAiC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtH,CAAC;AAFD,gDAEC;AAED,MAAM,WAAW,G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@
|
|
|
1
|
-
import type { Provider } from '@coral-xyz/anchor';
|
|
2
|
-
import type { Connection } from '@solana/web3.js';
|
|
3
|
-
export declare function createReadOnlyProvider(connection?: Connection): Provider | undefined;
|
|
4
|
-
export * from './account.js';
|
|
5
|
-
export * from './bpfLoaderUpgradeable.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAgB,sBAAsB,CACpC,UAAU,CAAC,EAAE,UAAU,GACtB,QAAQ,GAAG,SAAS,CAKtB;AAED,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC"}
|