boing-sdk 0.3.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/CHANGELOG.md +26 -0
- package/README.md +191 -0
- package/dist/accessList.d.ts +22 -0
- package/dist/accessList.d.ts.map +1 -0
- package/dist/accessList.js +45 -0
- package/dist/bincode.d.ts +92 -0
- package/dist/bincode.d.ts.map +1 -0
- package/dist/bincode.js +154 -0
- package/dist/callAbi.d.ts +119 -0
- package/dist/callAbi.d.ts.map +1 -0
- package/dist/callAbi.js +156 -0
- package/dist/calldata.d.ts +35 -0
- package/dist/calldata.d.ts.map +1 -0
- package/dist/calldata.js +93 -0
- package/dist/canonicalDeployArtifacts.d.ts +154 -0
- package/dist/canonicalDeployArtifacts.d.ts.map +1 -0
- package/dist/canonicalDeployArtifacts.js +271 -0
- package/dist/canonicalTestnet.d.ts +15 -0
- package/dist/canonicalTestnet.d.ts.map +1 -0
- package/dist/canonicalTestnet.js +15 -0
- package/dist/canonicalTestnetDex.d.ts +17 -0
- package/dist/canonicalTestnetDex.d.ts.map +1 -0
- package/dist/canonicalTestnetDex.js +17 -0
- package/dist/chainIds.d.ts +18 -0
- package/dist/chainIds.d.ts.map +1 -0
- package/dist/chainIds.js +56 -0
- package/dist/client.d.ts +223 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +659 -0
- package/dist/connectionMonitor.d.ts +47 -0
- package/dist/connectionMonitor.d.ts.map +1 -0
- package/dist/connectionMonitor.js +93 -0
- package/dist/create2.d.ts +94 -0
- package/dist/create2.d.ts.map +1 -0
- package/dist/create2.js +225 -0
- package/dist/dappDeploy.d.ts +100 -0
- package/dist/dappDeploy.d.ts.map +1 -0
- package/dist/dappDeploy.js +140 -0
- package/dist/dappUiHelpers.d.ts +28 -0
- package/dist/dappUiHelpers.d.ts.map +1 -0
- package/dist/dappUiHelpers.js +69 -0
- package/dist/defaultReferenceFungibleSecuredRuntimeBytecodeHex.d.ts +6 -0
- package/dist/defaultReferenceFungibleSecuredRuntimeBytecodeHex.d.ts.map +1 -0
- package/dist/defaultReferenceFungibleSecuredRuntimeBytecodeHex.js +5 -0
- package/dist/defaultReferenceFungibleSecuredTemplateBytecodeHex.d.ts +6 -0
- package/dist/defaultReferenceFungibleSecuredTemplateBytecodeHex.d.ts.map +1 -0
- package/dist/defaultReferenceFungibleSecuredTemplateBytecodeHex.js +5 -0
- package/dist/defaultReferenceFungibleTemplateBytecodeHex.d.ts +6 -0
- package/dist/defaultReferenceFungibleTemplateBytecodeHex.d.ts.map +1 -0
- package/dist/defaultReferenceFungibleTemplateBytecodeHex.js +5 -0
- package/dist/defaultReferenceNftCollectionTemplateBytecodeHex.d.ts +7 -0
- package/dist/defaultReferenceNftCollectionTemplateBytecodeHex.d.ts.map +1 -0
- package/dist/defaultReferenceNftCollectionTemplateBytecodeHex.js +6 -0
- package/dist/dexIntegration.d.ts +61 -0
- package/dist/dexIntegration.d.ts.map +1 -0
- package/dist/dexIntegration.js +193 -0
- package/dist/erc721Logs.d.ts +21 -0
- package/dist/erc721Logs.d.ts.map +1 -0
- package/dist/erc721Logs.js +69 -0
- package/dist/errors.d.ts +60 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +153 -0
- package/dist/hex.d.ts +27 -0
- package/dist/hex.d.ts.map +1 -0
- package/dist/hex.js +82 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/indexerBatch.d.ts +111 -0
- package/dist/indexerBatch.d.ts.map +1 -0
- package/dist/indexerBatch.js +253 -0
- package/dist/indexerGaps.d.ts +50 -0
- package/dist/indexerGaps.d.ts.map +1 -0
- package/dist/indexerGaps.js +117 -0
- package/dist/indexerSync.d.ts +61 -0
- package/dist/indexerSync.d.ts.map +1 -0
- package/dist/indexerSync.js +100 -0
- package/dist/nativeAmm.d.ts +64 -0
- package/dist/nativeAmm.d.ts.map +1 -0
- package/dist/nativeAmm.js +174 -0
- package/dist/nativeAmmLogs.d.ts +48 -0
- package/dist/nativeAmmLogs.d.ts.map +1 -0
- package/dist/nativeAmmLogs.js +114 -0
- package/dist/nativeAmmLpVault.d.ts +94 -0
- package/dist/nativeAmmLpVault.d.ts.map +1 -0
- package/dist/nativeAmmLpVault.js +205 -0
- package/dist/nativeAmmPool.d.ts +124 -0
- package/dist/nativeAmmPool.d.ts.map +1 -0
- package/dist/nativeAmmPool.js +245 -0
- package/dist/nativeContractSubmit.d.ts +26 -0
- package/dist/nativeContractSubmit.d.ts.map +1 -0
- package/dist/nativeContractSubmit.js +23 -0
- package/dist/nativeDexDirectory.d.ts +83 -0
- package/dist/nativeDexDirectory.d.ts.map +1 -0
- package/dist/nativeDexDirectory.js +147 -0
- package/dist/nativeDexDirectoryApi.d.ts +121 -0
- package/dist/nativeDexDirectoryApi.d.ts.map +1 -0
- package/dist/nativeDexDirectoryApi.js +408 -0
- package/dist/nativeDexFactory.d.ts +25 -0
- package/dist/nativeDexFactory.d.ts.map +1 -0
- package/dist/nativeDexFactory.js +72 -0
- package/dist/nativeDexFactoryLogs.d.ts +19 -0
- package/dist/nativeDexFactoryLogs.d.ts.map +1 -0
- package/dist/nativeDexFactoryLogs.js +61 -0
- package/dist/nativeDexFactoryPool.d.ts +61 -0
- package/dist/nativeDexFactoryPool.d.ts.map +1 -0
- package/dist/nativeDexFactoryPool.js +120 -0
- package/dist/nativeDexIndexerStats.d.ts +96 -0
- package/dist/nativeDexIndexerStats.d.ts.map +1 -0
- package/dist/nativeDexIndexerStats.js +448 -0
- package/dist/nativeDexLedgerRouter.d.ts +67 -0
- package/dist/nativeDexLedgerRouter.d.ts.map +1 -0
- package/dist/nativeDexLedgerRouter.js +108 -0
- package/dist/nativeDexLpPositions.d.ts +39 -0
- package/dist/nativeDexLpPositions.d.ts.map +1 -0
- package/dist/nativeDexLpPositions.js +69 -0
- package/dist/nativeDexNftIndexer.d.ts +26 -0
- package/dist/nativeDexNftIndexer.d.ts.map +1 -0
- package/dist/nativeDexNftIndexer.js +50 -0
- package/dist/nativeDexPoolHistory.d.ts +40 -0
- package/dist/nativeDexPoolHistory.d.ts.map +1 -0
- package/dist/nativeDexPoolHistory.js +110 -0
- package/dist/nativeDexReceiptArchive.d.ts +25 -0
- package/dist/nativeDexReceiptArchive.d.ts.map +1 -0
- package/dist/nativeDexReceiptArchive.js +47 -0
- package/dist/nativeDexRouting.d.ts +160 -0
- package/dist/nativeDexRouting.d.ts.map +1 -0
- package/dist/nativeDexRouting.js +345 -0
- package/dist/nativeDexSeamless.d.ts +86 -0
- package/dist/nativeDexSeamless.d.ts.map +1 -0
- package/dist/nativeDexSeamless.js +131 -0
- package/dist/nativeDexSwap2Router.d.ts +45 -0
- package/dist/nativeDexSwap2Router.d.ts.map +1 -0
- package/dist/nativeDexSwap2Router.js +276 -0
- package/dist/nativeLpShareToken.d.ts +54 -0
- package/dist/nativeLpShareToken.d.ts.map +1 -0
- package/dist/nativeLpShareToken.js +135 -0
- package/dist/nativeTokenSecurity.d.ts +59 -0
- package/dist/nativeTokenSecurity.d.ts.map +1 -0
- package/dist/nativeTokenSecurity.js +59 -0
- package/dist/networkProfile.d.ts +8 -0
- package/dist/networkProfile.d.ts.map +1 -0
- package/dist/networkProfile.js +29 -0
- package/dist/newHeadsWs.d.ts +43 -0
- package/dist/newHeadsWs.d.ts.map +1 -0
- package/dist/newHeadsWs.js +139 -0
- package/dist/preflightGate.d.ts +16 -0
- package/dist/preflightGate.d.ts.map +1 -0
- package/dist/preflightGate.js +29 -0
- package/dist/receiptLogs.d.ts +29 -0
- package/dist/receiptLogs.d.ts.map +1 -0
- package/dist/receiptLogs.js +66 -0
- package/dist/referenceFungibleSecuredDeployBytecode.d.ts +54 -0
- package/dist/referenceFungibleSecuredDeployBytecode.d.ts.map +1 -0
- package/dist/referenceFungibleSecuredDeployBytecode.js +274 -0
- package/dist/referenceNft.d.ts +14 -0
- package/dist/referenceNft.d.ts.map +1 -0
- package/dist/referenceNft.js +34 -0
- package/dist/referenceToken.d.ts +14 -0
- package/dist/referenceToken.d.ts.map +1 -0
- package/dist/referenceToken.js +29 -0
- package/dist/retryAfter.d.ts +6 -0
- package/dist/retryAfter.d.ts.map +1 -0
- package/dist/retryAfter.js +24 -0
- package/dist/rpcCapabilities.d.ts +43 -0
- package/dist/rpcCapabilities.d.ts.map +1 -0
- package/dist/rpcCapabilities.js +159 -0
- package/dist/rpcDoctor.d.ts +27 -0
- package/dist/rpcDoctor.d.ts.map +1 -0
- package/dist/rpcDoctor.js +66 -0
- package/dist/rpcSurfaceUi.d.ts +32 -0
- package/dist/rpcSurfaceUi.d.ts.map +1 -0
- package/dist/rpcSurfaceUi.js +49 -0
- package/dist/submitFlow.d.ts +70 -0
- package/dist/submitFlow.d.ts.map +1 -0
- package/dist/submitFlow.js +121 -0
- package/dist/transactionBuilder.d.ts +55 -0
- package/dist/transactionBuilder.d.ts.map +1 -0
- package/dist/transactionBuilder.js +100 -0
- package/dist/types.d.ts +436 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/walletProvider.d.ts +46 -0
- package/dist/walletProvider.d.ts.map +1 -0
- package/dist/walletProvider.js +126 -0
- package/package.json +44 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioning + tx-object helpers for **pinned** native Boing deploys (form-parity with EVM apps).
|
|
3
|
+
*
|
|
4
|
+
* See `docs/BOING-CANONICAL-DEPLOY-ARTIFACTS.md`. **Fungible** and **NFT collection** templates ship a
|
|
5
|
+
* pinned default in this package (`DEFAULT_REFERENCE_*`); env vars still override when set.
|
|
6
|
+
*/
|
|
7
|
+
import { DEFAULT_REFERENCE_FUNGIBLE_TEMPLATE_BYTECODE_HEX } from './defaultReferenceFungibleTemplateBytecodeHex.js';
|
|
8
|
+
import { DEFAULT_REFERENCE_FUNGIBLE_SECURED_TEMPLATE_BYTECODE_HEX } from './defaultReferenceFungibleSecuredTemplateBytecodeHex.js';
|
|
9
|
+
import { DEFAULT_REFERENCE_NFT_COLLECTION_TEMPLATE_BYTECODE_HEX } from './defaultReferenceNftCollectionTemplateBytecodeHex.js';
|
|
10
|
+
import { descriptionHashHexFromNativeTokenSecurity, } from './nativeTokenSecurity.js';
|
|
11
|
+
import { buildReferenceFungibleSecuredDeployBytecodeHexFromNativeTokenSecurity } from './referenceFungibleSecuredDeployBytecode.js';
|
|
12
|
+
/** Logical id for the fungible template line item (docs + telemetry). */
|
|
13
|
+
export const REFERENCE_FUNGIBLE_TEMPLATE_ARTIFACT_ID = 'boing.reference_fungible.v0';
|
|
14
|
+
/** Bump when default pinned hex in this package changes. */
|
|
15
|
+
export const REFERENCE_FUNGIBLE_TEMPLATE_VERSION = '1';
|
|
16
|
+
/** Logical id for the secured fungible template (`0xFD` init + runtime toggles). */
|
|
17
|
+
export const REFERENCE_FUNGIBLE_SECURED_TEMPLATE_ARTIFACT_ID = 'boing.reference_fungible_secured.v0';
|
|
18
|
+
/** Bump when default pinned secured hex in this package changes. */
|
|
19
|
+
export const REFERENCE_FUNGIBLE_SECURED_TEMPLATE_VERSION = '1';
|
|
20
|
+
/** Logical id for the NFT collection template. */
|
|
21
|
+
export const REFERENCE_NFT_COLLECTION_TEMPLATE_ARTIFACT_ID = 'boing.reference_nft_collection.v0';
|
|
22
|
+
/** Matches `reference_nft_collection_template_bytecode()` in `boing-execution` (regenerate via `dump_reference_token_artifacts`). */
|
|
23
|
+
export const REFERENCE_NFT_COLLECTION_TEMPLATE_VERSION = '1';
|
|
24
|
+
const DEFAULT_NFT_COLLECTION_ENV_KEYS = [
|
|
25
|
+
'BOING_REFERENCE_NFT_COLLECTION_TEMPLATE_BYTECODE_HEX',
|
|
26
|
+
'VITE_BOING_REFERENCE_NFT_COLLECTION_TEMPLATE_BYTECODE_HEX',
|
|
27
|
+
'REACT_APP_BOING_REFERENCE_NFT_COLLECTION_TEMPLATE_BYTECODE_HEX',
|
|
28
|
+
];
|
|
29
|
+
const DEFAULT_FUNGIBLE_ENV_KEYS = [
|
|
30
|
+
'BOING_REFERENCE_FUNGIBLE_TEMPLATE_BYTECODE_HEX',
|
|
31
|
+
'VITE_BOING_REFERENCE_FUNGIBLE_TEMPLATE_BYTECODE_HEX',
|
|
32
|
+
'REACT_APP_BOING_REFERENCE_FUNGIBLE_TEMPLATE_BYTECODE_HEX',
|
|
33
|
+
];
|
|
34
|
+
const DEFAULT_FUNGIBLE_SECURED_ENV_KEYS = [
|
|
35
|
+
'BOING_REFERENCE_FUNGIBLE_SECURED_TEMPLATE_BYTECODE_HEX',
|
|
36
|
+
'VITE_BOING_REFERENCE_FUNGIBLE_SECURED_TEMPLATE_BYTECODE_HEX',
|
|
37
|
+
'REACT_APP_BOING_REFERENCE_FUNGIBLE_SECURED_TEMPLATE_BYTECODE_HEX',
|
|
38
|
+
];
|
|
39
|
+
function readProcessEnv(name) {
|
|
40
|
+
try {
|
|
41
|
+
const proc = globalThis.process;
|
|
42
|
+
if (proc?.env && typeof proc.env[name] === 'string') {
|
|
43
|
+
const v = proc.env[name]?.trim();
|
|
44
|
+
return v || undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
/* ignore */
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Normalize hex for wallet RPC payloads (`0x` prefix). Use for deploy bytecode or `description_hash`.
|
|
54
|
+
*/
|
|
55
|
+
export function ensure0xHex(hex) {
|
|
56
|
+
const t = hex.trim();
|
|
57
|
+
if (!t) {
|
|
58
|
+
throw new Error('ensure0xHex: empty hex');
|
|
59
|
+
}
|
|
60
|
+
const prefixed = t.startsWith('0x') || t.startsWith('0X') ? t : `0x${t}`;
|
|
61
|
+
return prefixed;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolve pinned fungible template bytecode: explicit override → known env keys → embedded default
|
|
65
|
+
* (`DEFAULT_REFERENCE_FUNGIBLE_TEMPLATE_BYTECODE_HEX`).
|
|
66
|
+
*/
|
|
67
|
+
export function resolveReferenceFungibleTemplateBytecodeHex(opts) {
|
|
68
|
+
if (opts?.explicitHex?.trim()) {
|
|
69
|
+
return ensure0xHex(opts.explicitHex);
|
|
70
|
+
}
|
|
71
|
+
for (const k of DEFAULT_FUNGIBLE_ENV_KEYS) {
|
|
72
|
+
const v = readProcessEnv(k);
|
|
73
|
+
if (v)
|
|
74
|
+
return ensure0xHex(v);
|
|
75
|
+
}
|
|
76
|
+
if (opts?.extraEnvKeys) {
|
|
77
|
+
for (const k of opts.extraEnvKeys) {
|
|
78
|
+
const v = readProcessEnv(k);
|
|
79
|
+
if (v)
|
|
80
|
+
return ensure0xHex(v);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return ensure0xHex(DEFAULT_REFERENCE_FUNGIBLE_TEMPLATE_BYTECODE_HEX);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Resolve pinned **secured** fungible deploy bytecode (`0xFD` init + runtime): explicit → env → embedded default.
|
|
87
|
+
*/
|
|
88
|
+
export function resolveReferenceFungibleSecuredTemplateBytecodeHex(opts) {
|
|
89
|
+
if (opts?.explicitHex?.trim()) {
|
|
90
|
+
return ensure0xHex(opts.explicitHex);
|
|
91
|
+
}
|
|
92
|
+
for (const k of DEFAULT_FUNGIBLE_SECURED_ENV_KEYS) {
|
|
93
|
+
const v = readProcessEnv(k);
|
|
94
|
+
if (v)
|
|
95
|
+
return ensure0xHex(v);
|
|
96
|
+
}
|
|
97
|
+
if (opts?.extraEnvKeys) {
|
|
98
|
+
for (const k of opts.extraEnvKeys) {
|
|
99
|
+
const v = readProcessEnv(k);
|
|
100
|
+
if (v)
|
|
101
|
+
return ensure0xHex(v);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return ensure0xHex(DEFAULT_REFERENCE_FUNGIBLE_SECURED_TEMPLATE_BYTECODE_HEX);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Resolve pinned **reference NFT collection** template bytecode (explicit → env → embedded default,
|
|
108
|
+
* same pattern as {@link resolveReferenceFungibleTemplateBytecodeHex}).
|
|
109
|
+
*/
|
|
110
|
+
export function resolveReferenceNftCollectionTemplateBytecodeHex(opts) {
|
|
111
|
+
if (opts?.explicitHex?.trim()) {
|
|
112
|
+
return ensure0xHex(opts.explicitHex);
|
|
113
|
+
}
|
|
114
|
+
for (const k of DEFAULT_NFT_COLLECTION_ENV_KEYS) {
|
|
115
|
+
const v = readProcessEnv(k);
|
|
116
|
+
if (v)
|
|
117
|
+
return ensure0xHex(v);
|
|
118
|
+
}
|
|
119
|
+
if (opts?.extraEnvKeys) {
|
|
120
|
+
for (const k of opts.extraEnvKeys) {
|
|
121
|
+
const v = readProcessEnv(k);
|
|
122
|
+
if (v)
|
|
123
|
+
return ensure0xHex(v);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return ensure0xHex(DEFAULT_REFERENCE_NFT_COLLECTION_TEMPLATE_BYTECODE_HEX);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Build a **`contract_deploy_meta`** object for `boing_sendTransaction` / `boing_signTransaction`.
|
|
130
|
+
*/
|
|
131
|
+
export function buildContractDeployMetaTx(input) {
|
|
132
|
+
const name = input.assetName.trim();
|
|
133
|
+
const sym = input.assetSymbol.trim().toUpperCase();
|
|
134
|
+
if (!name) {
|
|
135
|
+
throw new Error('buildContractDeployMetaTx: assetName required');
|
|
136
|
+
}
|
|
137
|
+
if (!sym) {
|
|
138
|
+
throw new Error('buildContractDeployMetaTx: assetSymbol required');
|
|
139
|
+
}
|
|
140
|
+
const bytecode = ensure0xHex(input.bytecodeHex);
|
|
141
|
+
const purpose_category = (input.purposeCategory ?? 'token').trim();
|
|
142
|
+
const out = {
|
|
143
|
+
type: 'contract_deploy_meta',
|
|
144
|
+
bytecode,
|
|
145
|
+
purpose_category,
|
|
146
|
+
asset_name: name,
|
|
147
|
+
asset_symbol: sym,
|
|
148
|
+
};
|
|
149
|
+
const dh = input.descriptionHashHex?.trim();
|
|
150
|
+
if (dh) {
|
|
151
|
+
out.description_hash = ensure0xHex(dh);
|
|
152
|
+
}
|
|
153
|
+
return out;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* **One call** for wizard-style **Deploy token** on Boing: resolve pinned fungible bytecode + build **`contract_deploy_meta`**.
|
|
157
|
+
* Pass the result to **`boing_sendTransaction`** / **`boing_signTransaction`** (Boing Express).
|
|
158
|
+
*/
|
|
159
|
+
export function buildReferenceFungibleDeployMetaTx(input) {
|
|
160
|
+
const bytecodeHex = input.bytecodeHexOverride?.trim()
|
|
161
|
+
? ensure0xHex(input.bytecodeHexOverride)
|
|
162
|
+
: resolveReferenceFungibleTemplateBytecodeHex({ extraEnvKeys: input.extraEnvKeys });
|
|
163
|
+
const explicitDh = input.descriptionHashHex?.trim();
|
|
164
|
+
const securityDh = !explicitDh && input.nativeTokenSecurity
|
|
165
|
+
? descriptionHashHexFromNativeTokenSecurity(input.nativeTokenSecurity)
|
|
166
|
+
: undefined;
|
|
167
|
+
return buildContractDeployMetaTx({
|
|
168
|
+
bytecodeHex,
|
|
169
|
+
assetName: input.assetName,
|
|
170
|
+
assetSymbol: input.assetSymbol,
|
|
171
|
+
purposeCategory: input.purposeCategory,
|
|
172
|
+
descriptionHashHex: explicitDh || securityDh,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Same as {@link buildReferenceFungibleDeployMetaTx} but uses the secured fungible template.
|
|
177
|
+
* When **`nativeTokenSecurity`** is passed, bytecode is built so wizard toggles map to on-chain
|
|
178
|
+
* `reference_fungible_secured` init storage (not only `description_hash`). When omitted, uses the
|
|
179
|
+
* pinned default secured template (flags off).
|
|
180
|
+
*/
|
|
181
|
+
export function buildReferenceFungibleSecuredDeployMetaTx(input) {
|
|
182
|
+
const bytecodeHex = input.bytecodeHexOverride?.trim()
|
|
183
|
+
? ensure0xHex(input.bytecodeHexOverride)
|
|
184
|
+
: input.nativeTokenSecurity !== undefined
|
|
185
|
+
? buildReferenceFungibleSecuredDeployBytecodeHexFromNativeTokenSecurity(input.nativeTokenSecurity, {
|
|
186
|
+
chainHeight: input.chainContext?.chainHeight,
|
|
187
|
+
mintFirstTotalSupplyWei: input.mintFirstTotalSupplyWei,
|
|
188
|
+
})
|
|
189
|
+
: resolveReferenceFungibleSecuredTemplateBytecodeHex({ extraEnvKeys: input.extraEnvKeys });
|
|
190
|
+
const explicitDh = input.descriptionHashHex?.trim();
|
|
191
|
+
const securityDh = !explicitDh && input.nativeTokenSecurity
|
|
192
|
+
? descriptionHashHexFromNativeTokenSecurity(input.nativeTokenSecurity)
|
|
193
|
+
: undefined;
|
|
194
|
+
return buildContractDeployMetaTx({
|
|
195
|
+
bytecodeHex,
|
|
196
|
+
assetName: input.assetName,
|
|
197
|
+
assetSymbol: input.assetSymbol,
|
|
198
|
+
purposeCategory: input.purposeCategory,
|
|
199
|
+
descriptionHashHex: explicitDh || securityDh,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* **One call** for **native NFT collection** deploy meta tx. Bytecode: **`bytecodeHexOverride`** if set,
|
|
204
|
+
* else env keys (see {@link resolveReferenceNftCollectionTemplateBytecodeHex}), else the SDK embedded default.
|
|
205
|
+
*/
|
|
206
|
+
export function buildReferenceNftCollectionDeployMetaTx(input) {
|
|
207
|
+
const bytecodeHex = input.bytecodeHexOverride?.trim()
|
|
208
|
+
? ensure0xHex(input.bytecodeHexOverride)
|
|
209
|
+
: resolveReferenceNftCollectionTemplateBytecodeHex({ extraEnvKeys: input.extraEnvKeys });
|
|
210
|
+
return buildContractDeployMetaTx({
|
|
211
|
+
bytecodeHex,
|
|
212
|
+
assetName: input.collectionName,
|
|
213
|
+
assetSymbol: input.collectionSymbol,
|
|
214
|
+
purposeCategory: input.purposeCategory ?? 'nft',
|
|
215
|
+
descriptionHashHex: input.descriptionHashHex,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
const DEFAULT_NATIVE_AMM_POOL_ENV_KEYS = [
|
|
219
|
+
'BOING_NATIVE_AMM_BYTECODE_HEX',
|
|
220
|
+
'VITE_BOING_NATIVE_AMM_BYTECODE_HEX',
|
|
221
|
+
'REACT_APP_BOING_NATIVE_AMM_BYTECODE_HEX',
|
|
222
|
+
];
|
|
223
|
+
/**
|
|
224
|
+
* Resolve **native constant-product pool** bytecode from override or env (same keys as
|
|
225
|
+
* [examples/native-boing-tutorial](../examples/native-boing-tutorial/) **`BOING_NATIVE_AMM_BYTECODE_HEX`**).
|
|
226
|
+
*/
|
|
227
|
+
export function resolveNativeConstantProductPoolBytecodeHex(opts) {
|
|
228
|
+
if (opts?.explicitHex?.trim()) {
|
|
229
|
+
return ensure0xHex(opts.explicitHex);
|
|
230
|
+
}
|
|
231
|
+
for (const k of DEFAULT_NATIVE_AMM_POOL_ENV_KEYS) {
|
|
232
|
+
const v = readProcessEnv(k);
|
|
233
|
+
if (v)
|
|
234
|
+
return ensure0xHex(v);
|
|
235
|
+
}
|
|
236
|
+
if (opts?.extraEnvKeys) {
|
|
237
|
+
for (const k of opts.extraEnvKeys) {
|
|
238
|
+
const v = readProcessEnv(k);
|
|
239
|
+
if (v)
|
|
240
|
+
return ensure0xHex(v);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return undefined;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* **One call** for **native CP pool** **`contract_deploy_meta`**: pinned bytecode from env or override,
|
|
247
|
+
* **`purpose_category`** default **`dapp`**, then the same Express shape as token/NFT deploys.
|
|
248
|
+
*/
|
|
249
|
+
export function buildNativeConstantProductPoolDeployMetaTx(input) {
|
|
250
|
+
const bytecodeHex = input.bytecodeHexOverride?.trim()
|
|
251
|
+
? ensure0xHex(input.bytecodeHexOverride)
|
|
252
|
+
: resolveNativeConstantProductPoolBytecodeHex({ extraEnvKeys: input.extraEnvKeys });
|
|
253
|
+
if (!bytecodeHex) {
|
|
254
|
+
throw new Error('buildNativeConstantProductPoolDeployMetaTx: no pool bytecode — set BOING_NATIVE_AMM_BYTECODE_HEX (or VITE_/REACT_APP_ variant), or pass bytecodeHexOverride');
|
|
255
|
+
}
|
|
256
|
+
const name = (input.poolLabel ?? 'Native CP Pool').trim();
|
|
257
|
+
const sym = (input.poolSymbol ?? 'POOL').trim().toUpperCase();
|
|
258
|
+
if (!name) {
|
|
259
|
+
throw new Error('buildNativeConstantProductPoolDeployMetaTx: poolLabel required when set to empty');
|
|
260
|
+
}
|
|
261
|
+
if (!sym) {
|
|
262
|
+
throw new Error('buildNativeConstantProductPoolDeployMetaTx: poolSymbol required when set to empty');
|
|
263
|
+
}
|
|
264
|
+
return buildContractDeployMetaTx({
|
|
265
|
+
bytecodeHex,
|
|
266
|
+
assetName: name,
|
|
267
|
+
assetSymbol: sym,
|
|
268
|
+
purposeCategory: input.purposeCategory ?? 'dapp',
|
|
269
|
+
descriptionHashHex: input.descriptionHashHex,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Well-known **public Boing testnet** (chain id **6913**) identifiers.
|
|
3
|
+
*
|
|
4
|
+
* **Normative source of truth** for the canonical native CP pool address is
|
|
5
|
+
* [RPC-API-SPEC.md](https://github.com/Boing-Network/boing.network/blob/main/docs/RPC-API-SPEC.md) § Native constant-product AMM
|
|
6
|
+
* and [TESTNET.md](https://github.com/Boing-Network/boing.network/blob/main/docs/TESTNET.md) §5.3.
|
|
7
|
+
* This constant is a **convenience mirror** for TypeScript apps and tutorials; it may lag a doc-only update — verify on docs if unsure.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Canonical **v1** native constant-product pool `AccountId` on public Boing testnet (**6913**).
|
|
11
|
+
* Rotations: [OPS-FRESH-TESTNET-BOOTSTRAP.md](../../docs/OPS-FRESH-TESTNET-BOOTSTRAP.md).
|
|
12
|
+
*/
|
|
13
|
+
/** Live stack on `https://testnet-rpc.boing.network` — see `docs/NATIVE-DEX-OPERATOR-DEPLOYMENT-RECORD.md` Appendix B. */
|
|
14
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_CP_POOL_HEX: string;
|
|
15
|
+
//# sourceMappingURL=canonicalTestnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalTestnet.d.ts","sourceRoot":"","sources":["../src/canonicalTestnet.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;GAGG;AACH,0HAA0H;AAC1H,eAAO,MAAM,0CAA0C,QAEtD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Well-known **public Boing testnet** (chain id **6913**) identifiers.
|
|
3
|
+
*
|
|
4
|
+
* **Normative source of truth** for the canonical native CP pool address is
|
|
5
|
+
* [RPC-API-SPEC.md](https://github.com/Boing-Network/boing.network/blob/main/docs/RPC-API-SPEC.md) § Native constant-product AMM
|
|
6
|
+
* and [TESTNET.md](https://github.com/Boing-Network/boing.network/blob/main/docs/TESTNET.md) §5.3.
|
|
7
|
+
* This constant is a **convenience mirror** for TypeScript apps and tutorials; it may lag a doc-only update — verify on docs if unsure.
|
|
8
|
+
*/
|
|
9
|
+
import { validateHex32 } from './hex.js';
|
|
10
|
+
/**
|
|
11
|
+
* Canonical **v1** native constant-product pool `AccountId` on public Boing testnet (**6913**).
|
|
12
|
+
* Rotations: [OPS-FRESH-TESTNET-BOOTSTRAP.md](../../docs/OPS-FRESH-TESTNET-BOOTSTRAP.md).
|
|
13
|
+
*/
|
|
14
|
+
/** Live stack on `https://testnet-rpc.boing.network` — see `docs/NATIVE-DEX-OPERATOR-DEPLOYMENT-RECORD.md` Appendix B. */
|
|
15
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_CP_POOL_HEX = validateHex32('0x7247ddc3180fdc4d3fd1e716229bfa16bad334a07d28aa9fda9ad1bfa7bdacc3');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Live native DEX aux** on public Boing testnet RPC (`https://testnet-rpc.boing.network`, chain **6913**).
|
|
3
|
+
* Deployed via `npm run deploy-native-dex-full-stack` (operator record: `docs/NATIVE-DEX-OPERATOR-DEPLOYMENT-RECORD.md` Appendix B).
|
|
4
|
+
*
|
|
5
|
+
* **V1 ledger router** is optional (`BOING_AUX_INCLUDE_LEDGER_V1`); this stack ships swap2 + v2 + v3 forwarders only.
|
|
6
|
+
* `CANONICAL_BOING_TESTNET_NATIVE_DEX_LEDGER_ROUTER_V1_HEX` remains a legacy CREATE2 prediction id — do not assume it is deployed.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_DEX_DEPLOYER_HEX: string;
|
|
9
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_DEX_FACTORY_HEX: string;
|
|
10
|
+
/** Legacy predicted v1 — not deployed on the current testnet-rpc full-stack bundle unless aux includes v1. */
|
|
11
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_DEX_LEDGER_ROUTER_V1_HEX: string;
|
|
12
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_DEX_LEDGER_ROUTER_V2_HEX: string;
|
|
13
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_DEX_LEDGER_ROUTER_V3_HEX: string;
|
|
14
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_DEX_MULTIHOP_SWAP_ROUTER_HEX: string;
|
|
15
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_AMM_LP_VAULT_HEX: string;
|
|
16
|
+
export declare const CANONICAL_BOING_TESTNET_NATIVE_LP_SHARE_TOKEN_HEX: string;
|
|
17
|
+
//# sourceMappingURL=canonicalTestnetDex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonicalTestnetDex.d.ts","sourceRoot":"","sources":["../src/canonicalTestnetDex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,eAAO,MAAM,+CAA+C,QAE3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,QAE1D,CAAC;AAEF,8GAA8G;AAC9G,eAAO,MAAM,uDAAuD,QAEnE,CAAC;AAEF,eAAO,MAAM,uDAAuD,QAEnE,CAAC;AAEF,eAAO,MAAM,uDAAuD,QAEnE,CAAC;AAEF,eAAO,MAAM,2DAA2D,QAEvE,CAAC;AAEF,eAAO,MAAM,+CAA+C,QAE3D,CAAC;AAEF,eAAO,MAAM,iDAAiD,QAE7D,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **Live native DEX aux** on public Boing testnet RPC (`https://testnet-rpc.boing.network`, chain **6913**).
|
|
3
|
+
* Deployed via `npm run deploy-native-dex-full-stack` (operator record: `docs/NATIVE-DEX-OPERATOR-DEPLOYMENT-RECORD.md` Appendix B).
|
|
4
|
+
*
|
|
5
|
+
* **V1 ledger router** is optional (`BOING_AUX_INCLUDE_LEDGER_V1`); this stack ships swap2 + v2 + v3 forwarders only.
|
|
6
|
+
* `CANONICAL_BOING_TESTNET_NATIVE_DEX_LEDGER_ROUTER_V1_HEX` remains a legacy CREATE2 prediction id — do not assume it is deployed.
|
|
7
|
+
*/
|
|
8
|
+
import { validateHex32 } from './hex.js';
|
|
9
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_DEX_DEPLOYER_HEX = validateHex32('0x3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29');
|
|
10
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_DEX_FACTORY_HEX = validateHex32('0x58112627fc84618a27b82e9af82bc9a51761c6d3cca1260c93d56d22b6c481a1');
|
|
11
|
+
/** Legacy predicted v1 — not deployed on the current testnet-rpc full-stack bundle unless aux includes v1. */
|
|
12
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_DEX_LEDGER_ROUTER_V1_HEX = validateHex32('0x371b4cd7e3b88e06e6b89bdc86214918a7e7ec73b62deb7f9975e4166736d54d');
|
|
13
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_DEX_LEDGER_ROUTER_V2_HEX = validateHex32('0x33334ff73c44c93335ac5e69938a52ea65fa77b062d1961ed22c131adaa31e0f');
|
|
14
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_DEX_LEDGER_ROUTER_V3_HEX = validateHex32('0x2c90ffcddeb2683219b4b8143a91d7b93f249bcb0d9523c8b4f2111de668b79a');
|
|
15
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_DEX_MULTIHOP_SWAP_ROUTER_HEX = validateHex32('0xf801cd1aa5ec402f89a2f394b49e6b0c136264d8945b16a4a6a81a188b18acc1');
|
|
16
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_AMM_LP_VAULT_HEX = validateHex32('0x937d09ee8e4dcc521c812566ad4930792e74ad004ecb3ae2cc73dc015813aa8d');
|
|
17
|
+
export const CANONICAL_BOING_TESTNET_NATIVE_LP_SHARE_TOKEN_HEX = validateHex32('0x101201403f573e5b1d6d5c6b93d52d12c68957f4a228d5dad76e78c747044421');
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chain identifiers for **native Boing** L1 — use in multi-network dApps (deploy wizards, network pickers).
|
|
3
|
+
*
|
|
4
|
+
* Prefer **`boing_getNetworkInfo`**.`chain_id` when connected to a live RPC; use these constants when
|
|
5
|
+
* branching on **`eth_chainId`** / **`boing_chainId`** from the wallet.
|
|
6
|
+
*/
|
|
7
|
+
/** Public testnet chain id (decimal), per docs ([TESTNET.md](../../docs/TESTNET.md)). */
|
|
8
|
+
export declare const BOING_TESTNET_CHAIN_ID_DECIMAL = 6913;
|
|
9
|
+
/** Same id as EIP-155-style `0x`-prefixed hex (lowercase). */
|
|
10
|
+
export declare const BOING_TESTNET_CHAIN_ID_HEX: "0x1b01";
|
|
11
|
+
/**
|
|
12
|
+
* Normalize wallet/RPC chain id to lowercase `0x` hex (e.g. **`0x1b01`**).
|
|
13
|
+
* Accepts decimal string, `0x` hex, or bigint / number.
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeBoingChainIdHex(chainId: string | number | bigint): `0x${string}`;
|
|
16
|
+
/** True when **`chainId`** is **Boing testnet** (6913 / `0x1b01`), after normalization. */
|
|
17
|
+
export declare function isBoingTestnetChainId(chainId: string | number | bigint): boolean;
|
|
18
|
+
//# sourceMappingURL=chainIds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chainIds.d.ts","sourceRoot":"","sources":["../src/chainIds.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yFAAyF;AACzF,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD,8DAA8D;AAC9D,eAAO,MAAM,0BAA0B,EAAG,QAAiB,CAAC;AAO5D;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,MAAM,EAAE,CA2BzF;AAED,2FAA2F;AAC3F,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAOhF"}
|
package/dist/chainIds.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chain identifiers for **native Boing** L1 — use in multi-network dApps (deploy wizards, network pickers).
|
|
3
|
+
*
|
|
4
|
+
* Prefer **`boing_getNetworkInfo`**.`chain_id` when connected to a live RPC; use these constants when
|
|
5
|
+
* branching on **`eth_chainId`** / **`boing_chainId`** from the wallet.
|
|
6
|
+
*/
|
|
7
|
+
/** Public testnet chain id (decimal), per docs ([TESTNET.md](../../docs/TESTNET.md)). */
|
|
8
|
+
export const BOING_TESTNET_CHAIN_ID_DECIMAL = 6913;
|
|
9
|
+
/** Same id as EIP-155-style `0x`-prefixed hex (lowercase). */
|
|
10
|
+
export const BOING_TESTNET_CHAIN_ID_HEX = '0x1b01';
|
|
11
|
+
function strip0x(h) {
|
|
12
|
+
const t = h.trim().toLowerCase();
|
|
13
|
+
return t.startsWith('0x') ? t.slice(2) : t;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Normalize wallet/RPC chain id to lowercase `0x` hex (e.g. **`0x1b01`**).
|
|
17
|
+
* Accepts decimal string, `0x` hex, or bigint / number.
|
|
18
|
+
*/
|
|
19
|
+
export function normalizeBoingChainIdHex(chainId) {
|
|
20
|
+
if (typeof chainId === 'bigint') {
|
|
21
|
+
if (chainId < 0n) {
|
|
22
|
+
throw new Error('normalizeBoingChainIdHex: negative chain id');
|
|
23
|
+
}
|
|
24
|
+
return `0x${chainId.toString(16)}`;
|
|
25
|
+
}
|
|
26
|
+
if (typeof chainId === 'number') {
|
|
27
|
+
if (!Number.isInteger(chainId) || chainId < 0) {
|
|
28
|
+
throw new Error(`normalizeBoingChainIdHex: invalid number ${chainId}`);
|
|
29
|
+
}
|
|
30
|
+
return `0x${BigInt(chainId).toString(16)}`;
|
|
31
|
+
}
|
|
32
|
+
const s = chainId.trim();
|
|
33
|
+
if (/^\d+$/.test(s)) {
|
|
34
|
+
const n = BigInt(s);
|
|
35
|
+
if (n < 0n) {
|
|
36
|
+
throw new Error('normalizeBoingChainIdHex: negative chain id');
|
|
37
|
+
}
|
|
38
|
+
return `0x${n.toString(16)}`;
|
|
39
|
+
}
|
|
40
|
+
const bare = strip0x(s);
|
|
41
|
+
if (!/^[0-9a-f]+$/i.test(bare)) {
|
|
42
|
+
throw new Error('normalizeBoingChainIdHex: expected decimal or hex chain id');
|
|
43
|
+
}
|
|
44
|
+
const n = BigInt(`0x${bare}`);
|
|
45
|
+
return `0x${n.toString(16)}`;
|
|
46
|
+
}
|
|
47
|
+
/** True when **`chainId`** is **Boing testnet** (6913 / `0x1b01`), after normalization. */
|
|
48
|
+
export function isBoingTestnetChainId(chainId) {
|
|
49
|
+
try {
|
|
50
|
+
const h = normalizeBoingChainIdHex(chainId).toLowerCase();
|
|
51
|
+
return h === BOING_TESTNET_CHAIN_ID_HEX;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boing JSON-RPC client — typed methods for all node RPCs.
|
|
3
|
+
*/
|
|
4
|
+
import type { AccountBalance, AccountProof, AccountState, Block, ExecutionReceipt, GetLogsFilter, RpcLogEntry, FaucetResult, QaCheckResponse, QaPoolConfigResult, QaPoolListResult, QaPoolVoteResult, RegisterDappResult, SimulateResult, SubmitIntentResult, SubmitTransactionResult, SyncState, NetworkInfo, BoingHealth, RpcMethodCatalog, RpcOpenApiDocument, BoingRpcPreflightResult, ContractStorageWord, DexPoolListPage, DexTokenListPage, DexTokenListRow, VerifyProofResult, OperatorApplyQaPolicyResult, QaRegistryResult, JsonRpcBatchResponseItem } from './types.js';
|
|
5
|
+
export interface BoingClientConfig {
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
/** Optional fetch implementation (e.g. for Node or custom headers). */
|
|
8
|
+
fetch?: typeof fetch;
|
|
9
|
+
/** Request timeout in ms. Default 30000. Set 0 to disable. */
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
/** Merged into every JSON-RPC request (e.g. `{ 'X-Boing-Operator': token }`). */
|
|
12
|
+
extraHeaders?: Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Extra attempts after the first failure for transient errors (HTTP 429/502/503/504, RPC -32016,
|
|
15
|
+
* timeouts, network). Default **0** (no retries).
|
|
16
|
+
*/
|
|
17
|
+
maxRetries?: number;
|
|
18
|
+
/** Backoff base in ms before each retry: wait `retryBaseDelayMs * 2^attempt`. Default 250. */
|
|
19
|
+
retryBaseDelayMs?: number;
|
|
20
|
+
/**
|
|
21
|
+
* When true, sends **`X-Request-Id`** on each HTTP call (fresh UUID per request). Nodes echo it for log correlation.
|
|
22
|
+
*/
|
|
23
|
+
generateRequestId?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* HTTP JSON-RPC client for a Boing node.
|
|
27
|
+
* All methods return typed results; on RPC error they throw BoingRpcError (with code, message, method, and optional data).
|
|
28
|
+
*/
|
|
29
|
+
export declare class BoingClient {
|
|
30
|
+
private readonly baseUrl;
|
|
31
|
+
private readonly fetchImpl;
|
|
32
|
+
private readonly timeoutMs;
|
|
33
|
+
private readonly extraHeaders;
|
|
34
|
+
private readonly maxRetries;
|
|
35
|
+
private readonly retryBaseDelayMs;
|
|
36
|
+
private readonly generateRequestId;
|
|
37
|
+
private id;
|
|
38
|
+
/** From the last JSON-RPC **`POST /`** response header **`x-request-id`** (when present). */
|
|
39
|
+
private lastXRequestId;
|
|
40
|
+
constructor(config: string | BoingClientConfig);
|
|
41
|
+
/** Normalized RPC origin (no trailing slash). */
|
|
42
|
+
getBaseUrl(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Correlation id from the most recent JSON-RPC **`POST /`** response (**`x-request-id`**).
|
|
45
|
+
* Useful for support UI when CORS exposes this header on the response.
|
|
46
|
+
*/
|
|
47
|
+
getLastXRequestId(): string | undefined;
|
|
48
|
+
private recordRequestIdFromResponse;
|
|
49
|
+
private rpcExtraHeaders;
|
|
50
|
+
private requestOnce;
|
|
51
|
+
private request;
|
|
52
|
+
private requestBatchOnce;
|
|
53
|
+
/**
|
|
54
|
+
* POST a JSON-RPC **batch** (JSON array of requests). Assigns monotonic numeric `id`s; returns the response array in order.
|
|
55
|
+
*/
|
|
56
|
+
requestBatch(calls: ReadonlyArray<{
|
|
57
|
+
method: string;
|
|
58
|
+
params?: unknown[];
|
|
59
|
+
}>): Promise<JsonRpcBatchResponseItem[]>;
|
|
60
|
+
/**
|
|
61
|
+
* `GET {baseUrl}/live` — process is up (no chain read; for orchestrator liveness).
|
|
62
|
+
* Uses the same `extraHeaders` as JSON-RPC (e.g. auth in front of the node).
|
|
63
|
+
*/
|
|
64
|
+
checkHttpLive(): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* `GET {baseUrl}/ready` — node can serve RPC (read lock on state). Returns false on **503** when
|
|
67
|
+
* the node enforces **`BOING_RPC_READY_MIN_PEERS`** and peer count is too low.
|
|
68
|
+
*/
|
|
69
|
+
checkHttpReady(): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* One round-trip sanity check for dashboards and CI: `health`, supported method count,
|
|
72
|
+
* optional catalog size, whether OpenAPI JSON is exposed, plain HTTP `/live` + `/ready`,
|
|
73
|
+
* and a small JSON-RPC **batch** probe (`jsonrpcBatchOk`).
|
|
74
|
+
*/
|
|
75
|
+
preflightRpc(): Promise<BoingRpcPreflightResult>;
|
|
76
|
+
/** `GET {baseUrl}/openapi.json` — same document as `boing_getRpcOpenApi` when the node exposes it. */
|
|
77
|
+
checkHttpOpenApiJson(): Promise<boolean>;
|
|
78
|
+
/** `GET {baseUrl}/.well-known/boing-rpc` — path hints for HTTP discovery. */
|
|
79
|
+
checkWellKnownBoingRpc(): Promise<boolean>;
|
|
80
|
+
/** `GET {baseUrl}/live.json` — JSON liveness probe. */
|
|
81
|
+
checkHttpLiveJson(): Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* **`GET {baseUrl}/openapi.json`** — same OpenAPI document as **`boing_getRpcOpenApi`**, without a JSON-RPC round-trip.
|
|
84
|
+
* Prefer this in browser devtools panels; throws **`BoingRpcError`** when the response is not OK or not JSON.
|
|
85
|
+
*/
|
|
86
|
+
fetchOpenApiViaHttp(): Promise<RpcOpenApiDocument>;
|
|
87
|
+
/** Current chain height (tip block number). */
|
|
88
|
+
chainHeight(): Promise<number>;
|
|
89
|
+
/** Build identity string for this node (e.g. `boing-node/0.1.0`). Params: `[]`. */
|
|
90
|
+
clientVersion(): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Alphabetically sorted `boing_*` method names implemented by this binary (discovery). Params: `[]`.
|
|
93
|
+
*/
|
|
94
|
+
rpcSupportedMethods(): Promise<string[]>;
|
|
95
|
+
/** Embedded JSON Schema-style catalog for codegen (params `[]`). See `boing_getNetworkInfo.developer`. */
|
|
96
|
+
getRpcMethodCatalog(): Promise<RpcMethodCatalog>;
|
|
97
|
+
/** Minimal OpenAPI 3.1 document for `POST /` JSON-RPC and `GET /ws` (params `[]`). */
|
|
98
|
+
getRpcOpenApi(): Promise<RpcOpenApiDocument>;
|
|
99
|
+
/**
|
|
100
|
+
* Liveness and build identity (params `[]`). Prefer this over `boing_chainHeight` for load balancers:
|
|
101
|
+
* includes `client_version`, optional `chain_id` / `chain_name` from node env, and `head_height`.
|
|
102
|
+
*/
|
|
103
|
+
health(): Promise<BoingHealth>;
|
|
104
|
+
/**
|
|
105
|
+
* Committed chain tip: `head_height`, `finalized_height` (same as head today), and tip `latest_block_hash`.
|
|
106
|
+
* See RPC-API-SPEC.md — finality semantics.
|
|
107
|
+
*/
|
|
108
|
+
getSyncState(): Promise<SyncState>;
|
|
109
|
+
/**
|
|
110
|
+
* Network + tip snapshot for dApps (params `[]`). Includes `chain_native` (sums over committed accounts) and
|
|
111
|
+
* `rpc.not_available` for capabilities this surface does not expose (e.g. staking APY).
|
|
112
|
+
* See RPC-API-SPEC.md — `chain_id` / `chain_name` require node env `BOING_CHAIN_ID` / `BOING_CHAIN_NAME`.
|
|
113
|
+
*/
|
|
114
|
+
getNetworkInfo(): Promise<NetworkInfo>;
|
|
115
|
+
/** Get spendable balance for an account. Params: 32-byte account ID (hex). */
|
|
116
|
+
getBalance(hexAccountId: string): Promise<AccountBalance>;
|
|
117
|
+
/** Get full account state (balance, nonce, stake). Params: 32-byte account ID (hex). */
|
|
118
|
+
getAccount(hexAccountId: string): Promise<AccountState>;
|
|
119
|
+
/** Get block by height. Returns null if not found. */
|
|
120
|
+
getBlockByHeight(height: number, includeReceipts?: boolean): Promise<Block | null>;
|
|
121
|
+
/** Receipt for an included tx (`Transaction.id` hex), or `null` if unknown. */
|
|
122
|
+
getTransactionReceipt(hexTxId: string): Promise<ExecutionReceipt | null>;
|
|
123
|
+
/**
|
|
124
|
+
* Bounded log query over committed blocks (see RPC-API-SPEC — max block span and result cap on the node).
|
|
125
|
+
* Optional `address` is normalized to 32-byte hex when provided.
|
|
126
|
+
*/
|
|
127
|
+
getLogs(filter: GetLogsFilter): Promise<RpcLogEntry[]>;
|
|
128
|
+
/** Get block by hash. Params: 32-byte block hash (hex). */
|
|
129
|
+
getBlockByHash(hexBlockHash: string, includeReceipts?: boolean): Promise<Block | null>;
|
|
130
|
+
/** Get Merkle proof for an account. Params: 32-byte account ID (hex). */
|
|
131
|
+
getAccountProof(hexAccountId: string): Promise<AccountProof>;
|
|
132
|
+
/** Verify an account Merkle proof. Params: hex proof, hex state root. */
|
|
133
|
+
verifyAccountProof(hexProof: string, hexStateRoot: string): Promise<VerifyProofResult>;
|
|
134
|
+
/** Read one 32-byte VM storage slot for a contract (`SLOAD` semantics; missing → zero word). */
|
|
135
|
+
getContractStorage(hexContractId: string, hexKey32: string): Promise<ContractStorageWord>;
|
|
136
|
+
/**
|
|
137
|
+
* Cursor-paginated native DEX pools (`boing_listDexPools`).
|
|
138
|
+
* Factory: **`params.factory`** (32-byte hex) overrides **`BOING_CANONICAL_NATIVE_DEX_FACTORY`**.
|
|
139
|
+
* Set **`light`** / **`enrich: false`** to skip receipt scan (**`createdAtHeight`** stays null).
|
|
140
|
+
* Each pool row includes **`tokenADecimals`** / **`tokenBDecimals`** (**`BOING_DEX_TOKEN_DECIMALS_JSON`**, default **18**).
|
|
141
|
+
*/
|
|
142
|
+
listDexPoolsPage(params?: {
|
|
143
|
+
cursor?: string | null;
|
|
144
|
+
limit?: number;
|
|
145
|
+
factory?: string;
|
|
146
|
+
/** Fast path: skip receipt scan (no **`createdAtHeight`**). */
|
|
147
|
+
light?: boolean;
|
|
148
|
+
/** When false, same as **`light: true`**. */
|
|
149
|
+
enrich?: boolean;
|
|
150
|
+
/** When true, response may include **`diagnostics`** (receipt scan counters). */
|
|
151
|
+
includeDiagnostics?: boolean;
|
|
152
|
+
}): Promise<DexPoolListPage>;
|
|
153
|
+
/**
|
|
154
|
+
* Cursor-paginated DEX-derived token universe (`boing_listDexTokens`).
|
|
155
|
+
* Optional **`minReserveProduct`** / **`minLiquidityWei`** are decimal digit strings (same as node).
|
|
156
|
+
* **`light`** skips receipt + deploy metadata scans (**`firstSeenHeight`** null, **`metadataSource`** abbrev-only).
|
|
157
|
+
*/
|
|
158
|
+
listDexTokensPage(params?: {
|
|
159
|
+
cursor?: string | null;
|
|
160
|
+
limit?: number;
|
|
161
|
+
factory?: string;
|
|
162
|
+
light?: boolean;
|
|
163
|
+
enrich?: boolean;
|
|
164
|
+
minReserveProduct?: string;
|
|
165
|
+
minLiquidityWei?: string;
|
|
166
|
+
includeDiagnostics?: boolean;
|
|
167
|
+
}): Promise<DexTokenListPage>;
|
|
168
|
+
/** Single-token lookup in the DEX-derived universe (`boing_getDexToken`). */
|
|
169
|
+
getDexToken(idHex32: string, options?: {
|
|
170
|
+
factory?: string;
|
|
171
|
+
light?: boolean;
|
|
172
|
+
enrich?: boolean;
|
|
173
|
+
includeDiagnostics?: boolean;
|
|
174
|
+
}): Promise<DexTokenListRow | null>;
|
|
175
|
+
/** Simulate a transaction without applying it. Params: hex-encoded signed transaction. */
|
|
176
|
+
simulateTransaction(hexSignedTx: string): Promise<SimulateResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Dry-run a `contract_call` without a signed transaction (`boing_simulateContractCall`).
|
|
179
|
+
* Params: `[contract_hex, calldata_hex, sender_hex?, at_block?]` — see `docs/RPC-API-SPEC.md`.
|
|
180
|
+
*/
|
|
181
|
+
simulateContractCall(contractHex: string, calldataHex: string, options?: {
|
|
182
|
+
/** Omit for two-arg RPC; `null` or omit with `atBlock` → JSON `null` (zero sender). */
|
|
183
|
+
senderHex?: string | null;
|
|
184
|
+
/** `"latest"` or current tip height integer. */
|
|
185
|
+
atBlock?: number | 'latest';
|
|
186
|
+
}): Promise<SimulateResult>;
|
|
187
|
+
/**
|
|
188
|
+
* Submit a signed transaction to the mempool.
|
|
189
|
+
* The hex_signed_tx must be hex-encoded bincode-serialized SignedTransaction (from Rust/CLI or future signer).
|
|
190
|
+
*/
|
|
191
|
+
submitTransaction(hexSignedTx: string): Promise<SubmitTransactionResult>;
|
|
192
|
+
/** Register a dApp for incentive tracking. Params: 32-byte hex contract id, 32-byte hex owner id. */
|
|
193
|
+
registerDappMetrics(hexContract: string, hexOwner: string): Promise<RegisterDappResult>;
|
|
194
|
+
/** Submit a signed intent. Params: hex-encoded signed intent. */
|
|
195
|
+
submitIntent(hexSignedIntent: string): Promise<SubmitIntentResult>;
|
|
196
|
+
/**
|
|
197
|
+
* Pre-flight QA check for a deployment (no submit). Matches node param order:
|
|
198
|
+
* [hex_bytecode, purpose_category?, description_hash?, asset_name?, asset_symbol?].
|
|
199
|
+
* When passing asset_name, include description_hash (or use a 32-byte placeholder) per RPC-API-SPEC.
|
|
200
|
+
* Returns allow | reject | unsure; when reject, rule_id and message are set.
|
|
201
|
+
*/
|
|
202
|
+
/** List pending governance QA pool items. */
|
|
203
|
+
qaPoolList(): Promise<QaPoolListResult>;
|
|
204
|
+
/** Read effective QA pool governance config and `pending_count`. */
|
|
205
|
+
qaPoolConfig(): Promise<QaPoolConfigResult>;
|
|
206
|
+
/** Read-only: effective QA rule registry JSON (same shape as `qa_registry.json`). No auth. */
|
|
207
|
+
getQaRegistry(): Promise<QaRegistryResult>;
|
|
208
|
+
/**
|
|
209
|
+
* Vote on a pooled Unsure deploy. `voter` must be a governance administrator unless the node uses dev_open_voting.
|
|
210
|
+
* Params: tx_hash hex, voter account hex, `allow` | `reject` | `abstain`.
|
|
211
|
+
*/
|
|
212
|
+
qaPoolVote(txHashHex: string, voterHex: string, vote: 'allow' | 'reject' | 'abstain'): Promise<QaPoolVoteResult>;
|
|
213
|
+
/**
|
|
214
|
+
* Apply QA registry and pool governance config on the node (operator RPC).
|
|
215
|
+
* Params are full JSON documents as strings (same format as `qa_registry.json` / `qa_pool_config.json`).
|
|
216
|
+
* Requires `X-Boing-Operator` when the node has `BOING_OPERATOR_RPC_TOKEN` set.
|
|
217
|
+
*/
|
|
218
|
+
operatorApplyQaPolicy(registryJson: string, qaPoolConfigJson: string): Promise<OperatorApplyQaPolicyResult>;
|
|
219
|
+
qaCheck(hexBytecode: string, purposeCategory?: string, descriptionHash?: string, assetName?: string, assetSymbol?: string): Promise<QaCheckResponse>;
|
|
220
|
+
/** Request testnet BOING (only when node is started with --faucet-enable). Params: 32-byte account ID (hex). Rate limited per account. */
|
|
221
|
+
faucetRequest(hexAccountId: string): Promise<FaucetResult>;
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=client.d.ts.map
|