@1money/protocol-ts-sdk 1.0.14
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/.claude/settings.local.json +14 -0
- package/CLAUDE.md +77 -0
- package/README.md +600 -0
- package/es/api/accounts/index.d.ts +20 -0
- package/es/api/accounts/types.d.ts +9 -0
- package/es/api/chain/index.d.ts +12 -0
- package/es/api/chain/types.d.ts +3 -0
- package/es/api/checkpoints/index.d.ts +26 -0
- package/es/api/checkpoints/types.d.ts +33 -0
- package/es/api/constants.d.ts +9 -0
- package/es/api/index.d.ts +31 -0
- package/es/api/index.js +593 -0
- package/es/api/state/index.d.ts +12 -0
- package/es/api/state/types.d.ts +7 -0
- package/es/api/tokens/index.d.ts +62 -0
- package/es/api/tokens/types.d.ts +130 -0
- package/es/api/transactions/index.d.ts +35 -0
- package/es/api/transactions/types.d.ts +25 -0
- package/es/api/types.d.ts +18 -0
- package/es/client/core.d.ts +109 -0
- package/es/client/index.d.ts +21 -0
- package/es/client/index.js +373 -0
- package/es/index.d.ts +20 -0
- package/es/index.js +1490 -0
- package/es/utils/address.d.ts +15 -0
- package/es/utils/index.d.ts +6 -0
- package/es/utils/index.js +841 -0
- package/es/utils/interface.d.ts +7 -0
- package/es/utils/safePromise.d.ts +4 -0
- package/es/utils/sign.d.ts +15 -0
- package/es/utils/txHash.d.ts +2 -0
- package/es/utils/typeof.d.ts +2 -0
- package/lib/api/accounts/index.d.ts +20 -0
- package/lib/api/accounts/types.d.ts +9 -0
- package/lib/api/chain/index.d.ts +12 -0
- package/lib/api/chain/types.d.ts +3 -0
- package/lib/api/checkpoints/index.d.ts +26 -0
- package/lib/api/checkpoints/types.d.ts +33 -0
- package/lib/api/constants.d.ts +9 -0
- package/lib/api/index.d.ts +31 -0
- package/lib/api/index.js +692 -0
- package/lib/api/state/index.d.ts +12 -0
- package/lib/api/state/types.d.ts +7 -0
- package/lib/api/tokens/index.d.ts +62 -0
- package/lib/api/tokens/types.d.ts +130 -0
- package/lib/api/transactions/index.d.ts +35 -0
- package/lib/api/transactions/types.d.ts +25 -0
- package/lib/api/types.d.ts +18 -0
- package/lib/client/core.d.ts +109 -0
- package/lib/client/index.d.ts +21 -0
- package/lib/client/index.js +434 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +1591 -0
- package/lib/utils/address.d.ts +15 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +937 -0
- package/lib/utils/interface.d.ts +7 -0
- package/lib/utils/safePromise.d.ts +4 -0
- package/lib/utils/sign.d.ts +15 -0
- package/lib/utils/txHash.d.ts +2 -0
- package/lib/utils/typeof.d.ts +2 -0
- package/package.json +111 -0
- package/public/favicon.ico +0 -0
- package/public/logo.png +0 -0
- package/umd/1money-protocol-ts-sdk.min.js +2 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ZeroXString, Signature, Payload } from './interface';
|
|
2
|
+
/**
|
|
3
|
+
* RLP encode a payload into a digest
|
|
4
|
+
* @param payload Payload to encode
|
|
5
|
+
* @returns RLP encoded payload
|
|
6
|
+
*/
|
|
7
|
+
export declare function encodePayload(payload: Payload): Uint8Array<ArrayBufferLike>;
|
|
8
|
+
/**
|
|
9
|
+
* Sign a message using the provided private key
|
|
10
|
+
* @param payload Payload to sign
|
|
11
|
+
* @param privateKey Private key to sign with
|
|
12
|
+
* @returns Signature object with r, s, v components
|
|
13
|
+
*/
|
|
14
|
+
export declare function signMessage(payload: Payload, privateKey: ZeroXString): Promise<Signature>;
|
|
15
|
+
export declare function toHex(value: any): ZeroXString;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type TypeofResult = 'string' | 'number' | 'boolean' | 'bigint' | 'symbol' | 'object' | 'array' | 'function' | 'date' | 'regexp' | 'set' | 'map' | 'weakmap' | 'weakset' | 'error' | 'promise' | 'uint8array' | 'uint16array' | 'uint32array' | 'int8array' | 'int16array' | 'int32array' | 'arraybuffer' | 'null' | 'undefined';
|
|
2
|
+
export declare function _typeof(ele: any): TypeofResult;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AccountInfo, AssociatedTokenAccount } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Accounts API methods
|
|
4
|
+
*/
|
|
5
|
+
export declare const accountsApi: {
|
|
6
|
+
/**
|
|
7
|
+
* Get account nonce
|
|
8
|
+
* @param address Address of the account to lookup nonce for
|
|
9
|
+
* @returns Promise with account info response
|
|
10
|
+
*/
|
|
11
|
+
getNonce: (address: string) => import("../../client/index.js").PromiseWrapper<"custom", AccountInfo, AccountInfo, AccountInfo, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | AccountInfo, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<AccountInfo>;
|
|
12
|
+
/**
|
|
13
|
+
* Get associated token account
|
|
14
|
+
* @param address Address of the account to lookup associated token account for
|
|
15
|
+
* @param token Token address to lookup associated token account for
|
|
16
|
+
* @returns Promise with associated token account response
|
|
17
|
+
*/
|
|
18
|
+
getTokenAccount: (address: string, token: string) => import("../../client/index.js").PromiseWrapper<"custom", AssociatedTokenAccount, AssociatedTokenAccount, AssociatedTokenAccount, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | AssociatedTokenAccount, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<AssociatedTokenAccount>;
|
|
19
|
+
};
|
|
20
|
+
export default accountsApi;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChainIdResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Checkpoint API methods
|
|
4
|
+
*/
|
|
5
|
+
export declare const chainApi: {
|
|
6
|
+
/**
|
|
7
|
+
* Get the current chain id
|
|
8
|
+
* @returns Promise with chain id response
|
|
9
|
+
*/
|
|
10
|
+
getChainId: () => import("../../client/index.js").PromiseWrapper<"custom", ChainIdResponse, ChainIdResponse, ChainIdResponse, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | ChainIdResponse, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<ChainIdResponse>;
|
|
11
|
+
};
|
|
12
|
+
export default chainApi;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CheckpointNumberResponse, Checkpoint } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Checkpoint API methods
|
|
4
|
+
*/
|
|
5
|
+
export declare const checkpointsApi: {
|
|
6
|
+
/**
|
|
7
|
+
* Get the current checkpoint number
|
|
8
|
+
* @returns Promise with checkpoint number response
|
|
9
|
+
*/
|
|
10
|
+
getNumber: () => import("../../client/index.js").PromiseWrapper<"custom", CheckpointNumberResponse, CheckpointNumberResponse, CheckpointNumberResponse, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | CheckpointNumberResponse, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<CheckpointNumberResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Get checkpoint by hash
|
|
13
|
+
* @param hash Hash of the checkpoint to lookup
|
|
14
|
+
* @param full Whether to include full transaction details
|
|
15
|
+
* @returns Promise with checkpoint response
|
|
16
|
+
*/
|
|
17
|
+
getByHash: (hash: string, full?: boolean) => import("../../client/index.js").PromiseWrapper<"custom", Checkpoint, Checkpoint, Checkpoint, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Checkpoint, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Checkpoint>;
|
|
18
|
+
/**
|
|
19
|
+
* Get checkpoint by number
|
|
20
|
+
* @param number Number of the checkpoint to lookup
|
|
21
|
+
* @param full Whether to include full transaction details
|
|
22
|
+
* @returns Promise with checkpoint response
|
|
23
|
+
*/
|
|
24
|
+
getByNumber: (number: number | string, full?: boolean) => import("../../client/index.js").PromiseWrapper<"custom", Checkpoint, Checkpoint, Checkpoint, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Checkpoint, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Checkpoint>;
|
|
25
|
+
};
|
|
26
|
+
export default checkpointsApi;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { B256Schema, AddressSchema } from '../types';
|
|
2
|
+
export interface CheckpointNumberResponse {
|
|
3
|
+
number: number;
|
|
4
|
+
}
|
|
5
|
+
export interface Transaction {
|
|
6
|
+
hash: B256Schema;
|
|
7
|
+
chain_id: number;
|
|
8
|
+
from: AddressSchema;
|
|
9
|
+
nonce: number;
|
|
10
|
+
fee: number;
|
|
11
|
+
signature: {
|
|
12
|
+
r: string;
|
|
13
|
+
s: string;
|
|
14
|
+
v: number;
|
|
15
|
+
};
|
|
16
|
+
checkpoint_hash?: B256Schema;
|
|
17
|
+
checkpoint_number?: number;
|
|
18
|
+
transaction_index?: number;
|
|
19
|
+
}
|
|
20
|
+
export interface Header {
|
|
21
|
+
hash: B256Schema;
|
|
22
|
+
parent_hash: B256Schema;
|
|
23
|
+
state_root: B256Schema;
|
|
24
|
+
transactions_root: B256Schema;
|
|
25
|
+
receipts_root: B256Schema;
|
|
26
|
+
number: number;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
extra_data: string;
|
|
29
|
+
}
|
|
30
|
+
export interface Checkpoint extends Header {
|
|
31
|
+
size?: number;
|
|
32
|
+
transactions: Transaction[] | B256Schema[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const TESTNET_API_URL = "https://api.testnet.1money.network";
|
|
2
|
+
export declare const MAINNET_API_URL = "https://api.1money.network";
|
|
3
|
+
export declare const LOCAL_API_URL = "http://localhost:18555";
|
|
4
|
+
export declare const CHAIN_IDS: {
|
|
5
|
+
readonly MAINNET: 21210;
|
|
6
|
+
readonly TESTNET: 1212101;
|
|
7
|
+
readonly LOCAL: 1212101;
|
|
8
|
+
};
|
|
9
|
+
export declare const API_VERSION = "v1";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import accountsApi from './accounts';
|
|
2
|
+
import checkpointsApi from './checkpoints';
|
|
3
|
+
import tokensApi from './tokens';
|
|
4
|
+
import transactionsApi from './transactions';
|
|
5
|
+
import chainApi from './chain';
|
|
6
|
+
import stateApi from './state';
|
|
7
|
+
export * from './accounts/types';
|
|
8
|
+
export * from './tokens/types';
|
|
9
|
+
export * from './transactions/types';
|
|
10
|
+
export * from './checkpoints/types';
|
|
11
|
+
export * from './chain/types';
|
|
12
|
+
export * from './state/types';
|
|
13
|
+
/**
|
|
14
|
+
* API client for 1money network
|
|
15
|
+
* @param options Configuration options
|
|
16
|
+
* @param options.network Network to use (testnet, mainnet, local)
|
|
17
|
+
* @param options.timeout Request timeout in milliseconds
|
|
18
|
+
* @param options.chainId Custom chain ID (overrides the default for the selected network)
|
|
19
|
+
*/
|
|
20
|
+
export declare function api(options?: {
|
|
21
|
+
network?: 'testnet' | 'mainnet' | 'local';
|
|
22
|
+
timeout?: number;
|
|
23
|
+
}): {
|
|
24
|
+
accounts: typeof accountsApi;
|
|
25
|
+
checkpoints: typeof checkpointsApi;
|
|
26
|
+
tokens: typeof tokensApi;
|
|
27
|
+
transactions: typeof transactionsApi;
|
|
28
|
+
chain: typeof chainApi;
|
|
29
|
+
state: typeof stateApi;
|
|
30
|
+
};
|
|
31
|
+
export default api;
|