@thru/programs 0.3.18 → 0.4.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/README.md +9 -0
- package/dist/abi-manager/index.cjs +153 -32
- package/dist/abi-manager/index.cjs.map +1 -1
- package/dist/abi-manager/index.d.cts +1 -1
- package/dist/abi-manager/index.d.ts +1 -1
- package/dist/abi-manager/index.js +3 -2
- package/dist/amm/index.cjs +81 -47
- package/dist/amm/index.cjs.map +1 -1
- package/dist/amm/index.js +2 -3
- package/dist/amm/index.js.map +1 -1
- package/dist/bootstrap-addresses/index.cjs +58 -20
- package/dist/bootstrap-addresses/index.cjs.map +1 -1
- package/dist/bootstrap-addresses/index.d.cts +38 -19
- package/dist/bootstrap-addresses/index.d.ts +38 -19
- package/dist/bootstrap-addresses/index.js +2 -3
- package/dist/{chunk-UPB725FV.js → chunk-2NNQJFKS.js} +5 -4
- package/dist/chunk-2NNQJFKS.js.map +1 -0
- package/dist/{chunk-FQDO6J6E.js → chunk-A2BWZE2D.js} +12 -10
- package/dist/chunk-A2BWZE2D.js.map +1 -0
- package/dist/{chunk-PRU4KGQO.js → chunk-JHINXDSG.js} +43 -4
- package/dist/chunk-JHINXDSG.js.map +1 -0
- package/dist/{chunk-Q6762F4G.js → chunk-QGOAPK5X.js} +3 -3
- package/dist/{chunk-Q6762F4G.js.map → chunk-QGOAPK5X.js.map} +1 -1
- package/dist/chunk-S3UTJHRO.js +77 -0
- package/dist/chunk-S3UTJHRO.js.map +1 -0
- package/dist/{chunk-NMPO53TW.js → chunk-ZOFTRAAH.js} +4 -4
- package/dist/{chunk-NMPO53TW.js.map → chunk-ZOFTRAAH.js.map} +1 -1
- package/dist/{chunk-IGZZOZ73.js → chunk-ZP7A3GHV.js} +3 -4
- package/dist/chunk-ZP7A3GHV.js.map +1 -0
- package/dist/clob/index.cjs +164 -130
- package/dist/clob/index.cjs.map +1 -1
- package/dist/clob/index.js +4 -5
- package/dist/clob/index.js.map +1 -1
- package/dist/deploy/index.cjs +240 -168
- package/dist/deploy/index.cjs.map +1 -1
- package/dist/deploy/index.d.cts +5 -0
- package/dist/deploy/index.d.ts +5 -0
- package/dist/deploy/index.js +66 -37
- package/dist/deploy/index.js.map +1 -1
- package/dist/manager/index.cjs +14 -1
- package/dist/manager/index.cjs.map +1 -1
- package/dist/manager/index.d.cts +5 -1
- package/dist/manager/index.d.ts +5 -1
- package/dist/manager/index.js +2 -3
- package/dist/multicall/index.cjs +57 -23
- package/dist/multicall/index.cjs.map +1 -1
- package/dist/multicall/index.js +3 -4
- package/dist/oracle/index.cjs +64 -30
- package/dist/oracle/index.cjs.map +1 -1
- package/dist/oracle/index.js +2 -3
- package/dist/oracle/index.js.map +1 -1
- package/dist/passkey-manager/index.cjs +52 -18
- package/dist/passkey-manager/index.cjs.map +1 -1
- package/dist/passkey-manager/index.js +2 -3
- package/dist/passkey-manager/index.js.map +1 -1
- package/dist/perp/index.cjs +12 -2
- package/dist/perp/index.cjs.map +1 -1
- package/dist/perp/index.js +2 -3
- package/dist/perp/index.js.map +1 -1
- package/dist/uploader/index.cjs +45 -7
- package/dist/uploader/index.cjs.map +1 -1
- package/dist/uploader/index.d.cts +2 -1
- package/dist/uploader/index.d.ts +2 -1
- package/dist/uploader/index.js +2 -2
- package/package.json +2 -2
- package/src/abi-manager/constants.ts +2 -1
- package/src/abi-manager/index.test.ts +2 -2
- package/src/bootstrap-addresses/index.test.ts +70 -18
- package/src/bootstrap-addresses/index.ts +56 -19
- package/src/deploy/accounts.ts +7 -3
- package/src/deploy/chain.ts +1 -1
- package/src/deploy/constants.ts +3 -4
- package/src/deploy/deploy.test.ts +11 -10
- package/src/deploy/inspection.ts +3 -2
- package/src/deploy/types.ts +5 -0
- package/src/deploy/uploader.ts +5 -4
- package/src/deploy/workflows.test.ts +74 -5
- package/src/deploy/workflows.ts +55 -17
- package/src/manager/constants.ts +14 -2
- package/src/manager/derivation.ts +3 -3
- package/src/manager/index.test.ts +3 -3
- package/src/manager/index.ts +3 -0
- package/src/manager/types.ts +1 -1
- package/src/multicall/index.test.ts +1 -1
- package/src/passkey-manager/validate.test.ts +1 -1
- package/src/uploader/constants.ts +5 -4
- package/src/uploader/index.test.ts +2 -2
- package/src/uploader/index.ts +1 -0
- package/dist/chunk-FHYZQ5R3.js +0 -37
- package/dist/chunk-FHYZQ5R3.js.map +0 -1
- package/dist/chunk-FQDO6J6E.js.map +0 -1
- package/dist/chunk-IGZZOZ73.js.map +0 -1
- package/dist/chunk-O2ONVSHW.js +0 -51
- package/dist/chunk-O2ONVSHW.js.map +0 -1
- package/dist/chunk-PRU4KGQO.js.map +0 -1
- package/dist/chunk-UPB725FV.js.map +0 -1
package/dist/deploy/index.cjs
CHANGED
|
@@ -30,18 +30,6 @@ function asDeployError(error, code, message, options = {}) {
|
|
|
30
30
|
if (error instanceof DeployError) return error;
|
|
31
31
|
return new DeployError(code, message, { ...options, cause: error });
|
|
32
32
|
}
|
|
33
|
-
var ABI_MANAGER_PROGRAM_ADDRESS = "taAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACrG7";
|
|
34
|
-
sdk.Pubkey.from(
|
|
35
|
-
ABI_MANAGER_PROGRAM_ADDRESS
|
|
36
|
-
).toBytes();
|
|
37
|
-
var ABI_META_SIZE = 100;
|
|
38
|
-
var ABI_ACCOUNT_HEADER_SIZE = 45;
|
|
39
|
-
var ABI_META_VERSION = 1;
|
|
40
|
-
var ABI_META_KIND_OFFICIAL = 0;
|
|
41
|
-
var ABI_META_KIND_EXTERNAL = 1;
|
|
42
|
-
var ABI_STATE_OPEN = 0;
|
|
43
|
-
var ABI_STATE_FINALIZED = 1;
|
|
44
|
-
var ABI_ACCOUNT_SEED_SUFFIX = new TextEncoder().encode("_abi_account");
|
|
45
33
|
var PUBKEY_LENGTH = 32;
|
|
46
34
|
var TEXT_ENCODER = new TextEncoder();
|
|
47
35
|
function systemProgramPubkey(lastByte) {
|
|
@@ -116,7 +104,129 @@ function assertInteger(value, minimum, maximum, label) {
|
|
|
116
104
|
}
|
|
117
105
|
}
|
|
118
106
|
|
|
119
|
-
// src/
|
|
107
|
+
// src/manager/constants.ts
|
|
108
|
+
var ROOT_MANAGER_PROGRAM_PUBKEY = systemProgramPubkey(1);
|
|
109
|
+
var ROOT_MANAGER_PROGRAM_ADDRESS = helpers.encodeAddress(ROOT_MANAGER_PROGRAM_PUBKEY);
|
|
110
|
+
var MANAGER_PROGRAM_SEED = "thru-main-manager:949457";
|
|
111
|
+
var managerMeta = sdk.deriveProgramAddress({
|
|
112
|
+
programAddress: ROOT_MANAGER_PROGRAM_ADDRESS,
|
|
113
|
+
seed: padSeed(MANAGER_PROGRAM_SEED)
|
|
114
|
+
});
|
|
115
|
+
var MANAGER_PROGRAM_PUBKEY = sdk.deriveProgramAddress({
|
|
116
|
+
programAddress: ROOT_MANAGER_PROGRAM_ADDRESS,
|
|
117
|
+
seed: managerMeta.bytes
|
|
118
|
+
}).bytes;
|
|
119
|
+
var MANAGER_PROGRAM_ADDRESS = helpers.encodeAddress(MANAGER_PROGRAM_PUBKEY);
|
|
120
|
+
var MANAGER_META_SIZE = 73;
|
|
121
|
+
var MANAGER_STATE_OPEN = 0;
|
|
122
|
+
var MANAGER_STATE_PAUSED = 1;
|
|
123
|
+
var MANAGER_STATE_FINALIZED = 2;
|
|
124
|
+
var MANAGER_PROGRAM_IMAGE_VERSION = 1;
|
|
125
|
+
var MANAGER_PROGRAM_IMAGE_HEADER_SIZE = 8;
|
|
126
|
+
var MANAGER_PROGRAM_IMAGE_TRAILER_SIZE = 8;
|
|
127
|
+
var MANAGER_PROGRAM_IMAGE_MIN_TEXT_SIZE = 4;
|
|
128
|
+
|
|
129
|
+
// src/manager/derivation.ts
|
|
130
|
+
function deriveManagedProgramAddresses(seed, ephemeral = false, managerProgramAddress = MANAGER_PROGRAM_ADDRESS) {
|
|
131
|
+
const manager = pubkeyBytes(managerProgramAddress, "manager program address");
|
|
132
|
+
const meta = sdk.deriveProgramAddress({
|
|
133
|
+
programAddress: manager,
|
|
134
|
+
seed: padSeed(seed),
|
|
135
|
+
ephemeral
|
|
136
|
+
});
|
|
137
|
+
const program = sdk.deriveProgramAddress({
|
|
138
|
+
programAddress: manager,
|
|
139
|
+
seed: meta.bytes,
|
|
140
|
+
ephemeral
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
programMetaAccountAddress: meta.address,
|
|
144
|
+
programMetaAccountBytes: meta.bytes,
|
|
145
|
+
programAccountAddress: program.address,
|
|
146
|
+
programAccountBytes: program.bytes
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
var BOOTSTRAP_PROGRAM_SEEDS = Object.freeze({
|
|
150
|
+
noop: "thru-program:22654259",
|
|
151
|
+
faucet: "thru-program:310129",
|
|
152
|
+
name_service: "thru-program:2236909",
|
|
153
|
+
oracle: "thru-program:87959905",
|
|
154
|
+
multicall: "thru-program:3153525730",
|
|
155
|
+
abi_manager: "thru-program:167497",
|
|
156
|
+
token: "thru-program:3767426089",
|
|
157
|
+
amm: "thru-program:4614050",
|
|
158
|
+
clob: "thru-program:79287062",
|
|
159
|
+
thru_registrar: "thru-program:449594",
|
|
160
|
+
wthru: "thru-program:1687299648",
|
|
161
|
+
passkey_manager: "thru-program:1746189",
|
|
162
|
+
nft: "thru-program:1654635",
|
|
163
|
+
block_producer: "thru-program:8222",
|
|
164
|
+
consensus_validator: "thru-program:35555736"
|
|
165
|
+
});
|
|
166
|
+
function managedProgramAddress(seed) {
|
|
167
|
+
return deriveManagedProgramAddresses(seed).programAccountAddress;
|
|
168
|
+
}
|
|
169
|
+
var GENESIS_EOA_PROGRAM_SEED = "thru-program:207434";
|
|
170
|
+
managedProgramAddress(GENESIS_EOA_PROGRAM_SEED);
|
|
171
|
+
var BOOTSTRAP_PROGRAM_ADDRESSES = Object.freeze({
|
|
172
|
+
noop: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.noop),
|
|
173
|
+
faucet: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.faucet),
|
|
174
|
+
name_service: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.name_service),
|
|
175
|
+
oracle: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.oracle),
|
|
176
|
+
multicall: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.multicall),
|
|
177
|
+
abi_manager: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.abi_manager),
|
|
178
|
+
token: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.token),
|
|
179
|
+
amm: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.amm),
|
|
180
|
+
clob: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.clob),
|
|
181
|
+
thru_registrar: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.thru_registrar),
|
|
182
|
+
wthru: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.wthru),
|
|
183
|
+
passkey_manager: managedProgramAddress(
|
|
184
|
+
BOOTSTRAP_PROGRAM_SEEDS.passkey_manager
|
|
185
|
+
),
|
|
186
|
+
nft: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.nft),
|
|
187
|
+
block_producer: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.block_producer),
|
|
188
|
+
consensus_validator: managedProgramAddress(
|
|
189
|
+
BOOTSTRAP_PROGRAM_SEEDS.consensus_validator
|
|
190
|
+
)
|
|
191
|
+
});
|
|
192
|
+
function stateAddress(program, label) {
|
|
193
|
+
const seed = new Uint8Array(32);
|
|
194
|
+
seed.set(new TextEncoder().encode(label));
|
|
195
|
+
return sdk.deriveProgramAddress({ programAddress: program, seed }).address;
|
|
196
|
+
}
|
|
197
|
+
var wthruSeed = new Uint8Array(32);
|
|
198
|
+
stateAddress(BOOTSTRAP_PROGRAM_ADDRESSES.faucet, "vault");
|
|
199
|
+
wthruSeed.set(new TextEncoder().encode("wthru"));
|
|
200
|
+
var wthruMintSeed = sdk.deriveAddress([
|
|
201
|
+
sdk.Pubkey.from(BOOTSTRAP_PROGRAM_ADDRESSES.wthru).toBytes(),
|
|
202
|
+
wthruSeed
|
|
203
|
+
]).bytes;
|
|
204
|
+
Object.freeze({
|
|
205
|
+
attestor_table: stateAddress(BOOTSTRAP_PROGRAM_ADDRESSES.consensus_validator, "attestor_table"),
|
|
206
|
+
attestor_mint: stateAddress(BOOTSTRAP_PROGRAM_ADDRESSES.consensus_validator, "attestor_mint"),
|
|
207
|
+
converted_vault: stateAddress(BOOTSTRAP_PROGRAM_ADDRESSES.consensus_validator, "converted_vault"),
|
|
208
|
+
unclaimed_vault: stateAddress(BOOTSTRAP_PROGRAM_ADDRESSES.consensus_validator, "unclaimed_vault"),
|
|
209
|
+
validator_token_base: stateAddress(BOOTSTRAP_PROGRAM_ADDRESSES.consensus_validator, "validator_token"),
|
|
210
|
+
wthru_mint: sdk.deriveProgramAddress({
|
|
211
|
+
programAddress: BOOTSTRAP_PROGRAM_ADDRESSES.token,
|
|
212
|
+
seed: wthruMintSeed
|
|
213
|
+
}).address,
|
|
214
|
+
wthru_vault: stateAddress(BOOTSTRAP_PROGRAM_ADDRESSES.wthru, "vault")
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// src/abi-manager/constants.ts
|
|
218
|
+
var ABI_MANAGER_PROGRAM_ADDRESS = BOOTSTRAP_PROGRAM_ADDRESSES.abi_manager;
|
|
219
|
+
sdk.Pubkey.from(
|
|
220
|
+
ABI_MANAGER_PROGRAM_ADDRESS
|
|
221
|
+
).toBytes();
|
|
222
|
+
var ABI_META_SIZE = 100;
|
|
223
|
+
var ABI_ACCOUNT_HEADER_SIZE = 45;
|
|
224
|
+
var ABI_META_VERSION = 1;
|
|
225
|
+
var ABI_META_KIND_OFFICIAL = 0;
|
|
226
|
+
var ABI_META_KIND_EXTERNAL = 1;
|
|
227
|
+
var ABI_STATE_OPEN = 0;
|
|
228
|
+
var ABI_STATE_FINALIZED = 1;
|
|
229
|
+
var ABI_ACCOUNT_SEED_SUFFIX = new TextEncoder().encode("_abi_account");
|
|
120
230
|
new TextEncoder();
|
|
121
231
|
function deriveOfficialABIAddresses(programAddress, ephemeral = false, abiManagerProgramAddress = ABI_MANAGER_PROGRAM_ADDRESS) {
|
|
122
232
|
const body = new Uint8Array(96);
|
|
@@ -1618,7 +1728,7 @@ var __tn_ir_Pubkey = {
|
|
|
1618
1728
|
typeName: "Pubkey",
|
|
1619
1729
|
root: { op: "const", value: 32n }
|
|
1620
1730
|
};
|
|
1621
|
-
var
|
|
1731
|
+
var Pubkey4 = class _Pubkey {
|
|
1622
1732
|
constructor(buffer) {
|
|
1623
1733
|
this.buffer = buffer;
|
|
1624
1734
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
@@ -1718,15 +1828,15 @@ var PubkeyBuilder = class {
|
|
|
1718
1828
|
return target;
|
|
1719
1829
|
}
|
|
1720
1830
|
finish() {
|
|
1721
|
-
const view =
|
|
1831
|
+
const view = Pubkey4.from_array(this.buffer.slice());
|
|
1722
1832
|
if (!view) throw new Error("failed to build Pubkey");
|
|
1723
1833
|
return view;
|
|
1724
1834
|
}
|
|
1725
1835
|
};
|
|
1726
|
-
__tnRegisterFootprint("Pubkey", (params) =>
|
|
1727
|
-
__tnRegisterValidate("Pubkey", (buffer, params) =>
|
|
1836
|
+
__tnRegisterFootprint("Pubkey", (params) => Pubkey4.__tnInvokeFootprint(params));
|
|
1837
|
+
__tnRegisterValidate("Pubkey", (buffer, params) => Pubkey4.__tnInvokeValidate(buffer, params));
|
|
1728
1838
|
__tnRegisterDynamicValidate("Pubkey", (buffer) => {
|
|
1729
|
-
const result =
|
|
1839
|
+
const result = Pubkey4.validate(buffer);
|
|
1730
1840
|
const params = result.params;
|
|
1731
1841
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt(result.consumed), params };
|
|
1732
1842
|
});
|
|
@@ -2572,10 +2682,10 @@ __tnRegisterDynamicValidate2("Hash", (buffer) => {
|
|
|
2572
2682
|
const params = result.params;
|
|
2573
2683
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt2(result.consumed), params };
|
|
2574
2684
|
});
|
|
2575
|
-
__tnRegisterFootprint2("Pubkey", (params) =>
|
|
2576
|
-
__tnRegisterValidate2("Pubkey", (buffer, params) =>
|
|
2685
|
+
__tnRegisterFootprint2("Pubkey", (params) => Pubkey4.__tnInvokeFootprint(params));
|
|
2686
|
+
__tnRegisterValidate2("Pubkey", (buffer, params) => Pubkey4.__tnInvokeValidate(buffer, params));
|
|
2577
2687
|
__tnRegisterDynamicValidate2("Pubkey", (buffer) => {
|
|
2578
|
-
const result =
|
|
2688
|
+
const result = Pubkey4.validate(buffer);
|
|
2579
2689
|
const params = result.params;
|
|
2580
2690
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt2(result.consumed), params };
|
|
2581
2691
|
});
|
|
@@ -2879,7 +2989,7 @@ var StateProof_proof_body_creation_Inner = class _StateProof_proof_body_creation
|
|
|
2879
2989
|
get_existing_leaf_pubkey() {
|
|
2880
2990
|
const offset = 0;
|
|
2881
2991
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
2882
|
-
return
|
|
2992
|
+
return Pubkey4.from_array(slice);
|
|
2883
2993
|
}
|
|
2884
2994
|
set_existing_leaf_pubkey(value) {
|
|
2885
2995
|
const sourceBytes = value.buffer;
|
|
@@ -4042,10 +4152,10 @@ function __tnNormalizeIrError3(err) {
|
|
|
4042
4152
|
if (message.length > 0) return `tn.ir.runtime_error: ${message}`;
|
|
4043
4153
|
return "tn.ir.runtime_error";
|
|
4044
4154
|
}
|
|
4045
|
-
__tnRegisterFootprint3("Pubkey", (params) =>
|
|
4046
|
-
__tnRegisterValidate3("Pubkey", (buffer, params) =>
|
|
4155
|
+
__tnRegisterFootprint3("Pubkey", (params) => Pubkey4.__tnInvokeFootprint(params));
|
|
4156
|
+
__tnRegisterValidate3("Pubkey", (buffer, params) => Pubkey4.__tnInvokeValidate(buffer, params));
|
|
4047
4157
|
__tnRegisterDynamicValidate3("Pubkey", (buffer) => {
|
|
4048
|
-
const result =
|
|
4158
|
+
const result = Pubkey4.validate(buffer);
|
|
4049
4159
|
const params = result.params;
|
|
4050
4160
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt3(result.consumed), params };
|
|
4051
4161
|
});
|
|
@@ -5951,7 +6061,7 @@ var _AbiAccount = class _AbiAccount {
|
|
|
5951
6061
|
get_abi_meta_acc() {
|
|
5952
6062
|
const offset = 0;
|
|
5953
6063
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
5954
|
-
return
|
|
6064
|
+
return Pubkey4.from_array(slice);
|
|
5955
6065
|
}
|
|
5956
6066
|
set_abi_meta_acc(value) {
|
|
5957
6067
|
const sourceBytes = value.buffer;
|
|
@@ -6283,7 +6393,7 @@ var AbiMetaBodyExternal = class _AbiMetaBodyExternal {
|
|
|
6283
6393
|
get_publisher() {
|
|
6284
6394
|
const offset = 0;
|
|
6285
6395
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
6286
|
-
return
|
|
6396
|
+
return Pubkey4.from_array(slice);
|
|
6287
6397
|
}
|
|
6288
6398
|
set_publisher(value) {
|
|
6289
6399
|
const sourceBytes = value.buffer;
|
|
@@ -6299,7 +6409,7 @@ var AbiMetaBodyExternal = class _AbiMetaBodyExternal {
|
|
|
6299
6409
|
get_target_program() {
|
|
6300
6410
|
const offset = 32;
|
|
6301
6411
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
6302
|
-
return
|
|
6412
|
+
return Pubkey4.from_array(slice);
|
|
6303
6413
|
}
|
|
6304
6414
|
set_target_program(value) {
|
|
6305
6415
|
const sourceBytes = value.buffer;
|
|
@@ -6431,7 +6541,7 @@ var AbiMetaBodyOfficial = class _AbiMetaBodyOfficial {
|
|
|
6431
6541
|
get_program() {
|
|
6432
6542
|
const offset = 0;
|
|
6433
6543
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
6434
|
-
return
|
|
6544
|
+
return Pubkey4.from_array(slice);
|
|
6435
6545
|
}
|
|
6436
6546
|
set_program(value) {
|
|
6437
6547
|
const sourceBytes = value.buffer;
|
|
@@ -6565,7 +6675,7 @@ var CreateMetaExternalEphemeralArgs = class _CreateMetaExternalEphemeralArgs {
|
|
|
6565
6675
|
get_target_program() {
|
|
6566
6676
|
const offset = 4;
|
|
6567
6677
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
6568
|
-
return
|
|
6678
|
+
return Pubkey4.from_array(slice);
|
|
6569
6679
|
}
|
|
6570
6680
|
set_target_program(value) {
|
|
6571
6681
|
const sourceBytes = value.buffer;
|
|
@@ -7728,7 +7838,7 @@ var CreateMetaExternalPermanentArgs = class _CreateMetaExternalPermanentArgs {
|
|
|
7728
7838
|
get_target_program() {
|
|
7729
7839
|
const offset = 4;
|
|
7730
7840
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
7731
|
-
return
|
|
7841
|
+
return Pubkey4.from_array(slice);
|
|
7732
7842
|
}
|
|
7733
7843
|
set_target_program(value) {
|
|
7734
7844
|
const sourceBytes = value.buffer;
|
|
@@ -9377,35 +9487,6 @@ function createUpgradeOfficialABIInstruction(args) {
|
|
|
9377
9487
|
...officialABIIndices(context, args)
|
|
9378
9488
|
});
|
|
9379
9489
|
}
|
|
9380
|
-
var MANAGER_PROGRAM_PUBKEY = systemProgramPubkey(4);
|
|
9381
|
-
var MANAGER_PROGRAM_ADDRESS = helpers.encodeAddress(MANAGER_PROGRAM_PUBKEY);
|
|
9382
|
-
var MANAGER_META_SIZE = 73;
|
|
9383
|
-
var MANAGER_STATE_OPEN = 0;
|
|
9384
|
-
var MANAGER_STATE_PAUSED = 1;
|
|
9385
|
-
var MANAGER_STATE_FINALIZED = 2;
|
|
9386
|
-
var MANAGER_PROGRAM_IMAGE_VERSION = 1;
|
|
9387
|
-
var MANAGER_PROGRAM_IMAGE_HEADER_SIZE = 8;
|
|
9388
|
-
var MANAGER_PROGRAM_IMAGE_TRAILER_SIZE = 8;
|
|
9389
|
-
var MANAGER_PROGRAM_IMAGE_MIN_TEXT_SIZE = 4;
|
|
9390
|
-
function deriveManagedProgramAddresses(seed, ephemeral = false, managerProgramAddress = MANAGER_PROGRAM_ADDRESS) {
|
|
9391
|
-
const manager = pubkeyBytes(managerProgramAddress, "manager program address");
|
|
9392
|
-
const meta = sdk.deriveProgramAddress({
|
|
9393
|
-
programAddress: manager,
|
|
9394
|
-
seed: padSeed(seed),
|
|
9395
|
-
ephemeral
|
|
9396
|
-
});
|
|
9397
|
-
const program = sdk.deriveProgramAddress({
|
|
9398
|
-
programAddress: manager,
|
|
9399
|
-
seed: meta.bytes,
|
|
9400
|
-
ephemeral
|
|
9401
|
-
});
|
|
9402
|
-
return {
|
|
9403
|
-
programMetaAccountAddress: meta.address,
|
|
9404
|
-
programMetaAccountBytes: meta.bytes,
|
|
9405
|
-
programAccountAddress: program.address,
|
|
9406
|
-
programAccountBytes: program.bytes
|
|
9407
|
-
};
|
|
9408
|
-
}
|
|
9409
9490
|
|
|
9410
9491
|
// src/manager/abi/thru/common/primitives/types.ts
|
|
9411
9492
|
var __tnWarnings4 = /* @__PURE__ */ new Set();
|
|
@@ -10870,7 +10951,7 @@ var __tn_ir_Pubkey2 = {
|
|
|
10870
10951
|
typeName: "Pubkey",
|
|
10871
10952
|
root: { op: "const", value: 32n }
|
|
10872
10953
|
};
|
|
10873
|
-
var
|
|
10954
|
+
var Pubkey5 = class _Pubkey {
|
|
10874
10955
|
constructor(buffer) {
|
|
10875
10956
|
this.buffer = buffer;
|
|
10876
10957
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
@@ -10970,15 +11051,15 @@ var PubkeyBuilder2 = class {
|
|
|
10970
11051
|
return target;
|
|
10971
11052
|
}
|
|
10972
11053
|
finish() {
|
|
10973
|
-
const view =
|
|
11054
|
+
const view = Pubkey5.from_array(this.buffer.slice());
|
|
10974
11055
|
if (!view) throw new Error("failed to build Pubkey");
|
|
10975
11056
|
return view;
|
|
10976
11057
|
}
|
|
10977
11058
|
};
|
|
10978
|
-
__tnRegisterFootprint4("Pubkey", (params) =>
|
|
10979
|
-
__tnRegisterValidate4("Pubkey", (buffer, params) =>
|
|
11059
|
+
__tnRegisterFootprint4("Pubkey", (params) => Pubkey5.__tnInvokeFootprint(params));
|
|
11060
|
+
__tnRegisterValidate4("Pubkey", (buffer, params) => Pubkey5.__tnInvokeValidate(buffer, params));
|
|
10980
11061
|
__tnRegisterDynamicValidate4("Pubkey", (buffer) => {
|
|
10981
|
-
const result =
|
|
11062
|
+
const result = Pubkey5.validate(buffer);
|
|
10982
11063
|
const params = result.params;
|
|
10983
11064
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt4(result.consumed), params };
|
|
10984
11065
|
});
|
|
@@ -11824,10 +11905,10 @@ __tnRegisterDynamicValidate5("Hash", (buffer) => {
|
|
|
11824
11905
|
const params = result.params;
|
|
11825
11906
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt5(result.consumed), params };
|
|
11826
11907
|
});
|
|
11827
|
-
__tnRegisterFootprint5("Pubkey", (params) =>
|
|
11828
|
-
__tnRegisterValidate5("Pubkey", (buffer, params) =>
|
|
11908
|
+
__tnRegisterFootprint5("Pubkey", (params) => Pubkey5.__tnInvokeFootprint(params));
|
|
11909
|
+
__tnRegisterValidate5("Pubkey", (buffer, params) => Pubkey5.__tnInvokeValidate(buffer, params));
|
|
11829
11910
|
__tnRegisterDynamicValidate5("Pubkey", (buffer) => {
|
|
11830
|
-
const result =
|
|
11911
|
+
const result = Pubkey5.validate(buffer);
|
|
11831
11912
|
const params = result.params;
|
|
11832
11913
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt5(result.consumed), params };
|
|
11833
11914
|
});
|
|
@@ -12131,7 +12212,7 @@ var StateProof_proof_body_creation_Inner2 = class _StateProof_proof_body_creatio
|
|
|
12131
12212
|
get_existing_leaf_pubkey() {
|
|
12132
12213
|
const offset = 0;
|
|
12133
12214
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
12134
|
-
return
|
|
12215
|
+
return Pubkey5.from_array(slice);
|
|
12135
12216
|
}
|
|
12136
12217
|
set_existing_leaf_pubkey(value) {
|
|
12137
12218
|
const sourceBytes = value.buffer;
|
|
@@ -13294,10 +13375,10 @@ function __tnNormalizeIrError6(err) {
|
|
|
13294
13375
|
if (message.length > 0) return `tn.ir.runtime_error: ${message}`;
|
|
13295
13376
|
return "tn.ir.runtime_error";
|
|
13296
13377
|
}
|
|
13297
|
-
__tnRegisterFootprint6("Pubkey", (params) =>
|
|
13298
|
-
__tnRegisterValidate6("Pubkey", (buffer, params) =>
|
|
13378
|
+
__tnRegisterFootprint6("Pubkey", (params) => Pubkey5.__tnInvokeFootprint(params));
|
|
13379
|
+
__tnRegisterValidate6("Pubkey", (buffer, params) => Pubkey5.__tnInvokeValidate(buffer, params));
|
|
13299
13380
|
__tnRegisterDynamicValidate6("Pubkey", (buffer) => {
|
|
13300
|
-
const result =
|
|
13381
|
+
const result = Pubkey5.validate(buffer);
|
|
13301
13382
|
const params = result.params;
|
|
13302
13383
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt6(result.consumed), params };
|
|
13303
13384
|
});
|
|
@@ -14031,7 +14112,7 @@ var SetAuthorityArgs = class _SetAuthorityArgs {
|
|
|
14031
14112
|
get_authority_candidate() {
|
|
14032
14113
|
const offset = 4;
|
|
14033
14114
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
14034
|
-
return
|
|
14115
|
+
return Pubkey5.from_array(slice);
|
|
14035
14116
|
}
|
|
14036
14117
|
set_authority_candidate(value) {
|
|
14037
14118
|
const sourceBytes = value.buffer;
|
|
@@ -14477,7 +14558,7 @@ var ManagerProgramMeta = class _ManagerProgramMeta {
|
|
|
14477
14558
|
get_authority() {
|
|
14478
14559
|
const offset = 0;
|
|
14479
14560
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
14480
|
-
return
|
|
14561
|
+
return Pubkey5.from_array(slice);
|
|
14481
14562
|
}
|
|
14482
14563
|
set_authority(value) {
|
|
14483
14564
|
const sourceBytes = value.buffer;
|
|
@@ -14493,7 +14574,7 @@ var ManagerProgramMeta = class _ManagerProgramMeta {
|
|
|
14493
14574
|
get_authority_candidate() {
|
|
14494
14575
|
const offset = 32;
|
|
14495
14576
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
14496
|
-
return
|
|
14577
|
+
return Pubkey5.from_array(slice);
|
|
14497
14578
|
}
|
|
14498
14579
|
set_authority_candidate(value) {
|
|
14499
14580
|
const sourceBytes = value.buffer;
|
|
@@ -15872,49 +15953,6 @@ function createUpgradeProgramInstruction(args) {
|
|
|
15872
15953
|
});
|
|
15873
15954
|
}
|
|
15874
15955
|
|
|
15875
|
-
// src/bootstrap-addresses/index.ts
|
|
15876
|
-
var BOOTSTRAP_PROGRAM_SEEDS = Object.freeze({
|
|
15877
|
-
noop: "thru-noop",
|
|
15878
|
-
faucet: "thru-faucet",
|
|
15879
|
-
name_service: "thru-name_service",
|
|
15880
|
-
oracle: "thru-oracle",
|
|
15881
|
-
multicall: "thru-multicall",
|
|
15882
|
-
abi_manager: "thru-abi_manager",
|
|
15883
|
-
token: "thru-token",
|
|
15884
|
-
amm: "thru-amm",
|
|
15885
|
-
clob: "thru-clob",
|
|
15886
|
-
thru_registrar: "thru-thru_registrar",
|
|
15887
|
-
wthru: "thru-wthru",
|
|
15888
|
-
passkey_manager: "thru-passkey_manager",
|
|
15889
|
-
nft: "thru-nft",
|
|
15890
|
-
block_producer: "thru-block_producer",
|
|
15891
|
-
consensus_validator: "thru-consensus_validator"
|
|
15892
|
-
});
|
|
15893
|
-
function managedProgramAddress(seed) {
|
|
15894
|
-
return deriveManagedProgramAddresses(seed).programAccountAddress;
|
|
15895
|
-
}
|
|
15896
|
-
var BOOTSTRAP_PROGRAM_ADDRESSES = Object.freeze({
|
|
15897
|
-
noop: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.noop),
|
|
15898
|
-
faucet: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.faucet),
|
|
15899
|
-
name_service: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.name_service),
|
|
15900
|
-
oracle: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.oracle),
|
|
15901
|
-
multicall: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.multicall),
|
|
15902
|
-
abi_manager: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.abi_manager),
|
|
15903
|
-
token: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.token),
|
|
15904
|
-
amm: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.amm),
|
|
15905
|
-
clob: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.clob),
|
|
15906
|
-
thru_registrar: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.thru_registrar),
|
|
15907
|
-
wthru: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.wthru),
|
|
15908
|
-
passkey_manager: managedProgramAddress(
|
|
15909
|
-
BOOTSTRAP_PROGRAM_SEEDS.passkey_manager
|
|
15910
|
-
),
|
|
15911
|
-
nft: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.nft),
|
|
15912
|
-
block_producer: managedProgramAddress(BOOTSTRAP_PROGRAM_SEEDS.block_producer),
|
|
15913
|
-
consensus_validator: managedProgramAddress(
|
|
15914
|
-
BOOTSTRAP_PROGRAM_SEEDS.consensus_validator
|
|
15915
|
-
)
|
|
15916
|
-
});
|
|
15917
|
-
|
|
15918
15956
|
// src/multicall/abi/thru/common/primitives/types.ts
|
|
15919
15957
|
var __tnWarnings7 = /* @__PURE__ */ new Set();
|
|
15920
15958
|
var __tnHasNativeBigInt7 = typeof BigInt === "function";
|
|
@@ -17256,7 +17294,7 @@ var __tn_ir_Pubkey3 = {
|
|
|
17256
17294
|
typeName: "Pubkey",
|
|
17257
17295
|
root: { op: "const", value: 32n }
|
|
17258
17296
|
};
|
|
17259
|
-
var
|
|
17297
|
+
var Pubkey6 = class _Pubkey {
|
|
17260
17298
|
constructor(buffer) {
|
|
17261
17299
|
this.buffer = buffer;
|
|
17262
17300
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
@@ -17356,15 +17394,15 @@ var PubkeyBuilder3 = class {
|
|
|
17356
17394
|
return target;
|
|
17357
17395
|
}
|
|
17358
17396
|
finish() {
|
|
17359
|
-
const view =
|
|
17397
|
+
const view = Pubkey6.from_array(this.buffer.slice());
|
|
17360
17398
|
if (!view) throw new Error("failed to build Pubkey");
|
|
17361
17399
|
return view;
|
|
17362
17400
|
}
|
|
17363
17401
|
};
|
|
17364
|
-
__tnRegisterFootprint7("Pubkey", (params) =>
|
|
17365
|
-
__tnRegisterValidate7("Pubkey", (buffer, params) =>
|
|
17402
|
+
__tnRegisterFootprint7("Pubkey", (params) => Pubkey6.__tnInvokeFootprint(params));
|
|
17403
|
+
__tnRegisterValidate7("Pubkey", (buffer, params) => Pubkey6.__tnInvokeValidate(buffer, params));
|
|
17366
17404
|
__tnRegisterDynamicValidate7("Pubkey", (buffer) => {
|
|
17367
|
-
const result =
|
|
17405
|
+
const result = Pubkey6.validate(buffer);
|
|
17368
17406
|
const params = result.params;
|
|
17369
17407
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt7(result.consumed), params };
|
|
17370
17408
|
});
|
|
@@ -18554,7 +18592,7 @@ __tnRegisterDynamicValidate8("MulticallError", (buffer) => {
|
|
|
18554
18592
|
|
|
18555
18593
|
// src/multicall/index.ts
|
|
18556
18594
|
var GENESIS_MULTICALL_PROGRAM_PUBKEY = systemProgramPubkey(9);
|
|
18557
|
-
|
|
18595
|
+
helpers.encodeAddress(
|
|
18558
18596
|
GENESIS_MULTICALL_PROGRAM_PUBKEY
|
|
18559
18597
|
);
|
|
18560
18598
|
var MULTICALL_PROGRAM_ADDRESS = BOOTSTRAP_PROGRAM_ADDRESSES.multicall;
|
|
@@ -18634,8 +18672,12 @@ async function temporarySeed(seed, suffix) {
|
|
|
18634
18672
|
const digest = await sha256(combinedBytes);
|
|
18635
18673
|
return bytesToHex(digest.slice(0, 16));
|
|
18636
18674
|
}
|
|
18637
|
-
|
|
18638
|
-
|
|
18675
|
+
|
|
18676
|
+
// src/uploader/constants.ts
|
|
18677
|
+
var UPLOADER_PROGRAM_SEED = "thru-program:1073768";
|
|
18678
|
+
var uploader = deriveManagedProgramAddresses(UPLOADER_PROGRAM_SEED);
|
|
18679
|
+
uploader.programAccountBytes;
|
|
18680
|
+
var UPLOADER_PROGRAM_ADDRESS = uploader.programAccountAddress;
|
|
18639
18681
|
var UPLOADER_META_SIZE = 65;
|
|
18640
18682
|
var UPLOADER_STATE_OPEN = 1;
|
|
18641
18683
|
var UPLOADER_STATE_FINALIZED = 2;
|
|
@@ -18643,17 +18685,17 @@ var UPLOADER_DEFAULT_CHUNK_SIZE = 30720;
|
|
|
18643
18685
|
var UPLOADER_MIN_CHUNK_SIZE = 1024;
|
|
18644
18686
|
var UPLOADER_MAX_CHUNK_SIZE = 31e3;
|
|
18645
18687
|
function deriveUploadAddresses(seed, uploaderProgramAddress = UPLOADER_PROGRAM_ADDRESS) {
|
|
18646
|
-
const
|
|
18688
|
+
const uploader2 = pubkeyBytes(
|
|
18647
18689
|
uploaderProgramAddress,
|
|
18648
18690
|
"uploader program address"
|
|
18649
18691
|
);
|
|
18650
18692
|
const meta = sdk.deriveProgramAddress({
|
|
18651
|
-
programAddress:
|
|
18693
|
+
programAddress: uploader2,
|
|
18652
18694
|
seed: padSeed(seed),
|
|
18653
18695
|
ephemeral: true
|
|
18654
18696
|
});
|
|
18655
18697
|
const buffer = sdk.deriveProgramAddress({
|
|
18656
|
-
programAddress:
|
|
18698
|
+
programAddress: uploader2,
|
|
18657
18699
|
seed: meta.bytes,
|
|
18658
18700
|
ephemeral: true
|
|
18659
18701
|
});
|
|
@@ -20128,7 +20170,7 @@ var __tn_ir_Pubkey4 = {
|
|
|
20128
20170
|
typeName: "Pubkey",
|
|
20129
20171
|
root: { op: "const", value: 32n }
|
|
20130
20172
|
};
|
|
20131
|
-
var
|
|
20173
|
+
var Pubkey7 = class _Pubkey {
|
|
20132
20174
|
constructor(buffer) {
|
|
20133
20175
|
this.buffer = buffer;
|
|
20134
20176
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
@@ -20228,15 +20270,15 @@ var PubkeyBuilder4 = class {
|
|
|
20228
20270
|
return target;
|
|
20229
20271
|
}
|
|
20230
20272
|
finish() {
|
|
20231
|
-
const view =
|
|
20273
|
+
const view = Pubkey7.from_array(this.buffer.slice());
|
|
20232
20274
|
if (!view) throw new Error("failed to build Pubkey");
|
|
20233
20275
|
return view;
|
|
20234
20276
|
}
|
|
20235
20277
|
};
|
|
20236
|
-
__tnRegisterFootprint9("Pubkey", (params) =>
|
|
20237
|
-
__tnRegisterValidate9("Pubkey", (buffer, params) =>
|
|
20278
|
+
__tnRegisterFootprint9("Pubkey", (params) => Pubkey7.__tnInvokeFootprint(params));
|
|
20279
|
+
__tnRegisterValidate9("Pubkey", (buffer, params) => Pubkey7.__tnInvokeValidate(buffer, params));
|
|
20238
20280
|
__tnRegisterDynamicValidate9("Pubkey", (buffer) => {
|
|
20239
|
-
const result =
|
|
20281
|
+
const result = Pubkey7.validate(buffer);
|
|
20240
20282
|
const params = result.params;
|
|
20241
20283
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt9(result.consumed), params };
|
|
20242
20284
|
});
|
|
@@ -21110,10 +21152,10 @@ __tnRegisterDynamicValidate10("Hash", (buffer) => {
|
|
|
21110
21152
|
const params = result.params;
|
|
21111
21153
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt10(result.consumed), params };
|
|
21112
21154
|
});
|
|
21113
|
-
__tnRegisterFootprint10("Pubkey", (params) =>
|
|
21114
|
-
__tnRegisterValidate10("Pubkey", (buffer, params) =>
|
|
21155
|
+
__tnRegisterFootprint10("Pubkey", (params) => Pubkey7.__tnInvokeFootprint(params));
|
|
21156
|
+
__tnRegisterValidate10("Pubkey", (buffer, params) => Pubkey7.__tnInvokeValidate(buffer, params));
|
|
21115
21157
|
__tnRegisterDynamicValidate10("Pubkey", (buffer) => {
|
|
21116
|
-
const result =
|
|
21158
|
+
const result = Pubkey7.validate(buffer);
|
|
21117
21159
|
const params = result.params;
|
|
21118
21160
|
return { ok: result.ok, code: result.code, consumed: result.consumed === void 0 ? void 0 : __tnToBigInt10(result.consumed), params };
|
|
21119
21161
|
});
|
|
@@ -21378,7 +21420,7 @@ var UploaderProgramMeta = class _UploaderProgramMeta {
|
|
|
21378
21420
|
get_authority() {
|
|
21379
21421
|
const offset = 0;
|
|
21380
21422
|
const slice = this.buffer.subarray(offset, offset + 32);
|
|
21381
|
-
return
|
|
21423
|
+
return Pubkey7.from_array(slice);
|
|
21382
21424
|
}
|
|
21383
21425
|
set_authority(value) {
|
|
21384
21426
|
const sourceBytes = value.buffer;
|
|
@@ -22956,7 +22998,7 @@ function createFinalizeUploadInstruction(args) {
|
|
|
22956
22998
|
}
|
|
22957
22999
|
|
|
22958
23000
|
// src/deploy/constants.ts
|
|
22959
|
-
var DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS =
|
|
23001
|
+
var DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS = MULTICALL_PROGRAM_ADDRESS;
|
|
22960
23002
|
var TRANSACTION_TIMEOUT_MS = 6e4;
|
|
22961
23003
|
|
|
22962
23004
|
// src/deploy/accounts.ts
|
|
@@ -22986,14 +23028,14 @@ function assertOwner(account, owner, label) {
|
|
|
22986
23028
|
);
|
|
22987
23029
|
}
|
|
22988
23030
|
}
|
|
22989
|
-
function assertManagedProgramAccount(account, label = "managed program account") {
|
|
22990
|
-
assertOwner(account,
|
|
23031
|
+
function assertManagedProgramAccount(account, label = "managed program account", managerProgramAddress = MANAGER_PROGRAM_ADDRESS) {
|
|
23032
|
+
assertOwner(account, managerProgramAddress, label);
|
|
22991
23033
|
if (!account.meta?.flags.isProgram) {
|
|
22992
23034
|
throw new DeployError("VERIFICATION_FAILED", `${label} is not executable`);
|
|
22993
23035
|
}
|
|
22994
23036
|
}
|
|
22995
|
-
function parseManagerMeta(account) {
|
|
22996
|
-
assertOwner(account,
|
|
23037
|
+
function parseManagerMeta(account, managerProgramAddress = MANAGER_PROGRAM_ADDRESS) {
|
|
23038
|
+
assertOwner(account, managerProgramAddress, "program metadata account");
|
|
22997
23039
|
try {
|
|
22998
23040
|
const parsed = parseManagerProgramMeta(account);
|
|
22999
23041
|
return {
|
|
@@ -23140,7 +23182,7 @@ async function submitTransaction(client, signer, operation, phase, transaction)
|
|
|
23140
23182
|
header: {
|
|
23141
23183
|
fee: 0n,
|
|
23142
23184
|
computeUnits: transaction.computeUnits ?? 5e8,
|
|
23143
|
-
stateUnits: transaction.stateUnits ??
|
|
23185
|
+
stateUnits: transaction.stateUnits ?? 1,
|
|
23144
23186
|
memoryUnits: transaction.memoryUnits ?? 5e3,
|
|
23145
23187
|
expiryAfter: transaction.expiryAfter ?? 1e4
|
|
23146
23188
|
},
|
|
@@ -23344,7 +23386,8 @@ async function uploadArtifact(client, signer, upload, chunkSize, onProgress) {
|
|
|
23344
23386
|
seed: upload.seed
|
|
23345
23387
|
}),
|
|
23346
23388
|
computeUnits: 5e4 + upload.bytes.length * 2,
|
|
23347
|
-
|
|
23389
|
+
// One metadata account plus the meta-inclusive buffer footprint.
|
|
23390
|
+
stateUnits: 1 + Math.ceil((64 + upload.bytes.length) / 4096),
|
|
23348
23391
|
memoryUnits: 1e4,
|
|
23349
23392
|
expiryAfter: 10
|
|
23350
23393
|
}
|
|
@@ -23439,7 +23482,7 @@ async function uploadArtifact(client, signer, upload, chunkSize, onProgress) {
|
|
|
23439
23482
|
offset
|
|
23440
23483
|
}),
|
|
23441
23484
|
computeUnits: 5e8,
|
|
23442
|
-
stateUnits:
|
|
23485
|
+
stateUnits: 1,
|
|
23443
23486
|
memoryUnits: 5e3,
|
|
23444
23487
|
expiryAfter: 1e4
|
|
23445
23488
|
}
|
|
@@ -23525,7 +23568,7 @@ async function uploadArtifact(client, signer, upload, chunkSize, onProgress) {
|
|
|
23525
23568
|
expectedHash: upload.hash
|
|
23526
23569
|
}),
|
|
23527
23570
|
computeUnits: 5e4 + upload.bytes.length * 200,
|
|
23528
|
-
stateUnits:
|
|
23571
|
+
stateUnits: 1,
|
|
23529
23572
|
memoryUnits: 5e3,
|
|
23530
23573
|
expiryAfter: 1e4
|
|
23531
23574
|
}
|
|
@@ -23596,7 +23639,7 @@ async function cleanupUpload(client, signer, upload, onProgress) {
|
|
|
23596
23639
|
metaAccount: upload.addresses.metaAccountBytes
|
|
23597
23640
|
}),
|
|
23598
23641
|
computeUnits: 5e4,
|
|
23599
|
-
stateUnits:
|
|
23642
|
+
stateUnits: 1,
|
|
23600
23643
|
memoryUnits: 5e3,
|
|
23601
23644
|
expiryAfter: 1e4
|
|
23602
23645
|
}
|
|
@@ -23848,6 +23891,14 @@ function progress(context, phase, status, fields = {}) {
|
|
|
23848
23891
|
});
|
|
23849
23892
|
}
|
|
23850
23893
|
async function createContext(operation, request, programAddressAssertion) {
|
|
23894
|
+
let managerProgramAddress;
|
|
23895
|
+
try {
|
|
23896
|
+
const manager = sdk.Pubkey.from(request.managerProgramAddress ?? MANAGER_PROGRAM_ADDRESS);
|
|
23897
|
+
if (manager.toBytes().every((byte) => byte === 0)) throw new Error("zero parent");
|
|
23898
|
+
managerProgramAddress = manager.toThruFmt();
|
|
23899
|
+
} catch (error) {
|
|
23900
|
+
throw asDeployError(error, "INVALID_INPUT", "managerProgramAddress must be a nonzero Thru address");
|
|
23901
|
+
}
|
|
23851
23902
|
const client = request.client ?? sdk.createThruClient();
|
|
23852
23903
|
const chunkSize = validateSeedAndChunkSize(request.seed, request.chunkSize);
|
|
23853
23904
|
const signer = await resolveSigner(
|
|
@@ -23856,7 +23907,7 @@ async function createContext(operation, request, programAddressAssertion) {
|
|
|
23856
23907
|
request.signer.privateKey
|
|
23857
23908
|
);
|
|
23858
23909
|
const ephemeral = request.ephemeral ?? false;
|
|
23859
|
-
const program = deriveManagedProgramAddresses(request.seed, ephemeral);
|
|
23910
|
+
const program = deriveManagedProgramAddresses(request.seed, ephemeral, managerProgramAddress);
|
|
23860
23911
|
if (programAddressAssertion) {
|
|
23861
23912
|
let supplied;
|
|
23862
23913
|
try {
|
|
@@ -23884,6 +23935,7 @@ async function createContext(operation, request, programAddressAssertion) {
|
|
|
23884
23935
|
client,
|
|
23885
23936
|
signer,
|
|
23886
23937
|
seed: request.seed,
|
|
23938
|
+
managerProgramAddress,
|
|
23887
23939
|
ephemeral,
|
|
23888
23940
|
chunkSize,
|
|
23889
23941
|
program,
|
|
@@ -23891,6 +23943,11 @@ async function createContext(operation, request, programAddressAssertion) {
|
|
|
23891
23943
|
onProgress: request.onProgress
|
|
23892
23944
|
};
|
|
23893
23945
|
}
|
|
23946
|
+
function assertOfficialABIParent(context) {
|
|
23947
|
+
if (context.managerProgramAddress !== MANAGER_PROGRAM_ADDRESS) {
|
|
23948
|
+
throw new DeployError("INVALID_INPUT", "official ABI publication requires the canonical main Manager parent");
|
|
23949
|
+
}
|
|
23950
|
+
}
|
|
23894
23951
|
function addressDetails(context) {
|
|
23895
23952
|
return {
|
|
23896
23953
|
programMetaAccountAddress: context.program.programMetaAccountAddress,
|
|
@@ -23935,7 +23992,7 @@ async function requireProgram(context) {
|
|
|
23935
23992
|
}
|
|
23936
23993
|
);
|
|
23937
23994
|
}
|
|
23938
|
-
const meta = parseManagerMeta(metaAccount);
|
|
23995
|
+
const meta = parseManagerMeta(metaAccount, context.managerProgramAddress);
|
|
23939
23996
|
assertManagerOpen(meta);
|
|
23940
23997
|
if (!bytesEqual(meta.authority, context.signer.publicKey)) {
|
|
23941
23998
|
throw new DeployError(
|
|
@@ -23948,8 +24005,8 @@ async function requireProgram(context) {
|
|
|
23948
24005
|
}
|
|
23949
24006
|
);
|
|
23950
24007
|
}
|
|
23951
|
-
assertManagedProgramAccount(programAccount);
|
|
23952
|
-
return { meta };
|
|
24008
|
+
assertManagedProgramAccount(programAccount, void 0, context.managerProgramAddress);
|
|
24009
|
+
return { meta, dataSize: requireAccountData(programAccount, "managed program account").length };
|
|
23953
24010
|
}
|
|
23954
24011
|
async function requireABI(context) {
|
|
23955
24012
|
const [metaAccount, abiAccount] = await Promise.all([
|
|
@@ -23996,7 +24053,7 @@ async function verifyProgram(context, expectedBytes, expectedVersion) {
|
|
|
23996
24053
|
"managed program readback is missing"
|
|
23997
24054
|
);
|
|
23998
24055
|
}
|
|
23999
|
-
const meta = parseManagerMeta(metaAccount);
|
|
24056
|
+
const meta = parseManagerMeta(metaAccount, context.managerProgramAddress);
|
|
24000
24057
|
assertManagerOpen(meta);
|
|
24001
24058
|
assertPubkeyBytes(
|
|
24002
24059
|
meta.authority,
|
|
@@ -24009,7 +24066,7 @@ async function verifyProgram(context, expectedBytes, expectedVersion) {
|
|
|
24009
24066
|
`program version mismatch: expected ${expectedVersion}, got ${meta.version}`
|
|
24010
24067
|
);
|
|
24011
24068
|
}
|
|
24012
|
-
assertManagedProgramAccount(programAccount);
|
|
24069
|
+
assertManagedProgramAccount(programAccount, void 0, context.managerProgramAddress);
|
|
24013
24070
|
if (expectedBytes && !bytesEqual(
|
|
24014
24071
|
requireAccountData(programAccount, "program account"),
|
|
24015
24072
|
expectedBytes
|
|
@@ -24214,7 +24271,10 @@ async function deployProgram(request) {
|
|
|
24214
24271
|
const abiBytes = request.abi === void 0 ? void 0 : normalizeBytes(request.abi, "abi");
|
|
24215
24272
|
validateProgramImage(programBytes);
|
|
24216
24273
|
const context = await createContext(operation, request);
|
|
24217
|
-
if (abiBytes)
|
|
24274
|
+
if (abiBytes) {
|
|
24275
|
+
assertOfficialABIParent(context);
|
|
24276
|
+
await validateABI(abiBytes, context.client);
|
|
24277
|
+
}
|
|
24218
24278
|
progress(context, "validation", "succeeded");
|
|
24219
24279
|
progress(context, "preflight", "started");
|
|
24220
24280
|
const absent = [
|
|
@@ -24274,7 +24334,8 @@ async function deployProgram(request) {
|
|
|
24274
24334
|
let transaction;
|
|
24275
24335
|
if (!abiBytes || !abiUpload) {
|
|
24276
24336
|
transaction = {
|
|
24277
|
-
program:
|
|
24337
|
+
program: context.managerProgramAddress,
|
|
24338
|
+
stateUnits: 1 + Math.ceil((64 + programBytes.length) / 4096),
|
|
24278
24339
|
readWrite: [
|
|
24279
24340
|
context.program.programMetaAccountAddress,
|
|
24280
24341
|
context.program.programAccountAddress
|
|
@@ -24303,7 +24364,7 @@ async function deployProgram(request) {
|
|
|
24303
24364
|
]);
|
|
24304
24365
|
transaction = {
|
|
24305
24366
|
program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
|
|
24306
|
-
stateUnits:
|
|
24367
|
+
stateUnits: 2 + Math.ceil((64 + programBytes.length) / 4096) + Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiBytes.length) / 4096),
|
|
24307
24368
|
memoryUnits: 1e4,
|
|
24308
24369
|
readWrite: [
|
|
24309
24370
|
context.program.programMetaAccountAddress,
|
|
@@ -24312,14 +24373,14 @@ async function deployProgram(request) {
|
|
|
24312
24373
|
context.abi.abiAccountAddress
|
|
24313
24374
|
],
|
|
24314
24375
|
readOnly: [
|
|
24315
|
-
|
|
24376
|
+
context.managerProgramAddress,
|
|
24316
24377
|
ABI_MANAGER_PROGRAM_ADDRESS,
|
|
24317
24378
|
programUpload.result.bufferAccountAddress,
|
|
24318
24379
|
abiUpload.result.bufferAccountAddress
|
|
24319
24380
|
],
|
|
24320
24381
|
instructionData: (tx) => multicall(tx, [
|
|
24321
24382
|
{
|
|
24322
|
-
program:
|
|
24383
|
+
program: context.managerProgramAddress,
|
|
24323
24384
|
instructionData: createProgramInstruction(
|
|
24324
24385
|
context,
|
|
24325
24386
|
programUpload,
|
|
@@ -24368,6 +24429,7 @@ async function deployProgramABI(request) {
|
|
|
24368
24429
|
request,
|
|
24369
24430
|
request.programAddress
|
|
24370
24431
|
);
|
|
24432
|
+
assertOfficialABIParent(context);
|
|
24371
24433
|
await validateABI(abiBytes, context.client);
|
|
24372
24434
|
progress(context, "validation", "succeeded");
|
|
24373
24435
|
progress(context, "preflight", "started");
|
|
@@ -24408,7 +24470,7 @@ async function deployProgramABI(request) {
|
|
|
24408
24470
|
]);
|
|
24409
24471
|
const transaction = {
|
|
24410
24472
|
program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
|
|
24411
|
-
stateUnits:
|
|
24473
|
+
stateUnits: 1 + Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiBytes.length) / 4096),
|
|
24412
24474
|
memoryUnits: 1e4,
|
|
24413
24475
|
readWrite: [
|
|
24414
24476
|
context.abi.abiMetaAccountAddress,
|
|
@@ -24464,7 +24526,10 @@ async function upgradeProgram(request) {
|
|
|
24464
24526
|
request,
|
|
24465
24527
|
request.programAddress
|
|
24466
24528
|
);
|
|
24467
|
-
if (abiBytes)
|
|
24529
|
+
if (abiBytes) {
|
|
24530
|
+
assertOfficialABIParent(context);
|
|
24531
|
+
await validateABI(abiBytes, context.client);
|
|
24532
|
+
}
|
|
24468
24533
|
progress(context, "validation", "succeeded");
|
|
24469
24534
|
progress(context, "preflight", "started");
|
|
24470
24535
|
const programState = await requireProgram(context);
|
|
@@ -24504,7 +24569,10 @@ async function upgradeProgram(request) {
|
|
|
24504
24569
|
}
|
|
24505
24570
|
const transaction = abiBytes && abiUpload ? {
|
|
24506
24571
|
program: DEPLOYMENT_MULTICALL_PROGRAM_ADDRESS,
|
|
24507
|
-
stateUnits:
|
|
24572
|
+
stateUnits: Math.max(
|
|
24573
|
+
0,
|
|
24574
|
+
Math.ceil((64 + programBytes.length) / 4096) - Math.ceil((64 + programState.dataSize) / 4096) + Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiBytes.length) / 4096) - Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiState.abi.content.length) / 4096)
|
|
24575
|
+
),
|
|
24508
24576
|
memoryUnits: 1e4,
|
|
24509
24577
|
readWrite: [
|
|
24510
24578
|
context.program.programMetaAccountAddress,
|
|
@@ -24512,7 +24580,7 @@ async function upgradeProgram(request) {
|
|
|
24512
24580
|
context.abi.abiAccountAddress
|
|
24513
24581
|
],
|
|
24514
24582
|
readOnly: [
|
|
24515
|
-
|
|
24583
|
+
context.managerProgramAddress,
|
|
24516
24584
|
ABI_MANAGER_PROGRAM_ADDRESS,
|
|
24517
24585
|
context.abi.abiMetaAccountAddress,
|
|
24518
24586
|
programUpload.result.bufferAccountAddress,
|
|
@@ -24520,7 +24588,7 @@ async function upgradeProgram(request) {
|
|
|
24520
24588
|
],
|
|
24521
24589
|
instructionData: (tx) => multicall(tx, [
|
|
24522
24590
|
{
|
|
24523
|
-
program:
|
|
24591
|
+
program: context.managerProgramAddress,
|
|
24524
24592
|
instructionData: upgradeProgramInstruction(
|
|
24525
24593
|
context,
|
|
24526
24594
|
programUpload,
|
|
@@ -24537,7 +24605,8 @@ async function upgradeProgram(request) {
|
|
|
24537
24605
|
}
|
|
24538
24606
|
])
|
|
24539
24607
|
} : {
|
|
24540
|
-
program:
|
|
24608
|
+
program: context.managerProgramAddress,
|
|
24609
|
+
stateUnits: Math.max(0, Math.ceil((64 + programBytes.length) / 4096) - Math.ceil((64 + programState.dataSize) / 4096)),
|
|
24541
24610
|
readWrite: [
|
|
24542
24611
|
context.program.programMetaAccountAddress,
|
|
24543
24612
|
context.program.programAccountAddress
|
|
@@ -24573,6 +24642,7 @@ async function upgradeProgramABI(request) {
|
|
|
24573
24642
|
request,
|
|
24574
24643
|
request.programAddress
|
|
24575
24644
|
);
|
|
24645
|
+
assertOfficialABIParent(context);
|
|
24576
24646
|
await validateABI(abiBytes, context.client);
|
|
24577
24647
|
progress(context, "validation", "succeeded");
|
|
24578
24648
|
progress(context, "preflight", "started");
|
|
@@ -24599,6 +24669,7 @@ async function upgradeProgramABI(request) {
|
|
|
24599
24669
|
);
|
|
24600
24670
|
const transaction = {
|
|
24601
24671
|
program: ABI_MANAGER_PROGRAM_ADDRESS,
|
|
24672
|
+
stateUnits: Math.max(0, Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiBytes.length) / 4096) - Math.ceil((64 + ABI_ACCOUNT_HEADER_SIZE + abiState.abi.content.length) / 4096)),
|
|
24602
24673
|
readWrite: [context.abi.abiAccountAddress],
|
|
24603
24674
|
readOnly: [
|
|
24604
24675
|
context.abi.abiMetaAccountAddress,
|
|
@@ -24638,7 +24709,8 @@ async function inspectProgramDeployment(request) {
|
|
|
24638
24709
|
const ephemeral = request.ephemeral ?? false;
|
|
24639
24710
|
const programAddresses = deriveManagedProgramAddresses(
|
|
24640
24711
|
request.seed,
|
|
24641
|
-
ephemeral
|
|
24712
|
+
ephemeral,
|
|
24713
|
+
request.managerProgramAddress
|
|
24642
24714
|
);
|
|
24643
24715
|
const abiAddresses = deriveProgramABIAddresses(
|
|
24644
24716
|
programAddresses.programAccountAddress,
|
|
@@ -24661,8 +24733,8 @@ async function inspectProgramDeployment(request) {
|
|
|
24661
24733
|
if (!metadataAccount || !programAccount) {
|
|
24662
24734
|
program = absentPair(!!metadataAccount, !!programAccount);
|
|
24663
24735
|
} else {
|
|
24664
|
-
const metadata = parseManagerMeta(metadataAccount);
|
|
24665
|
-
assertManagedProgramAccount(programAccount);
|
|
24736
|
+
const metadata = parseManagerMeta(metadataAccount, request.managerProgramAddress);
|
|
24737
|
+
assertManagedProgramAccount(programAccount, void 0, request.managerProgramAddress);
|
|
24666
24738
|
const authorityAddress = sdk.Pubkey.from(metadata.authority).toThruFmt();
|
|
24667
24739
|
if (request.authorityAddress !== void 0) {
|
|
24668
24740
|
let expectedAuthority;
|