@pushchain/core 6.0.25 → 6.0.27-alpha.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/AGW.md +194 -0
- package/CHANGELOG.md +74 -0
- package/README.md +2 -0
- package/package.json +7 -1
- package/src/lib/agentic/agentic.d.ts +23 -0
- package/src/lib/agentic/agentic.js +51 -0
- package/src/lib/agentic/agentic.types.d.ts +409 -0
- package/src/lib/agentic/agentic.types.js +3 -0
- package/src/lib/agentic/capabilities.d.ts +37 -0
- package/src/lib/agentic/capabilities.js +64 -0
- package/src/lib/agentic/chain.d.ts +3 -0
- package/src/lib/agentic/chain.js +15 -0
- package/src/lib/agentic/codec/abi-layout.d.ts +15 -0
- package/src/lib/agentic/codec/abi-layout.js +121 -0
- package/src/lib/agentic/codec/defaults.d.ts +51 -0
- package/src/lib/agentic/codec/defaults.js +53 -0
- package/src/lib/agentic/codec/ids.d.ts +35 -0
- package/src/lib/agentic/codec/ids.js +74 -0
- package/src/lib/agentic/codec/native.d.ts +75 -0
- package/src/lib/agentic/codec/native.js +328 -0
- package/src/lib/agentic/codec/rules.d.ts +45 -0
- package/src/lib/agentic/codec/rules.js +110 -0
- package/src/lib/agentic/codec/selectors.d.ts +19 -0
- package/src/lib/agentic/codec/selectors.js +60 -0
- package/src/lib/agentic/codec/session.d.ts +54 -0
- package/src/lib/agentic/codec/session.js +65 -0
- package/src/lib/agentic/codec/svm-accounts.d.ts +35 -0
- package/src/lib/agentic/codec/svm-accounts.js +68 -0
- package/src/lib/agentic/codec/svm-idl.d.ts +11 -0
- package/src/lib/agentic/codec/svm-idl.js +226 -0
- package/src/lib/agentic/codec/svm-terms.d.ts +157 -0
- package/src/lib/agentic/codec/svm-terms.js +242 -0
- package/src/lib/agentic/codec/universal-terms.d.ts +67 -0
- package/src/lib/agentic/codec/universal-terms.js +41 -0
- package/src/lib/agentic/codec/universal.d.ts +14 -0
- package/src/lib/agentic/codec/universal.js +157 -0
- package/src/lib/agentic/constants.d.ts +11 -0
- package/src/lib/agentic/constants.js +15 -0
- package/src/lib/agentic/context.d.ts +29 -0
- package/src/lib/agentic/context.js +56 -0
- package/src/lib/agentic/contracts/abi/v5/agent-validator.d.ts +105 -0
- package/src/lib/agentic/contracts/abi/v5/agent-validator.js +149 -0
- package/src/lib/agentic/contracts/abi/v5/agw-factory.d.ts +847 -0
- package/src/lib/agentic/contracts/abi/v5/agw-factory.js +1108 -0
- package/src/lib/agentic/contracts/abi/v5/agw.d.ts +1211 -0
- package/src/lib/agentic/contracts/abi/v5/agw.js +1588 -0
- package/src/lib/agentic/contracts/abi/v5/index.d.ts +6 -0
- package/src/lib/agentic/contracts/abi/v5/index.js +17 -0
- package/src/lib/agentic/contracts/abi/v5/smart-session.d.ts +1493 -0
- package/src/lib/agentic/contracts/abi/v5/smart-session.js +1965 -0
- package/src/lib/agentic/contracts/abi/v5/universal-rules-policy.d.ts +1640 -0
- package/src/lib/agentic/contracts/abi/v5/universal-rules-policy.js +2160 -0
- package/src/lib/agentic/contracts/donut-v5.d.ts +11 -0
- package/src/lib/agentic/contracts/donut-v5.js +15 -0
- package/src/lib/agentic/contracts/prc20-metadata.d.ts +26 -0
- package/src/lib/agentic/contracts/prc20-metadata.js +87 -0
- package/src/lib/agentic/contracts/reader.d.ts +35 -0
- package/src/lib/agentic/contracts/reader.js +16 -0
- package/src/lib/agentic/contracts/v5.d.ts +5323 -0
- package/src/lib/agentic/contracts/v5.js +316 -0
- package/src/lib/agentic/deployments.d.ts +61 -0
- package/src/lib/agentic/deployments.js +203 -0
- package/src/lib/agentic/errors.d.ts +71 -0
- package/src/lib/agentic/errors.js +92 -0
- package/src/lib/agentic/execution/guards.d.ts +9 -0
- package/src/lib/agentic/execution/guards.js +30 -0
- package/src/lib/agentic/execution/outbound.d.ts +55 -0
- package/src/lib/agentic/execution/outbound.js +187 -0
- package/src/lib/agentic/execution/send.d.ts +9 -0
- package/src/lib/agentic/execution/send.js +276 -0
- package/src/lib/agentic/execution/svm-instruction.d.ts +24 -0
- package/src/lib/agentic/execution/svm-instruction.js +40 -0
- package/src/lib/agentic/execution/svm-outbound.d.ts +18 -0
- package/src/lib/agentic/execution/svm-outbound.js +86 -0
- package/src/lib/agentic/execution/svm-payload.d.ts +18 -0
- package/src/lib/agentic/execution/svm-payload.js +136 -0
- package/src/lib/agentic/execution/svm-public.d.ts +5 -0
- package/src/lib/agentic/execution/svm-public.js +182 -0
- package/src/lib/agentic/execution/svm-quote.d.ts +11 -0
- package/src/lib/agentic/execution/svm-quote.js +24 -0
- package/src/lib/agentic/execution/svm-send.d.ts +44 -0
- package/src/lib/agentic/execution/svm-send.js +90 -0
- package/src/lib/agentic/index.d.ts +5 -0
- package/src/lib/agentic/index.js +10 -0
- package/src/lib/agentic/management/common.d.ts +29 -0
- package/src/lib/agentic/management/common.js +114 -0
- package/src/lib/agentic/management/create.d.ts +16 -0
- package/src/lib/agentic/management/create.js +271 -0
- package/src/lib/agentic/management/duplicates.d.ts +4 -0
- package/src/lib/agentic/management/duplicates.js +20 -0
- package/src/lib/agentic/management/label.d.ts +3 -0
- package/src/lib/agentic/management/label.js +17 -0
- package/src/lib/agentic/management/prepare.d.ts +7 -0
- package/src/lib/agentic/management/prepare.js +95 -0
- package/src/lib/agentic/management/rules-write.d.ts +42 -0
- package/src/lib/agentic/management/rules-write.js +279 -0
- package/src/lib/agentic/management/svm-context.d.ts +25 -0
- package/src/lib/agentic/management/svm-context.js +55 -0
- package/src/lib/agentic/management/svm-metadata.d.ts +10 -0
- package/src/lib/agentic/management/svm-metadata.js +56 -0
- package/src/lib/agentic/management/svm-public.d.ts +6 -0
- package/src/lib/agentic/management/svm-public.js +125 -0
- package/src/lib/agentic/management/svm.d.ts +27 -0
- package/src/lib/agentic/management/svm.js +150 -0
- package/src/lib/agentic/presets/catalog.d.ts +21 -0
- package/src/lib/agentic/presets/catalog.js +10 -0
- package/src/lib/agentic/presets/index.d.ts +5 -0
- package/src/lib/agentic/presets/index.js +190 -0
- package/src/lib/agentic/presets/types.d.ts +44 -0
- package/src/lib/agentic/presets/types.js +3 -0
- package/src/lib/agentic/public-rule.d.ts +9 -0
- package/src/lib/agentic/public-rule.js +342 -0
- package/src/lib/agentic/reads/checkpoints.d.ts +17 -0
- package/src/lib/agentic/reads/checkpoints.js +109 -0
- package/src/lib/agentic/reads/rules.d.ts +42 -0
- package/src/lib/agentic/reads/rules.js +286 -0
- package/src/lib/agentic/reads/snapshot.d.ts +28 -0
- package/src/lib/agentic/reads/snapshot.js +85 -0
- package/src/lib/agentic/reads/svm.d.ts +17 -0
- package/src/lib/agentic/reads/svm.js +52 -0
- package/src/lib/agentic/reads/wallets.d.ts +25 -0
- package/src/lib/agentic/reads/wallets.js +122 -0
- package/src/lib/agentic/response.d.ts +41 -0
- package/src/lib/agentic/response.js +358 -0
- package/src/lib/agentic/revert.d.ts +7 -0
- package/src/lib/agentic/revert.js +102 -0
- package/src/lib/agentic/runtime.d.ts +58 -0
- package/src/lib/agentic/runtime.js +95 -0
- package/src/lib/agentic/utils.d.ts +57 -0
- package/src/lib/agentic/utils.js +165 -0
- package/src/lib/agentic/wallet.d.ts +32 -0
- package/src/lib/agentic/wallet.js +130 -0
- package/src/lib/constants/chain.js +1 -1
- package/src/lib/constants/enums.d.ts +6 -3
- package/src/lib/constants/enums.js +6 -3
- package/src/lib/constants/index.d.ts +65 -7
- package/src/lib/constants/index.js +18 -3
- package/src/lib/constants/read-state.d.ts +15 -2
- package/src/lib/constants/read-state.js +19 -3
- package/src/lib/index.d.ts +9 -3
- package/src/lib/index.js +11 -2
- package/src/lib/orchestrator/internals/errors.d.ts +7 -0
- package/src/lib/orchestrator/internals/errors.js +13 -1
- package/src/lib/orchestrator/internals/execute-standard.d.ts +3 -1
- package/src/lib/orchestrator/internals/execute-standard.js +3 -3
- package/src/lib/orchestrator/internals/outbound-sync.js +52 -7
- package/src/lib/orchestrator/internals/push-chain-tx.d.ts +1 -1
- package/src/lib/orchestrator/internals/push-chain-tx.js +13 -1
- package/src/lib/orchestrator/orchestrator.d.ts +3 -0
- package/src/lib/orchestrator/orchestrator.js +13 -1
- package/src/lib/orchestrator/orchestrator.types.d.ts +8 -0
- package/src/lib/orchestrator/route-detector.js +3 -2
- package/src/lib/orchestrator/svm-idl/resolve.d.ts +2 -0
- package/src/lib/orchestrator/svm-idl/resolve.js +11 -1
- package/src/lib/progress-hook/progress-hook.js +84 -0
- package/src/lib/progress-hook/progress-hook.types.d.ts +14 -2
- package/src/lib/progress-hook/progress-hook.types.js +13 -0
- package/src/lib/push-chain/push-chain.d.ts +58 -16
- package/src/lib/push-chain/push-chain.js +68 -8
- package/src/lib/push-client/push-client.d.ts +7 -0
- package/src/lib/push-client/push-client.js +41 -15
- package/src/lib/read-state/destination.js +6 -1
- package/src/lib/read-state/envelopes/evm.js +2 -3
- package/src/lib/read-state/envelopes/svm.js +11 -1
- package/src/lib/read-state/read-executor.js +4 -0
- package/src/lib/read-state/read-params.d.ts +71 -26
- package/src/lib/read-state/read-params.js +60 -15
- package/src/lib/read-state/read-state.types.d.ts +44 -1
- package/src/lib/read-state/read-state.types.js +23 -1
- package/src/lib/read-state/read-tracker.d.ts +6 -1
- package/src/lib/read-state/read-tracker.js +83 -17
- package/src/lib/read-state/registry.js +2 -3
- package/src/lib/read-state/result-decoder.js +6 -0
- package/src/lib/read-state/spec-builder.js +2 -2
- package/src/lib/read-state/svm-account.d.ts +20 -0
- package/src/lib/read-state/svm-account.js +114 -0
- package/src/lib/read-state/svm-pda.d.ts +13 -0
- package/src/lib/read-state/svm-pda.js +147 -0
- package/src/lib/universal/prc20-address.d.ts +15 -0
- package/src/lib/universal/prc20-address.js +135 -0
- package/src/lib/utils.d.ts +6 -13
- package/src/lib/utils.js +5 -128
- package/src/lib/vm-client/evm-client.js +34 -20
|
@@ -3,15 +3,19 @@
|
|
|
3
3
|
*
|
|
4
4
|
* read(user, { chain }) native balance (ETH / lamports)
|
|
5
5
|
* read(user, { chain, token }) token balance (ERC-20 / SPL via ATA)
|
|
6
|
-
* read(contract, { chain, abi, functionName, args }) typed call — abi encodes AND decodes
|
|
6
|
+
* read(contract, { chain, abi, functionName, args }) typed call — abi encodes AND decodes (any mutability; eth_call simulation)
|
|
7
|
+
* read(account, { chain, idl, functionName? }) Anchor account, layout picked by discriminator
|
|
8
|
+
* read(program, { chain, idl, functionName, args }) Anchor PDA — args are its IDL-declared seeds
|
|
7
9
|
* read(contract, { chain, storageSlot }) storage word
|
|
8
10
|
* read(url, { chain: CHAIN.WEB2, web2 }) web2
|
|
9
11
|
*
|
|
10
12
|
* Query keys are mutually exclusive; the namespace decides which are legal.
|
|
11
13
|
*/
|
|
12
|
-
import type { Abi, Address, Hex, ContractFunctionReturnType, ContractFunctionName, ContractFunctionArgs, ExtractAbiFunctionForArgs } from 'viem';
|
|
14
|
+
import type { Abi, AbiStateMutability, Address, Hex, ContractFunctionReturnType, ContractFunctionName, ContractFunctionArgs, ExtractAbiFunctionForArgs } from 'viem';
|
|
15
|
+
import type { Idl, IdlAccounts } from '@coral-xyz/anchor';
|
|
16
|
+
import { PublicKey } from '@solana/web3.js';
|
|
13
17
|
import { CHAIN, PUSH_NETWORK } from '../constants/enums';
|
|
14
|
-
import type { BuildReadSpecParams, ReadChain, ReadDestination, ReadLifecycleOptions, ReadQuery, ReadResultShape, Web2Extract } from './read-state.types';
|
|
18
|
+
import type { BuildReadSpecParams, ReadChain, ReadDestination, ReadLifecycleOptions, ReadQuery, ReadResultShape, Web2Extract, Web2ReadChain } from './read-state.types';
|
|
15
19
|
import type { ReadCallback } from './read-state.types';
|
|
16
20
|
import type { ProgressEvent } from '../progress-hook/progress-hook.types';
|
|
17
21
|
export interface ReadWeb2Options {
|
|
@@ -32,11 +36,23 @@ interface ReadOptionsInput {
|
|
|
32
36
|
chain: ReadChain;
|
|
33
37
|
/** Token balance of `subject`: ERC-20 `balanceOf` on EVM, the SPL ATA on SVM. */
|
|
34
38
|
token?: string;
|
|
35
|
-
/**
|
|
36
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Anchor IDL — the Solana counterpart of `abi`. The subject account is decoded
|
|
41
|
+
* with the layout whose discriminator matches its data. Reads never execute an
|
|
42
|
+
* instruction.
|
|
43
|
+
*/
|
|
44
|
+
idl?: Idl;
|
|
37
45
|
/** Typed contract call — encodes the call and decodes the result. */
|
|
38
46
|
abi?: Abi;
|
|
47
|
+
/**
|
|
48
|
+
* With `abi`: the function to call (required). With `idl`: the account layout
|
|
49
|
+
* (optional — inferred from the discriminator; snake_case or camelCase).
|
|
50
|
+
*/
|
|
39
51
|
functionName?: string;
|
|
52
|
+
/**
|
|
53
|
+
* With `abi`: positional call args. With `idl` and the program id as subject:
|
|
54
|
+
* the PDA's non-constant seeds, in IDL order.
|
|
55
|
+
*/
|
|
40
56
|
args?: readonly unknown[];
|
|
41
57
|
/** EVM storage word. */
|
|
42
58
|
storageSlot?: Hex | bigint;
|
|
@@ -60,6 +76,8 @@ interface ReadOptionsInput {
|
|
|
60
76
|
type NoQuery = {
|
|
61
77
|
token?: never;
|
|
62
78
|
tokenProgram?: never;
|
|
79
|
+
idl?: never;
|
|
80
|
+
accountName?: never;
|
|
63
81
|
abi?: never;
|
|
64
82
|
functionName?: never;
|
|
65
83
|
args?: never;
|
|
@@ -79,9 +97,14 @@ export type ReadQueryOptions = ({
|
|
|
79
97
|
token: string;
|
|
80
98
|
}>) | ({
|
|
81
99
|
chain: SvmChain;
|
|
82
|
-
} & Query<'token'
|
|
100
|
+
} & Query<'token', {
|
|
83
101
|
token: string;
|
|
84
|
-
|
|
102
|
+
}>) | ({
|
|
103
|
+
chain: SvmChain;
|
|
104
|
+
} & Query<'idl' | 'functionName' | 'args', {
|
|
105
|
+
idl: Idl;
|
|
106
|
+
functionName?: string;
|
|
107
|
+
args?: readonly unknown[];
|
|
85
108
|
}>) | ({
|
|
86
109
|
chain: EvmChain;
|
|
87
110
|
} & Query<'abi' | 'functionName' | 'args', {
|
|
@@ -93,14 +116,14 @@ export type ReadQueryOptions = ({
|
|
|
93
116
|
} & Query<'storageSlot', {
|
|
94
117
|
storageSlot: Hex | bigint;
|
|
95
118
|
}>) | ({
|
|
96
|
-
chain:
|
|
119
|
+
chain: Web2ReadChain;
|
|
97
120
|
} & Query<'web2', {
|
|
98
121
|
web2: ReadWeb2Options;
|
|
99
122
|
}>);
|
|
100
123
|
export type ReadCallbackOptions = {
|
|
101
124
|
callback?: ({
|
|
102
125
|
target: Address;
|
|
103
|
-
gasLimit
|
|
126
|
+
gasLimit?: bigint;
|
|
104
127
|
} & Pick<ReadCallback, 'abi' | 'functionName' | 'args'>) | {
|
|
105
128
|
target?: never;
|
|
106
129
|
gasLimit?: bigint;
|
|
@@ -123,12 +146,12 @@ type FinalizedDestinationOptions = {
|
|
|
123
146
|
export type ReadPrepareOptions = SharedPrepareOptions & ((Extract<ReadQueryOptions, {
|
|
124
147
|
chain: EvmChain;
|
|
125
148
|
}> & EvmPinningOptions) | (Extract<ReadQueryOptions, {
|
|
126
|
-
chain: SvmChain |
|
|
149
|
+
chain: SvmChain | Web2ReadChain;
|
|
127
150
|
}> & FinalizedDestinationOptions));
|
|
128
151
|
export type ReadExecuteOptions = Pick<ReadOptionsInput, 'advanced' | 'waitForCompletion' | 'progressHook'>;
|
|
129
152
|
type WithExecutionOptions<T> = T extends unknown ? Omit<T, 'advanced' | 'waitForCompletion' | 'progressHook'> & ReadExecuteOptions : never;
|
|
130
153
|
export type ReadOptions = WithExecutionOptions<ReadPrepareOptions> & {
|
|
131
|
-
callback?: (Required<Pick<ReadCallback, 'target' | '
|
|
154
|
+
callback?: (Required<Pick<ReadCallback, 'target' | 'abi' | 'functionName'>> & Pick<ReadCallback, 'gasLimit' | 'args'>) | {
|
|
132
155
|
target?: never;
|
|
133
156
|
gasLimit?: bigint;
|
|
134
157
|
abi?: never;
|
|
@@ -148,11 +171,11 @@ type Web2Values = {
|
|
|
148
171
|
string: string;
|
|
149
172
|
};
|
|
150
173
|
type Web2Value<E extends Web2Extract> = Web2Values[E['valueType']];
|
|
151
|
-
type ReadFunctionName<A extends Abi, F extends string> = F & ContractFunctionName<A,
|
|
174
|
+
type ReadFunctionName<A extends Abi, F extends string> = F & ContractFunctionName<A, AbiStateMutability>;
|
|
152
175
|
type ReadFunctionArgs<O, A extends Abi, F extends string> = O extends {
|
|
153
|
-
args: infer Args extends ContractFunctionArgs<A,
|
|
154
|
-
} ? Args : readonly [] extends ContractFunctionArgs<A,
|
|
155
|
-
type ReadCallValue<A extends Abi, F extends string, Args extends ContractFunctionArgs<A,
|
|
176
|
+
args: infer Args extends ContractFunctionArgs<A, AbiStateMutability, ReadFunctionName<A, F>>;
|
|
177
|
+
} ? Args : readonly [] extends ContractFunctionArgs<A, AbiStateMutability, ReadFunctionName<A, F>> ? readonly [] : ContractFunctionArgs<A, AbiStateMutability, ReadFunctionName<A, F>>;
|
|
178
|
+
type ReadCallValue<A extends Abi, F extends string, Args extends ContractFunctionArgs<A, AbiStateMutability, ReadFunctionName<A, F>>> = ExtractAbiFunctionForArgs<A, AbiStateMutability, ReadFunctionName<A, F>, Args> extends infer Selected ? Selected extends Abi[number] & {
|
|
156
179
|
type: 'function';
|
|
157
180
|
outputs: readonly unknown[];
|
|
158
181
|
} ? ContractFunctionReturnType<readonly [Selected]> : never : never;
|
|
@@ -160,7 +183,7 @@ type ReadCallValue<A extends Abi, F extends string, Args extends ContractFunctio
|
|
|
160
183
|
export type ReadValue<O> = O extends {
|
|
161
184
|
abi: infer A extends Abi;
|
|
162
185
|
functionName: infer F extends string;
|
|
163
|
-
} ? number extends A['length'] ?
|
|
186
|
+
} ? number extends A['length'] ? unknown : ReadCallValue<A, F, ReadFunctionArgs<O, A, F>> : O extends {
|
|
164
187
|
web2: {
|
|
165
188
|
extract: infer E extends readonly Web2Extract[];
|
|
166
189
|
};
|
|
@@ -168,7 +191,19 @@ export type ReadValue<O> = O extends {
|
|
|
168
191
|
readonly [K in keyof E]: Web2Value<E[K]>;
|
|
169
192
|
} : O extends {
|
|
170
193
|
storageSlot: unknown;
|
|
171
|
-
} ? Hex :
|
|
194
|
+
} ? Hex : O extends {
|
|
195
|
+
idl: infer I extends Idl;
|
|
196
|
+
} ? IdlReadValue<I, O extends {
|
|
197
|
+
functionName: infer N extends string;
|
|
198
|
+
} ? N : undefined> : bigint;
|
|
199
|
+
/** snake_case / camelCase / PascalCase spellings compare equal (mirrors `idlNameKey`). */
|
|
200
|
+
type IdlNameKey<S extends string> = Lowercase<S extends `${infer H}_${infer T}` ? `${H}${IdlNameKey<T>}` : S>;
|
|
201
|
+
type IdlAccountName<I extends Idl> = Extract<keyof IdlAccounts<I>, string>;
|
|
202
|
+
type MatchAccount<I extends Idl, N extends string> = {
|
|
203
|
+
[K in IdlAccountName<I>]: IdlNameKey<K> extends IdlNameKey<N> ? K : never;
|
|
204
|
+
}[IdlAccountName<I>];
|
|
205
|
+
/** A literal IDL types the account; a dynamic one (names typed `string`) yields `unknown`. */
|
|
206
|
+
type IdlReadValue<I extends Idl, N extends string | undefined> = string extends IdlAccountName<I> ? unknown : N extends string ? IdlAccounts<I>[MatchAccount<I, N>] : IdlAccounts<I>[IdlAccountName<I>];
|
|
172
207
|
/** Just `balanceOf` — it also types the decoded result as uint256. */
|
|
173
208
|
export declare const ERC20_BALANCE_OF_ABI: readonly [{
|
|
174
209
|
readonly type: "function";
|
|
@@ -185,21 +220,31 @@ export declare const ERC20_BALANCE_OF_ABI: readonly [{
|
|
|
185
220
|
}];
|
|
186
221
|
export declare function toReadDestination(chain: ReadChain): ReadDestination;
|
|
187
222
|
/** Build the internal query from the public grammar. Pure. */
|
|
188
|
-
export declare function toReadQuery(subject: string, o: ReadOptionsInput): ReadQuery;
|
|
223
|
+
export declare function toReadQuery(subject: string, o: ReadOptionsInput, resolvedTokenProgram?: PublicKey): ReadQuery;
|
|
189
224
|
/** Public options → the spec builder's params. Pure; throws `InvalidReadQueryError` on a malformed request. */
|
|
190
|
-
export declare function toBuildReadSpecParams(subject: string, o: ReadOptionsInput, network?: PUSH_NETWORK): BuildReadSpecParams;
|
|
191
|
-
/**
|
|
225
|
+
export declare function toBuildReadSpecParams(subject: string, o: ReadOptionsInput, network?: PUSH_NETWORK, resolvedTokenProgram?: PublicKey): BuildReadSpecParams;
|
|
226
|
+
/** Resolve Solana mint ownership before the otherwise-pure options conversion. */
|
|
227
|
+
export declare function resolveReadSpecParams(subject: string, o: ReadOptionsInput, network: PUSH_NETWORK, rpcUrls: Partial<Record<CHAIN, string[]>>): Promise<BuildReadSpecParams>;
|
|
228
|
+
/** Internal offline key helper. Solana token callers must use PreparedRead.queryKey after mint resolution. */
|
|
192
229
|
export declare function getReadQueryKey<const O extends ReadQueryOptions>(subject: string, options: O & ValidateReadCall<O>): Hex;
|
|
193
230
|
export declare function toLifecycleOptions(o?: ReadTrackOptions): ReadLifecycleOptions;
|
|
194
|
-
/**
|
|
231
|
+
/**
|
|
232
|
+
* Restrict known ABIs to declared functions and their argument tuple. Every mutability
|
|
233
|
+
* is allowed: the read is an eth_call simulation, so state-changing functions only return data.
|
|
234
|
+
*/
|
|
195
235
|
export type ValidateReadCall<O> = O extends {
|
|
196
236
|
abi: infer A extends Abi;
|
|
197
237
|
functionName: infer F extends string;
|
|
198
238
|
} ? {
|
|
199
|
-
functionName: ContractFunctionName<A,
|
|
200
|
-
} & (readonly [] extends ContractFunctionArgs<A,
|
|
201
|
-
args?: ContractFunctionArgs<A,
|
|
239
|
+
functionName: ContractFunctionName<A, AbiStateMutability>;
|
|
240
|
+
} & (readonly [] extends ContractFunctionArgs<A, AbiStateMutability, F & ContractFunctionName<A, AbiStateMutability>> ? {
|
|
241
|
+
args?: ContractFunctionArgs<A, AbiStateMutability, F & ContractFunctionName<A, AbiStateMutability>>;
|
|
202
242
|
} : {
|
|
203
|
-
args: ContractFunctionArgs<A,
|
|
204
|
-
}) :
|
|
243
|
+
args: ContractFunctionArgs<A, AbiStateMutability, F & ContractFunctionName<A, AbiStateMutability>>;
|
|
244
|
+
}) : O extends {
|
|
245
|
+
idl: infer I extends Idl;
|
|
246
|
+
functionName: infer N extends string;
|
|
247
|
+
} ? string extends IdlAccountName<I> ? unknown : [MatchAccount<I, N>] extends [never] ? {
|
|
248
|
+
functionName: IdlAccountName<I>;
|
|
249
|
+
} : unknown : unknown;
|
|
205
250
|
export {};
|
|
@@ -4,9 +4,13 @@ exports.ERC20_BALANCE_OF_ABI = void 0;
|
|
|
4
4
|
exports.toReadDestination = toReadDestination;
|
|
5
5
|
exports.toReadQuery = toReadQuery;
|
|
6
6
|
exports.toBuildReadSpecParams = toBuildReadSpecParams;
|
|
7
|
+
exports.resolveReadSpecParams = resolveReadSpecParams;
|
|
7
8
|
exports.getReadQueryKey = getReadQueryKey;
|
|
8
9
|
exports.toLifecycleOptions = toLifecycleOptions;
|
|
9
10
|
const viem_1 = require("viem");
|
|
11
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
12
|
+
const svm_account_1 = require("./svm-account");
|
|
13
|
+
const svm_pda_1 = require("./svm-pda");
|
|
10
14
|
const enums_1 = require("../constants/enums");
|
|
11
15
|
const registry_1 = require("./registry");
|
|
12
16
|
const read_state_1 = require("../constants/read-state");
|
|
@@ -23,27 +27,29 @@ exports.ERC20_BALANCE_OF_ABI = [
|
|
|
23
27
|
outputs: [{ name: '', type: 'uint256' }],
|
|
24
28
|
},
|
|
25
29
|
];
|
|
26
|
-
const QUERY_KEYS = ['token', 'abi', 'storageSlot', 'web2'];
|
|
30
|
+
const QUERY_KEYS = ['token', 'abi', 'idl', 'storageSlot', 'web2'];
|
|
27
31
|
function queryKind(o) {
|
|
32
|
+
if ('tokenProgram' in o)
|
|
33
|
+
throw new errors_1.InvalidReadQueryError('tokenProgram is detected from the mint; remove options.tokenProgram');
|
|
34
|
+
if ('accountName' in o)
|
|
35
|
+
throw new errors_1.InvalidReadQueryError('accountName was removed; pass the account layout as functionName (optional — inferred from the discriminator)');
|
|
28
36
|
const present = QUERY_KEYS.filter((k) => o[k] !== undefined);
|
|
29
37
|
if (present.length > 1) {
|
|
30
38
|
throw new errors_1.InvalidReadQueryError(`query keys are mutually exclusive, got ${present.join(' + ')}`);
|
|
31
39
|
}
|
|
32
|
-
if ((o.functionName !== undefined || o.args !== undefined) && o.abi === undefined) {
|
|
33
|
-
throw new errors_1.InvalidReadQueryError('functionName and args need abi');
|
|
40
|
+
if ((o.functionName !== undefined || o.args !== undefined) && o.abi === undefined && o.idl === undefined) {
|
|
41
|
+
throw new errors_1.InvalidReadQueryError('functionName and args need abi or idl');
|
|
34
42
|
}
|
|
35
43
|
return present[0] ?? 'native';
|
|
36
44
|
}
|
|
37
45
|
function toReadDestination(chain) {
|
|
38
|
-
|
|
46
|
+
// Both public spellings normalize to the unchanged wire identity web2:https.
|
|
47
|
+
return (0, read_state_1.isWeb2ReadChain)(chain) ? read_state_1.WEB2_DESTINATION : { chain };
|
|
39
48
|
}
|
|
40
49
|
/** Build the internal query from the public grammar. Pure. */
|
|
41
|
-
function toReadQuery(subject, o) {
|
|
50
|
+
function toReadQuery(subject, o, resolvedTokenProgram) {
|
|
42
51
|
const dest = (0, destination_1.resolveDestination)(toReadDestination(o.chain));
|
|
43
52
|
const kind = queryKind(o);
|
|
44
|
-
if (o.tokenProgram !== undefined && (dest.namespace !== read_state_1.READ_NAMESPACE.SVM || kind !== 'token' || !['spl-token', 'token-2022'].includes(o.tokenProgram))) {
|
|
45
|
-
throw new errors_1.InvalidReadQueryError('tokenProgram requires a Solana token balance query and must be spl-token or token-2022');
|
|
46
|
-
}
|
|
47
53
|
if (dest.namespace === read_state_1.READ_NAMESPACE.WEB2) {
|
|
48
54
|
if (kind !== 'web2' || !o.web2)
|
|
49
55
|
throw new errors_1.InvalidReadQueryError('a web2 read needs the `web2` option and no other query key');
|
|
@@ -52,7 +58,7 @@ function toReadQuery(subject, o) {
|
|
|
52
58
|
return { type: 'http', url: subject, ...o.web2 };
|
|
53
59
|
}
|
|
54
60
|
if (kind === 'web2')
|
|
55
|
-
throw new errors_1.InvalidReadQueryError('`web2` is only valid with chain CHAIN.WEB2');
|
|
61
|
+
throw new errors_1.InvalidReadQueryError('`web2` is only valid with chain READ.CHAIN.WEB2');
|
|
56
62
|
if (dest.namespace === read_state_1.READ_NAMESPACE.EVM) {
|
|
57
63
|
if (!(0, viem_1.isAddress)(subject))
|
|
58
64
|
throw new errors_1.InvalidReadQueryError(`EVM subject must be an address, got ${subject}`);
|
|
@@ -75,24 +81,52 @@ function toReadQuery(subject, o) {
|
|
|
75
81
|
throw new errors_1.InvalidReadQueryError(`unsupported query for eip155: ${kind}`);
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
|
-
// SVM:
|
|
84
|
+
// SVM: token-program ownership has already been resolved by the async public path.
|
|
79
85
|
switch (kind) {
|
|
80
86
|
case 'native':
|
|
81
87
|
return { type: 'lamportBalance', account: subject };
|
|
82
88
|
case 'token':
|
|
83
|
-
|
|
89
|
+
if (!resolvedTokenProgram)
|
|
90
|
+
throw new errors_1.InvalidReadQueryError('Solana token reads need mint-owner resolution; use universal.prepareRead or universal.read');
|
|
91
|
+
return { type: 'splTokenAccount', account: (0, svm_1.deriveAssociatedTokenAddress)(subject, o.token, resolvedTokenProgram).toBase58() };
|
|
92
|
+
case 'idl':
|
|
93
|
+
return toIdlAccountQuery(subject, o);
|
|
84
94
|
default:
|
|
85
|
-
throw new errors_1.InvalidReadQueryError(`unsupported query for solana: ${kind}
|
|
95
|
+
throw new errors_1.InvalidReadQueryError(`unsupported query for solana: ${kind}; use idl for account-state decoding`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* `idl` → a raw account read that decodes with the IDL. The subject is the account,
|
|
100
|
+
* or the program id when `args` are the seeds of the `functionName` PDA.
|
|
101
|
+
*/
|
|
102
|
+
function toIdlAccountQuery(subject, o) {
|
|
103
|
+
const idl = o.idl;
|
|
104
|
+
(0, svm_account_1.validateIdl)(idl);
|
|
105
|
+
const accountName = o.functionName === undefined ? undefined : (0, svm_account_1.resolveAccountName)(idl, o.functionName);
|
|
106
|
+
if ((0, svm_pda_1.isProgramSubject)(idl, subject)) {
|
|
107
|
+
if (!o.functionName)
|
|
108
|
+
throw new errors_1.InvalidReadQueryError('the subject is the program id: pass functionName (the account layout) and args (its PDA seeds) to derive the account');
|
|
109
|
+
const pda = (0, svm_pda_1.deriveIdlPda)(idl, o.functionName, o.args ?? []);
|
|
110
|
+
return { type: 'rawAccountData', account: pda.toBase58(), idl, accountName };
|
|
111
|
+
}
|
|
112
|
+
if (o.args !== undefined)
|
|
113
|
+
throw new errors_1.InvalidReadQueryError('with idl, args are PDA seeds and need the program id as the subject');
|
|
114
|
+
try {
|
|
115
|
+
new web3_js_1.PublicKey(subject);
|
|
86
116
|
}
|
|
117
|
+
catch {
|
|
118
|
+
throw new errors_1.InvalidReadQueryError(`Solana subject must be a base58 pubkey, got ${subject}`);
|
|
119
|
+
}
|
|
120
|
+
return { type: 'rawAccountData', account: subject, idl, accountName };
|
|
87
121
|
}
|
|
88
122
|
/** Public options → the spec builder's params. Pure; throws `InvalidReadQueryError` on a malformed request. */
|
|
89
|
-
function toBuildReadSpecParams(subject, o, network = enums_1.PUSH_NETWORK.TESTNET_DONUT) {
|
|
123
|
+
function toBuildReadSpecParams(subject, o, network = enums_1.PUSH_NETWORK.TESTNET_DONUT, resolvedTokenProgram) {
|
|
90
124
|
const destination = toReadDestination(o.chain);
|
|
91
125
|
const namespace = (0, destination_1.resolveDestination)(destination).namespace;
|
|
92
126
|
if (namespace !== read_state_1.READ_NAMESPACE.EVM && (o.blockNumber !== undefined || o.minConfirmations !== undefined)) {
|
|
93
127
|
throw new errors_1.InvalidReadQueryError(`${namespace} reads do not expose blockNumber or minConfirmations; the SDK selects the read reference internally`);
|
|
94
128
|
}
|
|
95
|
-
const query = toReadQuery(subject, o);
|
|
129
|
+
const query = toReadQuery(subject, o, resolvedTokenProgram);
|
|
96
130
|
const callback = (0, registry_1.resolveReadCallback)(o.callback, network, (0, registry_1.computeReadQueryKey)(destination, query));
|
|
97
131
|
return {
|
|
98
132
|
callback,
|
|
@@ -106,7 +140,18 @@ function toBuildReadSpecParams(subject, o, network = enums_1.PUSH_NETWORK.TESTNE
|
|
|
106
140
|
maxFee: o.maxFee,
|
|
107
141
|
};
|
|
108
142
|
}
|
|
109
|
-
/**
|
|
143
|
+
/** Resolve Solana mint ownership before the otherwise-pure options conversion. */
|
|
144
|
+
async function resolveReadSpecParams(subject, o, network, rpcUrls) {
|
|
145
|
+
const kind = queryKind(o);
|
|
146
|
+
const namespace = (0, destination_1.resolveDestination)(toReadDestination(o.chain)).namespace;
|
|
147
|
+
if (namespace === read_state_1.READ_NAMESPACE.SVM && kind === 'token') {
|
|
148
|
+
new web3_js_1.PublicKey(subject);
|
|
149
|
+
const program = await (0, svm_account_1.detectTokenProgram)(o.token, o.chain, rpcUrls[o.chain]);
|
|
150
|
+
return toBuildReadSpecParams(subject, o, network, program);
|
|
151
|
+
}
|
|
152
|
+
return toBuildReadSpecParams(subject, o, network);
|
|
153
|
+
}
|
|
154
|
+
/** Internal offline key helper. Solana token callers must use PreparedRead.queryKey after mint resolution. */
|
|
110
155
|
function getReadQueryKey(subject, options) {
|
|
111
156
|
return (0, registry_1.computeReadQueryKey)(toReadDestination(options.chain), toReadQuery(subject, options));
|
|
112
157
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Abi, Address, Hex } from 'viem';
|
|
2
|
+
import type { Idl } from '@coral-xyz/anchor';
|
|
2
3
|
import type { CHAIN } from '../constants/enums';
|
|
3
4
|
import type { ReadNamespace } from '../constants/read-state';
|
|
4
5
|
/**
|
|
5
6
|
* Where a read goes. `CHAIN` enum values are CAIP-2 and split cleanly; the
|
|
6
7
|
* explicit form is the low-level escape hatch; the public API uses `CHAIN.WEB2`.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
/** Web2 read source: `READ.CHAIN.WEB2` (`'web2'`) or the legacy `'web2:https'` literal. */
|
|
10
|
+
export type Web2ReadChain = 'web2' | 'web2:https';
|
|
11
|
+
export type ReadChain = CHAIN | Web2ReadChain;
|
|
9
12
|
export type ReadDestination = {
|
|
10
13
|
chain: ReadChain;
|
|
11
14
|
} | {
|
|
@@ -48,6 +51,8 @@ export type SvmReadQuery = {
|
|
|
48
51
|
} | {
|
|
49
52
|
type: 'rawAccountData';
|
|
50
53
|
account: string | Uint8Array;
|
|
54
|
+
idl?: Idl; /** Omitted → layout inferred from the discriminator. */
|
|
55
|
+
accountName?: string;
|
|
51
56
|
};
|
|
52
57
|
export type Web2ValueType = 'uint256' | 'int256' | 'bool' | 'string' | 'bytes';
|
|
53
58
|
export interface Web2Extract {
|
|
@@ -71,6 +76,10 @@ export interface Web2ReadQuery {
|
|
|
71
76
|
}
|
|
72
77
|
export type ReadQuery = EvmReadQuery | SvmReadQuery | Web2ReadQuery;
|
|
73
78
|
export type ReadResultShape = {
|
|
79
|
+
kind: 'svmAccount';
|
|
80
|
+
idl: Idl; /** Omitted → layout inferred from the discriminator. */
|
|
81
|
+
accountName?: string;
|
|
82
|
+
} | {
|
|
74
83
|
kind: 'uint256';
|
|
75
84
|
} | {
|
|
76
85
|
kind: 'bytes32';
|
|
@@ -98,6 +107,10 @@ export interface EncodedReadQuery {
|
|
|
98
107
|
warnings: string[];
|
|
99
108
|
}
|
|
100
109
|
export type DecodedReadResult = {
|
|
110
|
+
kind: 'svmAccount';
|
|
111
|
+
value: unknown; /** The IDL layout the data decoded as. */
|
|
112
|
+
accountName: string;
|
|
113
|
+
} | {
|
|
101
114
|
kind: 'uint256';
|
|
102
115
|
value: bigint;
|
|
103
116
|
} | {
|
|
@@ -314,11 +327,20 @@ export interface ReadFees {
|
|
|
314
327
|
}
|
|
315
328
|
export interface UniversalReadResponse<T = unknown> {
|
|
316
329
|
requestId: Hex;
|
|
330
|
+
/** `requestId` as the `uint256` contracts key results by (e.g. registry `resultByRequestId`). */
|
|
331
|
+
requestIdUint: bigint;
|
|
317
332
|
/** Push tx that carried the request */
|
|
318
333
|
txHash: Hex;
|
|
319
334
|
destination: ResolvedDestination;
|
|
320
335
|
/** Required read destination, including `CHAIN.WEB2`. */
|
|
321
336
|
chain: ReadChain;
|
|
337
|
+
/**
|
|
338
|
+
* The one field that answers "did it work": `SUCCESS` means the source read
|
|
339
|
+
* succeeded, your callback ran, and `value` is set (when a shape is known).
|
|
340
|
+
* Derived by the SDK from `status`, `raw.status`, `callbackDelivered` and
|
|
341
|
+
* `decodeError`, which stay available for debugging.
|
|
342
|
+
*/
|
|
343
|
+
outcome: READ_OUTCOME;
|
|
322
344
|
status: UNIVERSAL_READ_STATUS;
|
|
323
345
|
isTerminal: boolean;
|
|
324
346
|
/**
|
|
@@ -405,6 +427,27 @@ export declare enum READ_ERROR_CODE {
|
|
|
405
427
|
INVALID_RESULT = 5,
|
|
406
428
|
REJECTED = 6
|
|
407
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* SDK-derived single outcome. FULFILLED on the node only means the fulfil tx
|
|
432
|
+
* landed; this separates the ways a FULFILLED read can still not have worked.
|
|
433
|
+
*/
|
|
434
|
+
export declare enum READ_OUTCOME {
|
|
435
|
+
/** Not terminal yet. */
|
|
436
|
+
PENDING = "PENDING",
|
|
437
|
+
/** Source SUCCESS, callback delivered, result decoded (or no shape to decode with). */
|
|
438
|
+
SUCCESS = "SUCCESS",
|
|
439
|
+
/** FULFILLED, but the destination returned an error (`raw.errorCode`). */
|
|
440
|
+
SOURCE_ERROR = "SOURCE_ERROR",
|
|
441
|
+
/** FULFILLED, but the receiver callback reverted or ran out of gas (`callbackFailReason`). */
|
|
442
|
+
CALLBACK_FAILED = "CALLBACK_FAILED",
|
|
443
|
+
/** Delivered, but `resultData` did not match the expected shape (`decodeError`). */
|
|
444
|
+
DECODE_FAILED = "DECODE_FAILED",
|
|
445
|
+
EXPIRED = "EXPIRED",
|
|
446
|
+
FAILED = "FAILED",
|
|
447
|
+
ABORTED = "ABORTED",
|
|
448
|
+
/** FULFILLED, but the fulfil receipt was unavailable, so delivery cannot be confirmed. */
|
|
449
|
+
UNKNOWN = "UNKNOWN"
|
|
450
|
+
}
|
|
408
451
|
/** On-chain lifecycle (`RequestStatus` in ReadTypes.sol). */
|
|
409
452
|
export declare enum CONTRACT_REQUEST_STATUS {
|
|
410
453
|
NONE = 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TERMINAL_READ_STATUSES = exports.CONTRACT_REQUEST_STATUS = exports.READ_ERROR_CODE = exports.READ_STATUS = exports.UNIVERSAL_READ_STATUS = void 0;
|
|
3
|
+
exports.TERMINAL_READ_STATUSES = exports.CONTRACT_REQUEST_STATUS = exports.READ_OUTCOME = exports.READ_ERROR_CODE = exports.READ_STATUS = exports.UNIVERSAL_READ_STATUS = void 0;
|
|
4
4
|
// ---------------------------------------------------------------------------
|
|
5
5
|
// Status enums (mirror ucallback.v1 protos; re-exported for the public surface)
|
|
6
6
|
// ---------------------------------------------------------------------------
|
|
@@ -32,6 +32,28 @@ var READ_ERROR_CODE;
|
|
|
32
32
|
READ_ERROR_CODE[READ_ERROR_CODE["INVALID_RESULT"] = 5] = "INVALID_RESULT";
|
|
33
33
|
READ_ERROR_CODE[READ_ERROR_CODE["REJECTED"] = 6] = "REJECTED";
|
|
34
34
|
})(READ_ERROR_CODE || (exports.READ_ERROR_CODE = READ_ERROR_CODE = {}));
|
|
35
|
+
/**
|
|
36
|
+
* SDK-derived single outcome. FULFILLED on the node only means the fulfil tx
|
|
37
|
+
* landed; this separates the ways a FULFILLED read can still not have worked.
|
|
38
|
+
*/
|
|
39
|
+
var READ_OUTCOME;
|
|
40
|
+
(function (READ_OUTCOME) {
|
|
41
|
+
/** Not terminal yet. */
|
|
42
|
+
READ_OUTCOME["PENDING"] = "PENDING";
|
|
43
|
+
/** Source SUCCESS, callback delivered, result decoded (or no shape to decode with). */
|
|
44
|
+
READ_OUTCOME["SUCCESS"] = "SUCCESS";
|
|
45
|
+
/** FULFILLED, but the destination returned an error (`raw.errorCode`). */
|
|
46
|
+
READ_OUTCOME["SOURCE_ERROR"] = "SOURCE_ERROR";
|
|
47
|
+
/** FULFILLED, but the receiver callback reverted or ran out of gas (`callbackFailReason`). */
|
|
48
|
+
READ_OUTCOME["CALLBACK_FAILED"] = "CALLBACK_FAILED";
|
|
49
|
+
/** Delivered, but `resultData` did not match the expected shape (`decodeError`). */
|
|
50
|
+
READ_OUTCOME["DECODE_FAILED"] = "DECODE_FAILED";
|
|
51
|
+
READ_OUTCOME["EXPIRED"] = "EXPIRED";
|
|
52
|
+
READ_OUTCOME["FAILED"] = "FAILED";
|
|
53
|
+
READ_OUTCOME["ABORTED"] = "ABORTED";
|
|
54
|
+
/** FULFILLED, but the fulfil receipt was unavailable, so delivery cannot be confirmed. */
|
|
55
|
+
READ_OUTCOME["UNKNOWN"] = "UNKNOWN";
|
|
56
|
+
})(READ_OUTCOME || (exports.READ_OUTCOME = READ_OUTCOME = {}));
|
|
35
57
|
/** On-chain lifecycle (`RequestStatus` in ReadTypes.sol). */
|
|
36
58
|
var CONTRACT_REQUEST_STATUS;
|
|
37
59
|
(function (CONTRACT_REQUEST_STATUS) {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { type Hex } from 'viem';
|
|
19
19
|
import { PUSH_NETWORK } from '../constants/enums';
|
|
20
20
|
import type { PushClient } from '../push-client/push-client';
|
|
21
|
-
import { type ReadLifecycleOptions, type ReadResultShape, type UniversalReadResponse } from './read-state.types';
|
|
21
|
+
import { READ_OUTCOME, READ_STATUS, UNIVERSAL_READ_STATUS, type ReadLifecycleOptions, type ReadResultShape, type UniversalReadResponse } from './read-state.types';
|
|
22
22
|
export type ReadHookEmitter = (hookId: string, ...args: unknown[]) => void;
|
|
23
23
|
export interface TrackReadDeps {
|
|
24
24
|
pushClient: Pick<PushClient, 'getUniversalRead' | 'getReadsByTx' | 'getTransactionReceiptWithArchiveFallback' | 'getBlockResultEvents'> & {
|
|
@@ -38,6 +38,11 @@ export declare function trackRead(deps: TrackReadDeps, ref: {
|
|
|
38
38
|
}, opts?: ReadLifecycleOptions): Promise<UniversalReadResponse>;
|
|
39
39
|
/** Normalise a bigint / hex requestId to the node's lowercase 32-byte key. */
|
|
40
40
|
export declare function toRequestIdHex(id: Hex | bigint): Hex;
|
|
41
|
+
/**
|
|
42
|
+
* One answer to "did it work". Order matters: a source error is delivered to the
|
|
43
|
+
* callback as an ERROR result, so it is reported before any callback outcome.
|
|
44
|
+
*/
|
|
45
|
+
export declare function deriveReadOutcome(status: UNIVERSAL_READ_STATUS, rawStatus: READ_STATUS | undefined, callbackDelivered: boolean | undefined, decodeError: string | undefined): READ_OUTCOME;
|
|
41
46
|
/** Best-effort shape from the on-chain envelope. Contract calls carry no ABI → raw. */
|
|
42
47
|
export declare function inferResultShape(namespace: string, query: Hex): ReadResultShape;
|
|
43
48
|
export declare function statusName(status: number): string;
|