@pushchain/core 5.1.4 → 5.1.5-alpha.1
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 +1 -1
- package/src/lib/index.d.ts +1 -1
- package/src/lib/orchestrator/internals/cascade.js +68 -25
- package/src/lib/orchestrator/internals/execute-funds-payload.js +4 -4
- package/src/lib/orchestrator/internals/execute-standard.js +55 -7
- package/src/lib/orchestrator/internals/gas-calculator.d.ts +10 -0
- package/src/lib/orchestrator/internals/gas-calculator.js +95 -3
- package/src/lib/orchestrator/internals/gateway-client.js +6 -6
- package/src/lib/orchestrator/internals/response-builder.js +24 -1
- package/src/lib/orchestrator/internals/route-handlers.js +27 -43
- package/src/lib/orchestrator/orchestrator.types.d.ts +13 -23
- package/src/lib/orchestrator/route-detector.js +0 -3
- package/src/lib/orchestrator/svm-idl/build-payload.d.ts +11 -0
- package/src/lib/orchestrator/svm-idl/build-payload.js +36 -0
- package/src/lib/orchestrator/svm-idl/ix-encoder.d.ts +3 -0
- package/src/lib/orchestrator/svm-idl/ix-encoder.js +47 -0
- package/src/lib/orchestrator/svm-idl/registry.d.ts +10 -0
- package/src/lib/orchestrator/svm-idl/registry.js +36 -0
- package/src/lib/orchestrator/svm-idl/resolve.d.ts +14 -0
- package/src/lib/orchestrator/svm-idl/resolve.js +85 -0
- package/src/lib/progress-hook/progress-hook.js +40 -0
- package/src/lib/progress-hook/progress-hook.types.d.ts +5 -0
- package/src/lib/progress-hook/progress-hook.types.js +6 -0
- package/src/lib/push-chain/push-chain.js +14 -4
- package/src/lib/universal/account/account.d.ts +13 -0
- package/src/lib/universal/account/account.js +1 -0
- package/src/lib/utils.d.ts +20 -1
- package/src/lib/utils.js +28 -0
|
@@ -6,6 +6,7 @@ exports.fromChainAgnostic = fromChainAgnostic;
|
|
|
6
6
|
exports.convertOriginToExecutor = convertOriginToExecutor;
|
|
7
7
|
exports.convertExecutorToOriginAccount = convertExecutorToOriginAccount;
|
|
8
8
|
exports.convertExecutorToOrigin = convertExecutorToOrigin;
|
|
9
|
+
exports.deriveSvmCeaPda = deriveSvmCeaPda;
|
|
9
10
|
exports.deriveExecutorAccount = deriveExecutorAccount;
|
|
10
11
|
exports.resolveControllerAccount = resolveControllerAccount;
|
|
11
12
|
const tslib_1 = require("tslib");
|
package/src/lib/utils.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { construct, toUniversal as toUniversalSigner, toUniversalFromKeypair } f
|
|
|
3
3
|
import { CHAIN, PUSH_NETWORK } from './constants/enums';
|
|
4
4
|
import { type MoveableToken } from './constants/tokens';
|
|
5
5
|
import type { PushChain } from './push-chain/push-chain';
|
|
6
|
+
import { registerIdl as registerSvmIdl, getRegisteredIdls as getRegisteredSvmIdls, getIdl as getSvmIdl } from './orchestrator/svm-idl/registry';
|
|
6
7
|
/**
|
|
7
8
|
* @dev - THESE UTILS ARE EXPORTED TO SDK CONSUMER
|
|
8
9
|
* @dev - Make sure each exported fn has good comments to help out sdk consumer
|
|
@@ -32,6 +33,24 @@ export declare class Utils {
|
|
|
32
33
|
deriveExecutorAccount: typeof deriveExecutorAccount;
|
|
33
34
|
resolveControllerAccount: typeof resolveControllerAccount;
|
|
34
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* SVM (Solana) utilities for registering program Anchor IDLs.
|
|
38
|
+
*
|
|
39
|
+
* Register your program's Anchor IDL once per process; `prepareTransaction`
|
|
40
|
+
* then resolves accounts, PDAs, and signers from the IDL so you only need
|
|
41
|
+
* to pass `data` (discriminator + Borsh args), the same shape used for EVM.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* PushChain.utils.svm.registerIdl(
|
|
45
|
+
* PROGRAM_ADDRESS_HEX,
|
|
46
|
+
* testCounterIdl
|
|
47
|
+
* );
|
|
48
|
+
*/
|
|
49
|
+
static svm: {
|
|
50
|
+
registerIdl: typeof registerSvmIdl;
|
|
51
|
+
getRegisteredIdls: typeof getRegisteredSvmIdls;
|
|
52
|
+
getIdl: typeof getSvmIdl;
|
|
53
|
+
};
|
|
35
54
|
static signer: {
|
|
36
55
|
/**
|
|
37
56
|
* Converts various signer types (viem, ethers v6, Solana) into a UniversalSigner.
|
|
@@ -98,7 +117,7 @@ export declare class Utils {
|
|
|
98
117
|
*/
|
|
99
118
|
getChainName: (chainName: string) => string | undefined;
|
|
100
119
|
encodeTxData({ abi, functionName, args, }: {
|
|
101
|
-
abi: any
|
|
120
|
+
abi: any;
|
|
102
121
|
functionName: string;
|
|
103
122
|
args?: any[];
|
|
104
123
|
}): `0x${string}`;
|
package/src/lib/utils.js
CHANGED
|
@@ -7,6 +7,9 @@ const enums_1 = require("./constants/enums");
|
|
|
7
7
|
const tokens_1 = require("./constants/tokens");
|
|
8
8
|
const chain_1 = require("./constants/chain");
|
|
9
9
|
const viem_1 = require("viem");
|
|
10
|
+
const buffer_1 = require("buffer");
|
|
11
|
+
const ix_encoder_1 = require("./orchestrator/svm-idl/ix-encoder");
|
|
12
|
+
const registry_1 = require("./orchestrator/svm-idl/registry");
|
|
10
13
|
/**
|
|
11
14
|
* @dev - THESE UTILS ARE EXPORTED TO SDK CONSUMER
|
|
12
15
|
* @dev - Make sure each exported fn has good comments to help out sdk consumer
|
|
@@ -74,6 +77,24 @@ Utils.account = {
|
|
|
74
77
|
deriveExecutorAccount: account_1.deriveExecutorAccount,
|
|
75
78
|
resolveControllerAccount: account_1.resolveControllerAccount,
|
|
76
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* SVM (Solana) utilities for registering program Anchor IDLs.
|
|
82
|
+
*
|
|
83
|
+
* Register your program's Anchor IDL once per process; `prepareTransaction`
|
|
84
|
+
* then resolves accounts, PDAs, and signers from the IDL so you only need
|
|
85
|
+
* to pass `data` (discriminator + Borsh args), the same shape used for EVM.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* PushChain.utils.svm.registerIdl(
|
|
89
|
+
* PROGRAM_ADDRESS_HEX,
|
|
90
|
+
* testCounterIdl
|
|
91
|
+
* );
|
|
92
|
+
*/
|
|
93
|
+
Utils.svm = {
|
|
94
|
+
registerIdl: registry_1.registerIdl,
|
|
95
|
+
getRegisteredIdls: registry_1.getRegisteredIdls,
|
|
96
|
+
getIdl: registry_1.getIdl,
|
|
97
|
+
};
|
|
77
98
|
Utils.signer = {
|
|
78
99
|
/**
|
|
79
100
|
* Converts various signer types (viem, ethers v6, Solana) into a UniversalSigner.
|
|
@@ -207,6 +228,13 @@ Utils.helpers = {
|
|
|
207
228
|
};
|
|
208
229
|
})(),
|
|
209
230
|
encodeTxData({ abi, functionName, args = [], }) {
|
|
231
|
+
if ((0, ix_encoder_1.isAnchorIdl)(abi)) {
|
|
232
|
+
if (!Array.isArray(args)) {
|
|
233
|
+
throw new Error('Arguments must be an array');
|
|
234
|
+
}
|
|
235
|
+
const bytes = (0, ix_encoder_1.encodeAnchorIxData)(abi, functionName, args);
|
|
236
|
+
return `0x${buffer_1.Buffer.from(bytes).toString('hex')}`;
|
|
237
|
+
}
|
|
210
238
|
// Validate inputs
|
|
211
239
|
if (!Array.isArray(abi)) {
|
|
212
240
|
throw new Error('ABI must be an array');
|