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,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional **native token deploy security** metadata (wizard parity with EVM “security features”).
|
|
3
|
+
*
|
|
4
|
+
* The default Boing **reference fungible** bytecode is minimal (`transfer` / single `mint_first`). DApps that
|
|
5
|
+
* ship **custom bytecode** can still commit the user’s security choices on-chain via **`description_hash`**
|
|
6
|
+
* (Blake3 over canonical JSON). Indexers, explorers, and QA reviewers can decode the same JSON shape.
|
|
7
|
+
*
|
|
8
|
+
* For the **secured** fungible, **`buildReferenceFungibleSecuredDeployMetaTx`** maps these fields into
|
|
9
|
+
* **`0xFD` init** storage (on-chain enforcement) when `nativeTokenSecurity` is passed — see
|
|
10
|
+
* **`referenceFungibleSecuredConfigFromNativeTokenSecurity`**. **`renounceOwnership`** is still metadata-only
|
|
11
|
+
* (admin must call renounce selector after deploy). **`timelock`** uses **`chainContext.chainHeight`** +
|
|
12
|
+
* **`timelockDelay`** as a **transfer-unlock block height**.
|
|
13
|
+
*
|
|
14
|
+
* Boing VM **`BlockHeight` (`0x40`)** and **`Timestamp` (`0x41`)** opcodes support time/block-gated rules.
|
|
15
|
+
*/
|
|
16
|
+
/** Mirrors boing.finance `DeployToken.jsx` `SECURITY_FEATURES` / wizard toggles (all optional on input). */
|
|
17
|
+
export type NativeTokenSecurityFeaturesInput = {
|
|
18
|
+
renounceMint?: boolean;
|
|
19
|
+
enableFreezing?: boolean;
|
|
20
|
+
enableBlacklist?: boolean;
|
|
21
|
+
maxTxAmount?: string;
|
|
22
|
+
renounceOwnership?: boolean;
|
|
23
|
+
antiBot?: boolean;
|
|
24
|
+
/** Cooldown between transfers (e.g. seconds); empty string means disabled. */
|
|
25
|
+
cooldownPeriod?: string;
|
|
26
|
+
antiWhale?: boolean;
|
|
27
|
+
pauseFunction?: boolean;
|
|
28
|
+
timelock?: boolean;
|
|
29
|
+
/** Admin timelock delay (dApp-defined units, often seconds). */
|
|
30
|
+
timelockDelay?: string;
|
|
31
|
+
maxWallet?: boolean;
|
|
32
|
+
maxWalletPercentage?: string;
|
|
33
|
+
};
|
|
34
|
+
/** Canonical JSON-ready object (every known key present). */
|
|
35
|
+
export type NativeTokenSecurityFeaturesNormalized = {
|
|
36
|
+
schema: 'boing.native_token_security.v1';
|
|
37
|
+
renounceMint: boolean;
|
|
38
|
+
enableFreezing: boolean;
|
|
39
|
+
enableBlacklist: boolean;
|
|
40
|
+
maxTxAmount: string;
|
|
41
|
+
renounceOwnership: boolean;
|
|
42
|
+
antiBot: boolean;
|
|
43
|
+
cooldownPeriod: string;
|
|
44
|
+
antiWhale: boolean;
|
|
45
|
+
pauseFunction: boolean;
|
|
46
|
+
timelock: boolean;
|
|
47
|
+
timelockDelay: string;
|
|
48
|
+
maxWallet: boolean;
|
|
49
|
+
maxWalletPercentage: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Stable object for hashing / logging (fixed key order via explicit construction).
|
|
53
|
+
*/
|
|
54
|
+
export declare function normalizeNativeTokenSecurity(input: NativeTokenSecurityFeaturesInput | undefined): NativeTokenSecurityFeaturesNormalized;
|
|
55
|
+
/**
|
|
56
|
+
* Blake3-256 digest of UTF-8 JSON, as **`0x` + 64 hex** (fits `description_hash` on `contract_deploy_meta`).
|
|
57
|
+
*/
|
|
58
|
+
export declare function descriptionHashHexFromNativeTokenSecurity(input: NativeTokenSecurityFeaturesInput | undefined): `0x${string}`;
|
|
59
|
+
//# sourceMappingURL=nativeTokenSecurity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeTokenSecurity.d.ts","sourceRoot":"","sources":["../src/nativeTokenSecurity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,4GAA4G;AAC5G,MAAM,MAAM,gCAAgC,GAAG;IAC7C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,qCAAqC,GAAG;IAClD,MAAM,EAAE,gCAAgC,CAAC;IACzC,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AAWF;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,gCAAgC,GAAG,SAAS,GAClD,qCAAqC,CAiBvC;AAED;;GAEG;AACH,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,gCAAgC,GAAG,SAAS,GAClD,KAAK,MAAM,EAAE,CASf"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional **native token deploy security** metadata (wizard parity with EVM “security features”).
|
|
3
|
+
*
|
|
4
|
+
* The default Boing **reference fungible** bytecode is minimal (`transfer` / single `mint_first`). DApps that
|
|
5
|
+
* ship **custom bytecode** can still commit the user’s security choices on-chain via **`description_hash`**
|
|
6
|
+
* (Blake3 over canonical JSON). Indexers, explorers, and QA reviewers can decode the same JSON shape.
|
|
7
|
+
*
|
|
8
|
+
* For the **secured** fungible, **`buildReferenceFungibleSecuredDeployMetaTx`** maps these fields into
|
|
9
|
+
* **`0xFD` init** storage (on-chain enforcement) when `nativeTokenSecurity` is passed — see
|
|
10
|
+
* **`referenceFungibleSecuredConfigFromNativeTokenSecurity`**. **`renounceOwnership`** is still metadata-only
|
|
11
|
+
* (admin must call renounce selector after deploy). **`timelock`** uses **`chainContext.chainHeight`** +
|
|
12
|
+
* **`timelockDelay`** as a **transfer-unlock block height**.
|
|
13
|
+
*
|
|
14
|
+
* Boing VM **`BlockHeight` (`0x40`)** and **`Timestamp` (`0x41`)** opcodes support time/block-gated rules.
|
|
15
|
+
*/
|
|
16
|
+
import { blake3 } from '@noble/hashes/blake3';
|
|
17
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
18
|
+
function bool(v, defaultFalse = false) {
|
|
19
|
+
if (v === undefined || v === null)
|
|
20
|
+
return defaultFalse;
|
|
21
|
+
return Boolean(v);
|
|
22
|
+
}
|
|
23
|
+
function str(v) {
|
|
24
|
+
return typeof v === 'string' ? v.trim() : '';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Stable object for hashing / logging (fixed key order via explicit construction).
|
|
28
|
+
*/
|
|
29
|
+
export function normalizeNativeTokenSecurity(input) {
|
|
30
|
+
return {
|
|
31
|
+
schema: 'boing.native_token_security.v1',
|
|
32
|
+
renounceMint: bool(input?.renounceMint),
|
|
33
|
+
enableFreezing: bool(input?.enableFreezing),
|
|
34
|
+
enableBlacklist: bool(input?.enableBlacklist),
|
|
35
|
+
maxTxAmount: str(input?.maxTxAmount),
|
|
36
|
+
renounceOwnership: bool(input?.renounceOwnership),
|
|
37
|
+
antiBot: bool(input?.antiBot),
|
|
38
|
+
cooldownPeriod: str(input?.cooldownPeriod),
|
|
39
|
+
antiWhale: bool(input?.antiWhale),
|
|
40
|
+
pauseFunction: bool(input?.pauseFunction),
|
|
41
|
+
timelock: bool(input?.timelock),
|
|
42
|
+
timelockDelay: str(input?.timelockDelay),
|
|
43
|
+
maxWallet: bool(input?.maxWallet),
|
|
44
|
+
maxWalletPercentage: str(input?.maxWalletPercentage),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Blake3-256 digest of UTF-8 JSON, as **`0x` + 64 hex** (fits `description_hash` on `contract_deploy_meta`).
|
|
49
|
+
*/
|
|
50
|
+
export function descriptionHashHexFromNativeTokenSecurity(input) {
|
|
51
|
+
const norm = normalizeNativeTokenSecurity(input);
|
|
52
|
+
const json = JSON.stringify(norm);
|
|
53
|
+
const digest = blake3(new TextEncoder().encode(json));
|
|
54
|
+
const h = bytesToHex(digest);
|
|
55
|
+
if (h.length !== 64) {
|
|
56
|
+
throw new Error('descriptionHashHexFromNativeTokenSecurity: unexpected digest length');
|
|
57
|
+
}
|
|
58
|
+
return `0x${h}`;
|
|
59
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture a JSON-serializable snapshot of RPC endpoint identity + capabilities (CI / local dev pins).
|
|
3
|
+
*/
|
|
4
|
+
import type { BoingClient } from './client.js';
|
|
5
|
+
import type { BoingNetworkProfile } from './types.js';
|
|
6
|
+
/** Fetch health, optional network info, supported methods, and {@link BoingClient.preflightRpc}. */
|
|
7
|
+
export declare function captureBoingNetworkProfile(client: BoingClient): Promise<BoingNetworkProfile>;
|
|
8
|
+
//# sourceMappingURL=networkProfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networkProfile.d.ts","sourceRoot":"","sources":["../src/networkProfile.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,oGAAoG;AACpG,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsBlG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture a JSON-serializable snapshot of RPC endpoint identity + capabilities (CI / local dev pins).
|
|
3
|
+
*/
|
|
4
|
+
/** Fetch health, optional network info, supported methods, and {@link BoingClient.preflightRpc}. */
|
|
5
|
+
export async function captureBoingNetworkProfile(client) {
|
|
6
|
+
const preflight = await client.preflightRpc();
|
|
7
|
+
let network_info = null;
|
|
8
|
+
try {
|
|
9
|
+
network_info = await client.getNetworkInfo();
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
network_info = null;
|
|
13
|
+
}
|
|
14
|
+
let supported_methods = null;
|
|
15
|
+
try {
|
|
16
|
+
supported_methods = await client.rpcSupportedMethods();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
supported_methods = null;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
captured_at_ms: Date.now(),
|
|
23
|
+
base_url: client.getBaseUrl(),
|
|
24
|
+
health: preflight.health,
|
|
25
|
+
network_info,
|
|
26
|
+
supported_methods,
|
|
27
|
+
preflight,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-oriented **`GET /ws`** **newHeads** subscriber (handshake + JSON text frames).
|
|
3
|
+
* Uses global **`WebSocket`**; safe to omit in SSR bundles if you never instantiate.
|
|
4
|
+
*/
|
|
5
|
+
export type BoingNewHeadsWsState = 'idle' | 'connecting' | 'subscribed' | 'reconnecting' | 'closed' | 'error';
|
|
6
|
+
export interface BoingNewHeadsWsOptions {
|
|
7
|
+
/** WebSocket path on the RPC host (default **`/ws`**). */
|
|
8
|
+
path?: string;
|
|
9
|
+
/** First reconnect delay in ms (default **1000**); doubles up to **`maxReconnectDelayMs`**. */
|
|
10
|
+
initialReconnectDelayMs?: number;
|
|
11
|
+
maxReconnectDelayMs?: number;
|
|
12
|
+
/** Cap manual reconnect attempts after close (**default 8**). */
|
|
13
|
+
maxReconnectAttempts?: number;
|
|
14
|
+
onState?: (s: BoingNewHeadsWsState) => void;
|
|
15
|
+
/** Fired for server **`newHead`** payloads (parsed JSON). */
|
|
16
|
+
onHead?: (payload: unknown) => void;
|
|
17
|
+
/** Subscribe handshake succeeded. */
|
|
18
|
+
onSubscribed?: () => void;
|
|
19
|
+
onError?: (err: unknown) => void;
|
|
20
|
+
}
|
|
21
|
+
/** Build **`ws:` / `wss:`** URL for the node’s WebSocket endpoint. */
|
|
22
|
+
export declare function boingRpcWebSocketUrl(rpcBaseUrl: string, path?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Thin wrapper around **`WebSocket`** with reconnect and typed callbacks.
|
|
25
|
+
*/
|
|
26
|
+
export declare class BoingNewHeadsWs {
|
|
27
|
+
private readonly rpcBaseUrl;
|
|
28
|
+
private readonly options;
|
|
29
|
+
private ws;
|
|
30
|
+
private state;
|
|
31
|
+
private reconnectAttempt;
|
|
32
|
+
private reconnectTimer;
|
|
33
|
+
private closedByUser;
|
|
34
|
+
constructor(rpcBaseUrl: string, options?: BoingNewHeadsWsOptions);
|
|
35
|
+
private setState;
|
|
36
|
+
getState(): BoingNewHeadsWsState;
|
|
37
|
+
/** Open socket and send subscribe handshake. */
|
|
38
|
+
connect(): void;
|
|
39
|
+
private scheduleReconnect;
|
|
40
|
+
/** Stop reconnecting and close the socket. */
|
|
41
|
+
close(): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=newHeadsWs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"newHeadsWs.d.ts","sourceRoot":"","sources":["../src/newHeadsWs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,QAAQ,GACR,OAAO,CAAC;AAEZ,MAAM,WAAW,sBAAsB;IACrC,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+FAA+F;IAC/F,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC5C,6DAA6D;IAC7D,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACpC,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;CAClC;AAED,sEAAsE;AACtE,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,MAAM,CAU7E;AAID;;GAEG;AACH,qBAAa,eAAe;IAQxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,YAAY,CAAS;gBAGV,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,sBAA2B;IAGvD,OAAO,CAAC,QAAQ;IAKhB,QAAQ,IAAI,oBAAoB;IAIhC,gDAAgD;IAChD,OAAO,IAAI,IAAI;IAqEf,OAAO,CAAC,iBAAiB;IAmBzB,8CAA8C;IAC9C,KAAK,IAAI,IAAI;CAgBd"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-oriented **`GET /ws`** **newHeads** subscriber (handshake + JSON text frames).
|
|
3
|
+
* Uses global **`WebSocket`**; safe to omit in SSR bundles if you never instantiate.
|
|
4
|
+
*/
|
|
5
|
+
/** Build **`ws:` / `wss:`** URL for the node’s WebSocket endpoint. */
|
|
6
|
+
export function boingRpcWebSocketUrl(rpcBaseUrl, path = '/ws') {
|
|
7
|
+
const trimmed = rpcBaseUrl.replace(/\/$/, '');
|
|
8
|
+
const withProto = trimmed.includes('://') ? trimmed : `http://${trimmed}`;
|
|
9
|
+
const u = new URL(withProto);
|
|
10
|
+
u.protocol = u.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
11
|
+
const p = path.startsWith('/') ? path : `/${path}`;
|
|
12
|
+
u.pathname = p;
|
|
13
|
+
u.search = '';
|
|
14
|
+
u.hash = '';
|
|
15
|
+
return u.toString();
|
|
16
|
+
}
|
|
17
|
+
const SUBSCRIBE = JSON.stringify({ type: 'subscribe', channel: 'newHeads' });
|
|
18
|
+
/**
|
|
19
|
+
* Thin wrapper around **`WebSocket`** with reconnect and typed callbacks.
|
|
20
|
+
*/
|
|
21
|
+
export class BoingNewHeadsWs {
|
|
22
|
+
constructor(rpcBaseUrl, options = {}) {
|
|
23
|
+
this.rpcBaseUrl = rpcBaseUrl;
|
|
24
|
+
this.options = options;
|
|
25
|
+
this.ws = null;
|
|
26
|
+
this.state = 'idle';
|
|
27
|
+
this.reconnectAttempt = 0;
|
|
28
|
+
this.reconnectTimer = null;
|
|
29
|
+
this.closedByUser = false;
|
|
30
|
+
}
|
|
31
|
+
setState(s) {
|
|
32
|
+
this.state = s;
|
|
33
|
+
this.options.onState?.(s);
|
|
34
|
+
}
|
|
35
|
+
getState() {
|
|
36
|
+
return this.state;
|
|
37
|
+
}
|
|
38
|
+
/** Open socket and send subscribe handshake. */
|
|
39
|
+
connect() {
|
|
40
|
+
const WS = globalThis.WebSocket;
|
|
41
|
+
if (WS == null) {
|
|
42
|
+
const err = new Error('WebSocket is not available in this environment');
|
|
43
|
+
this.setState('error');
|
|
44
|
+
this.options.onError?.(err);
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
this.closedByUser = false;
|
|
48
|
+
if (this.reconnectTimer != null) {
|
|
49
|
+
clearTimeout(this.reconnectTimer);
|
|
50
|
+
this.reconnectTimer = null;
|
|
51
|
+
}
|
|
52
|
+
const path = this.options.path ?? '/ws';
|
|
53
|
+
const url = boingRpcWebSocketUrl(this.rpcBaseUrl, path);
|
|
54
|
+
this.setState(this.reconnectAttempt > 0 ? 'reconnecting' : 'connecting');
|
|
55
|
+
const ws = new WS(url);
|
|
56
|
+
this.ws = ws;
|
|
57
|
+
ws.onopen = () => {
|
|
58
|
+
try {
|
|
59
|
+
ws.send(SUBSCRIBE);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
this.options.onError?.(e);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
ws.onmessage = (ev) => {
|
|
66
|
+
if (typeof ev.data !== 'string')
|
|
67
|
+
return;
|
|
68
|
+
let j;
|
|
69
|
+
try {
|
|
70
|
+
j = JSON.parse(ev.data);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!j || typeof j !== 'object')
|
|
76
|
+
return;
|
|
77
|
+
const o = j;
|
|
78
|
+
if (o.type === 'subscribed' && o.channel === 'newHeads') {
|
|
79
|
+
this.reconnectAttempt = 0;
|
|
80
|
+
this.setState('subscribed');
|
|
81
|
+
this.options.onSubscribed?.();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (o.type === 'newHead') {
|
|
85
|
+
this.options.onHead?.(j);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (o.type === 'error') {
|
|
89
|
+
this.options.onError?.(j);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
ws.onerror = () => {
|
|
93
|
+
this.options.onError?.(new Error('WebSocket error'));
|
|
94
|
+
};
|
|
95
|
+
ws.onclose = () => {
|
|
96
|
+
this.ws = null;
|
|
97
|
+
if (this.closedByUser) {
|
|
98
|
+
this.setState('closed');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.scheduleReconnect();
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
scheduleReconnect() {
|
|
105
|
+
const maxAttempts = this.options.maxReconnectAttempts ?? 8;
|
|
106
|
+
if (this.reconnectAttempt >= maxAttempts) {
|
|
107
|
+
this.setState('error');
|
|
108
|
+
this.options.onError?.(new Error('WebSocket: max reconnect attempts reached'));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const base = this.options.initialReconnectDelayMs ?? 1000;
|
|
112
|
+
const maxDelay = this.options.maxReconnectDelayMs ?? 30000;
|
|
113
|
+
const delay = Math.min(maxDelay, base * Math.pow(2, this.reconnectAttempt));
|
|
114
|
+
this.reconnectAttempt += 1;
|
|
115
|
+
this.setState('reconnecting');
|
|
116
|
+
this.reconnectTimer = setTimeout(() => {
|
|
117
|
+
this.reconnectTimer = null;
|
|
118
|
+
this.connect();
|
|
119
|
+
}, delay);
|
|
120
|
+
}
|
|
121
|
+
/** Stop reconnecting and close the socket. */
|
|
122
|
+
close() {
|
|
123
|
+
this.closedByUser = true;
|
|
124
|
+
if (this.reconnectTimer != null) {
|
|
125
|
+
clearTimeout(this.reconnectTimer);
|
|
126
|
+
this.reconnectTimer = null;
|
|
127
|
+
}
|
|
128
|
+
if (this.ws != null) {
|
|
129
|
+
try {
|
|
130
|
+
this.ws.close();
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
/* ignore */
|
|
134
|
+
}
|
|
135
|
+
this.ws = null;
|
|
136
|
+
}
|
|
137
|
+
this.setState('closed');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fail fast before heavy flows (swap UI, indexer tick) when the RPC environment is unhealthy.
|
|
3
|
+
*/
|
|
4
|
+
import type { BoingClient } from './client.js';
|
|
5
|
+
import { type BoingRpcDoctorOptions, type BoingRpcDoctorResult } from './rpcDoctor.js';
|
|
6
|
+
export declare class BoingRpcPreflightError extends Error {
|
|
7
|
+
readonly doctor: BoingRpcDoctorResult;
|
|
8
|
+
constructor(doctor: BoingRpcDoctorResult);
|
|
9
|
+
}
|
|
10
|
+
export declare function isBoingRpcPreflightError(e: unknown): e is BoingRpcPreflightError;
|
|
11
|
+
/**
|
|
12
|
+
* Runs {@link doctorBoingRpcEnvironment}; throws {@link BoingRpcPreflightError} when **`ok`** is false.
|
|
13
|
+
* Use in dApp “connect” or before starting polling loops.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertBoingRpcEnvironment(client: BoingClient, options?: BoingRpcDoctorOptions): Promise<BoingRpcDoctorResult>;
|
|
16
|
+
//# sourceMappingURL=preflightGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflightGate.d.ts","sourceRoot":"","sources":["../src/preflightGate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAA6B,KAAK,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAElH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;gBAE1B,MAAM,EAAE,oBAAoB;CAUzC;AAED,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,sBAAsB,CAEhF;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CAM/B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fail fast before heavy flows (swap UI, indexer tick) when the RPC environment is unhealthy.
|
|
3
|
+
*/
|
|
4
|
+
import { doctorBoingRpcEnvironment } from './rpcDoctor.js';
|
|
5
|
+
export class BoingRpcPreflightError extends Error {
|
|
6
|
+
constructor(doctor) {
|
|
7
|
+
const msg = doctor.messages.length > 0
|
|
8
|
+
? doctor.messages.join('\n')
|
|
9
|
+
: 'RPC environment check failed (see BoingRpcPreflightError.doctor).';
|
|
10
|
+
super(msg);
|
|
11
|
+
this.name = 'BoingRpcPreflightError';
|
|
12
|
+
this.doctor = doctor;
|
|
13
|
+
Object.setPrototypeOf(this, BoingRpcPreflightError.prototype);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function isBoingRpcPreflightError(e) {
|
|
17
|
+
return e instanceof BoingRpcPreflightError;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Runs {@link doctorBoingRpcEnvironment}; throws {@link BoingRpcPreflightError} when **`ok`** is false.
|
|
21
|
+
* Use in dApp “connect” or before starting polling loops.
|
|
22
|
+
*/
|
|
23
|
+
export async function assertBoingRpcEnvironment(client, options) {
|
|
24
|
+
const doctor = await doctorBoingRpcEnvironment(client, options);
|
|
25
|
+
if (!doctor.ok) {
|
|
26
|
+
throw new BoingRpcPreflightError(doctor);
|
|
27
|
+
}
|
|
28
|
+
return doctor;
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for execution logs on receipts and blocks (no `address` field — use `boing_getLogs` / {@link BoingClient.getLogs} when you need attributed contract ids).
|
|
3
|
+
*/
|
|
4
|
+
import type { Block, ExecutionLog, ExecutionReceipt } from './types.js';
|
|
5
|
+
/** Normalize one 32-byte topic to lowercase `0x` + 64 hex (throws if invalid). */
|
|
6
|
+
export declare function normalizeTopicWord(topic: string): string;
|
|
7
|
+
/** Normalize `ExecutionLog` topics and data to lowercase hex with `0x`. */
|
|
8
|
+
export declare function normalizeExecutionLog(log: ExecutionLog): ExecutionLog;
|
|
9
|
+
/** `topics[0]` after normalize, or `undefined`. */
|
|
10
|
+
export declare function logTopic0(log: ExecutionLog): string | undefined;
|
|
11
|
+
export interface ReceiptLogRef {
|
|
12
|
+
receipt: ExecutionReceipt;
|
|
13
|
+
log: ExecutionLog;
|
|
14
|
+
logIndex: number;
|
|
15
|
+
}
|
|
16
|
+
/** Yield each log in a receipt (empty if none). */
|
|
17
|
+
export declare function iterReceiptLogs(receipt: ExecutionReceipt): Generator<ReceiptLogRef>;
|
|
18
|
+
/**
|
|
19
|
+
* Topic filter semantics (common log-RPC shape): `filter[i]` null/undefined = wildcard; otherwise exact match on `topics[i]` (normalized).
|
|
20
|
+
*/
|
|
21
|
+
export declare function logMatchesTopicFilter(log: ExecutionLog, filter: (string | null | undefined)[]): boolean;
|
|
22
|
+
/** Optional `topic0` filter on receipt logs. */
|
|
23
|
+
export declare function filterReceiptLogsByTopic0(receipt: ExecutionReceipt, topic0: string): ExecutionLog[];
|
|
24
|
+
/**
|
|
25
|
+
* Walk `block.receipts` (same order as `transactions`) and emit every log with receipt context.
|
|
26
|
+
* Skips `null` receipt slots.
|
|
27
|
+
*/
|
|
28
|
+
export declare function iterBlockReceiptLogs(block: Block): Generator<ReceiptLogRef>;
|
|
29
|
+
//# sourceMappingURL=receiptLogs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"receiptLogs.d.ts","sourceRoot":"","sources":["../src/receiptLogs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAIxE,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAKrE;AAED,mDAAmD;AACnD,wBAAgB,SAAS,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAG/D;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,GAAG,EAAE,YAAY,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mDAAmD;AACnD,wBAAiB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,CAAC,aAAa,CAAC,CAIpF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,OAAO,CASvG;AAED,gDAAgD;AAChD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,MAAM,GACb,YAAY,EAAE,CAGhB;AAED;;;GAGG;AACH,wBAAiB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC,aAAa,CAAC,CAO5E"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for execution logs on receipts and blocks (no `address` field — use `boing_getLogs` / {@link BoingClient.getLogs} when you need attributed contract ids).
|
|
3
|
+
*/
|
|
4
|
+
import { ensureHex } from './hex.js';
|
|
5
|
+
const TOPIC_HEX_RE = /^[0-9a-fA-F]{64}$/;
|
|
6
|
+
/** Normalize one 32-byte topic to lowercase `0x` + 64 hex (throws if invalid). */
|
|
7
|
+
export function normalizeTopicWord(topic) {
|
|
8
|
+
const raw = topic.trim().replace(/^0x/i, '');
|
|
9
|
+
if (raw.length !== 64 || !TOPIC_HEX_RE.test(raw)) {
|
|
10
|
+
throw new Error(`Topic must be 32 bytes (64 hex chars), got ${raw.length}`);
|
|
11
|
+
}
|
|
12
|
+
return '0x' + raw.toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
/** Normalize `ExecutionLog` topics and data to lowercase hex with `0x`. */
|
|
15
|
+
export function normalizeExecutionLog(log) {
|
|
16
|
+
return {
|
|
17
|
+
topics: log.topics.map((t) => normalizeTopicWord(t)),
|
|
18
|
+
data: ensureHex(log.data.trim().replace(/^0X/i, '0x')).toLowerCase(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** `topics[0]` after normalize, or `undefined`. */
|
|
22
|
+
export function logTopic0(log) {
|
|
23
|
+
const t0 = log.topics[0];
|
|
24
|
+
return t0 != null ? normalizeTopicWord(t0) : undefined;
|
|
25
|
+
}
|
|
26
|
+
/** Yield each log in a receipt (empty if none). */
|
|
27
|
+
export function* iterReceiptLogs(receipt) {
|
|
28
|
+
for (let logIndex = 0; logIndex < receipt.logs.length; logIndex++) {
|
|
29
|
+
yield { receipt, log: receipt.logs[logIndex], logIndex };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Topic filter semantics (common log-RPC shape): `filter[i]` null/undefined = wildcard; otherwise exact match on `topics[i]` (normalized).
|
|
34
|
+
*/
|
|
35
|
+
export function logMatchesTopicFilter(log, filter) {
|
|
36
|
+
for (let i = 0; i < filter.length; i++) {
|
|
37
|
+
const want = filter[i];
|
|
38
|
+
if (want == null)
|
|
39
|
+
continue;
|
|
40
|
+
const a = log.topics[i];
|
|
41
|
+
if (a == null)
|
|
42
|
+
return false;
|
|
43
|
+
if (normalizeTopicWord(a) !== normalizeTopicWord(want))
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
/** Optional `topic0` filter on receipt logs. */
|
|
49
|
+
export function filterReceiptLogsByTopic0(receipt, topic0) {
|
|
50
|
+
const want = normalizeTopicWord(topic0);
|
|
51
|
+
return receipt.logs.filter((log) => logTopic0(log) === want);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Walk `block.receipts` (same order as `transactions`) and emit every log with receipt context.
|
|
55
|
+
* Skips `null` receipt slots.
|
|
56
|
+
*/
|
|
57
|
+
export function* iterBlockReceiptLogs(block) {
|
|
58
|
+
const receipts = block.receipts;
|
|
59
|
+
if (receipts == null)
|
|
60
|
+
return;
|
|
61
|
+
for (const receipt of receipts) {
|
|
62
|
+
if (receipt == null)
|
|
63
|
+
continue;
|
|
64
|
+
yield* iterReceiptLogs(receipt);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build **`0xFD` + init** deploy payloads for the secured reference fungible, matching
|
|
3
|
+
* `boing_execution::reference_fungible_secured_deploy_bytecode` / init layout.
|
|
4
|
+
*
|
|
5
|
+
* Runtime bytes are pinned from `defaultReferenceFungibleSecuredRuntimeBytecodeHex.ts`
|
|
6
|
+
* (regenerated with `embed-reference-fungible-secured-template-hex.mjs`).
|
|
7
|
+
*/
|
|
8
|
+
import { type NativeTokenSecurityFeaturesInput } from './nativeTokenSecurity.js';
|
|
9
|
+
/** Mirrors `reference_fungible_secured` flag words (u32). */
|
|
10
|
+
export declare const FLAG_DENYLIST = 1;
|
|
11
|
+
export declare const FLAG_MAX_TX = 2;
|
|
12
|
+
export declare const FLAG_MAX_WALLET = 4;
|
|
13
|
+
export declare const FLAG_ANTI_BOT = 8;
|
|
14
|
+
export declare const FLAG_COOLDOWN = 16;
|
|
15
|
+
export declare const FLAG_NO_MINT = 32;
|
|
16
|
+
export declare const FLAG_TRANSFER_UNLOCK = 64;
|
|
17
|
+
export type ReferenceFungibleSecuredConfigBytes = {
|
|
18
|
+
flags: number;
|
|
19
|
+
maxTx: bigint;
|
|
20
|
+
maxWallet: bigint;
|
|
21
|
+
antiBotExtraBlocks: bigint;
|
|
22
|
+
antiBotMaxAmount: bigint;
|
|
23
|
+
cooldownSecs: bigint;
|
|
24
|
+
transferUnlockHeight: bigint;
|
|
25
|
+
initialPaused: boolean;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Init bytecode only (no `0xFD` prefix), matching `reference_fungible_secured_init_bytecode`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function referenceFungibleSecuredInitBytecode(config: ReferenceFungibleSecuredConfigBytes, runtime: Uint8Array): Uint8Array;
|
|
31
|
+
/** Full deploy: `0xFD || init` (init `RETURN`s runtime). */
|
|
32
|
+
export declare function referenceFungibleSecuredDeployBytecode(config: ReferenceFungibleSecuredConfigBytes, runtime?: Uint8Array): Uint8Array;
|
|
33
|
+
export declare function referenceFungibleSecuredDeployBytecodeHex(config: ReferenceFungibleSecuredConfigBytes, runtime?: Uint8Array): `0x${string}`;
|
|
34
|
+
export type SecuredWizardBuildContext = {
|
|
35
|
+
/**
|
|
36
|
+
* Current height from `boing_chainHeight` — **required** when `timelock` is enabled in
|
|
37
|
+
* `nativeTokenSecurity` so `transfer_unlock_height` can be set (`FLAG_TRANSFER_UNLOCK`).
|
|
38
|
+
*/
|
|
39
|
+
chainHeight?: bigint;
|
|
40
|
+
/**
|
|
41
|
+
* Total supply (base units) planned for the initial `mint_first`, used with `maxWalletPercentage`
|
|
42
|
+
* / anti-whale percentage to derive `max_wallet`.
|
|
43
|
+
*/
|
|
44
|
+
mintFirstTotalSupplyWei?: bigint;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Map wizard / `boing.native_token_security.v1` fields to secured init storage (on-chain enforcement).
|
|
48
|
+
*
|
|
49
|
+
* - **renounceOwnership**: not applied at deploy (admin is deployer); use admin `0x05` after deploy.
|
|
50
|
+
* - **timelock**: maps to transfer-unlock **block height** = `chainHeight + timelockDelay` (both decimals).
|
|
51
|
+
*/
|
|
52
|
+
export declare function referenceFungibleSecuredConfigFromNativeTokenSecurity(input: NativeTokenSecurityFeaturesInput | undefined, ctx?: SecuredWizardBuildContext): ReferenceFungibleSecuredConfigBytes;
|
|
53
|
+
export declare function buildReferenceFungibleSecuredDeployBytecodeHexFromNativeTokenSecurity(input: NativeTokenSecurityFeaturesInput | undefined, ctx?: SecuredWizardBuildContext): `0x${string}`;
|
|
54
|
+
//# sourceMappingURL=referenceFungibleSecuredDeployBytecode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referenceFungibleSecuredDeployBytecode.d.ts","sourceRoot":"","sources":["../src/referenceFungibleSecuredDeployBytecode.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,0BAA0B,CAAC;AAqBlC,6DAA6D;AAC7D,eAAO,MAAM,aAAa,IAAO,CAAC;AAClC,eAAO,MAAM,WAAW,IAAO,CAAC;AAChC,eAAO,MAAM,eAAe,IAAO,CAAC;AACpC,eAAO,MAAM,aAAa,IAAO,CAAC;AAClC,eAAO,MAAM,aAAa,KAAO,CAAC;AAClC,eAAO,MAAM,YAAY,KAAO,CAAC;AACjC,eAAO,MAAM,oBAAoB,KAAO,CAAC;AAEzC,MAAM,MAAM,mCAAmC,GAAG;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAgFF;;GAEG;AACH,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,mCAAmC,EAC3C,OAAO,EAAE,UAAU,GAClB,UAAU,CAgDZ;AAED,4DAA4D;AAC5D,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,mCAAmC,EAC3C,OAAO,CAAC,EAAE,UAAU,GACnB,UAAU,CAMZ;AAED,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,mCAAmC,EAC3C,OAAO,CAAC,EAAE,UAAU,GACnB,KAAK,MAAM,EAAE,CAEf;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AA4BF;;;;;GAKG;AACH,wBAAgB,qDAAqD,CACnE,KAAK,EAAE,gCAAgC,GAAG,SAAS,EACnD,GAAG,GAAE,yBAA8B,GAClC,mCAAmC,CAoFrC;AAED,wBAAgB,qEAAqE,CACnF,KAAK,EAAE,gCAAgC,GAAG,SAAS,EACnD,GAAG,GAAE,yBAA8B,GAClC,KAAK,MAAM,EAAE,CAGf"}
|