@dynamic-labs-wallet/node-ton 0.0.0 → 0.0.255

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1 +1,39 @@
1
- { "name": "@dynamic-labs-wallet/node-ton", "version": "0.0.0" }
1
+ {
2
+ "name": "@dynamic-labs-wallet/node-ton",
3
+ "version": "0.0.255",
4
+ "license": "MIT",
5
+ "type": "module",
6
+ "dependencies": {
7
+ "@dynamic-labs-wallet/core": "0.0.255",
8
+ "@dynamic-labs-wallet/node": "0.0.255",
9
+ "@dynamic-labs/logger": "^4.25.3",
10
+ "@ton/crypto": "^3.3.0",
11
+ "@ton/ton": "^16.0.0",
12
+ "axios": "1.13.2"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "nx": {
18
+ "sourceRoot": "packages/node-ton/src",
19
+ "projectType": "library",
20
+ "name": "node-ton",
21
+ "targets": {
22
+ "build": {}
23
+ }
24
+ },
25
+ "main": "./index.cjs.js",
26
+ "module": "./index.esm.js",
27
+ "types": "./index.esm.d.ts",
28
+ "exports": {
29
+ "./package.json": "./package.json",
30
+ ".": {
31
+ "types": "./index.esm.d.ts",
32
+ "import": "./index.esm.js",
33
+ "require": "./index.cjs.js"
34
+ }
35
+ },
36
+ "devDependencies": {
37
+ "@types/http-errors": "^2.0.0"
38
+ }
39
+ }
@@ -0,0 +1,126 @@
1
+ import { DynamicWalletClient, type DynamicWalletClientProps, type Ed25519KeygenResult, type ServerKeyShare, type ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';
2
+ export declare class DynamicTonWalletClient extends DynamicWalletClient {
3
+ readonly chainName = "TON";
4
+ constructor({ environmentId, baseApiUrl, baseMPCRelayApiUrl, debug, enableMPCAccelerator, }: DynamicWalletClientProps);
5
+ /**
6
+ * Creates a new wallet account and stores the key shares in the wallet map.
7
+ * @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
8
+ * @param password - The password to use for the wallet.
9
+ * @param onError - The function to call if an error occurs.
10
+ * @param backUpToClientShareService - Whether to back up the external server key shares to the client share service. By default, it is false.
11
+ * @returns The account address, public key hex, raw public key, external server key shares, and wallet id.
12
+ */
13
+ createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToClientShareService, }: {
14
+ thresholdSignatureScheme: ThresholdSignatureScheme;
15
+ password?: string;
16
+ onError?: (error: Error) => void;
17
+ backUpToClientShareService?: boolean;
18
+ }): Promise<{
19
+ accountAddress: string;
20
+ publicKeyHex: string;
21
+ rawPublicKey: Uint8Array | string;
22
+ externalServerKeyShares: ServerKeyShare[];
23
+ walletId: string;
24
+ }>;
25
+ /**
26
+ * Signs a message using MPC
27
+ * @param message - The message to sign
28
+ * @param accountAddress - The account address to sign with
29
+ * @param password - The password for encrypted backup shares
30
+ * @param externalServerKeyShares - The external server key shares
31
+ * @param onError - The function to call if an error occurs
32
+ * @returns The signature as a base64 string
33
+ */
34
+ signMessage({ message, accountAddress, password, externalServerKeyShares, onError, }: {
35
+ message: string;
36
+ accountAddress: string;
37
+ password?: string;
38
+ externalServerKeyShares?: ServerKeyShare[];
39
+ onError?: (error: Error) => void;
40
+ }): Promise<string>;
41
+ /**
42
+ * Signs a transaction using MPC
43
+ * @param senderAddress - The sender address
44
+ * @param transaction - The serialized transaction to sign
45
+ * @param password - The password for encrypted backup shares
46
+ * @param externalServerKeyShares - The external server key shares
47
+ * @param onError - The function to call if an error occurs
48
+ * @returns The signature as a base64 string
49
+ */
50
+ signTransaction({ senderAddress, transaction, password, externalServerKeyShares, onError, }: {
51
+ senderAddress: string;
52
+ transaction: string;
53
+ password?: string;
54
+ externalServerKeyShares?: ServerKeyShare[];
55
+ onError?: (error: Error) => void;
56
+ }): Promise<string>;
57
+ /**
58
+ * Exports the private key for a given account address
59
+ * @param accountAddress - The account address to export the private key for
60
+ * @param password - The password for encrypted backup shares
61
+ * @param externalServerKeyShares - The external server key shares
62
+ * @returns The private key as a hex string
63
+ */
64
+ exportPrivateKey({ accountAddress, password, externalServerKeyShares, }: {
65
+ accountAddress: string;
66
+ password?: string;
67
+ externalServerKeyShares?: ServerKeyShare[];
68
+ }): Promise<string>;
69
+ /**
70
+ * Exports the private key offline using key shares
71
+ * @param keyShares - The key shares to export the private key for
72
+ * @param derivationPath - The derivation path
73
+ * @returns The derived private key
74
+ */
75
+ offlineExportPrivateKey({ keyShares, derivationPath, }: {
76
+ keyShares: Ed25519KeygenResult[];
77
+ derivationPath?: string;
78
+ }): Promise<{
79
+ derivedPrivateKey: string | undefined;
80
+ }>;
81
+ /**
82
+ * Imports a private key and stores the key shares in the wallet map.
83
+ * @param privateKey - The private key to import.
84
+ * @param chainName - The chain name to use for the wallet.
85
+ * @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
86
+ * @param password - The password to use for the wallet.
87
+ * @param onError - The function to call if an error occurs.
88
+ * @param backUpToClientShareService - Whether to back up the external server key shares to the client share service.
89
+ * @param publicAddressCheck - Optional public address to verify against the derived address.
90
+ * @returns The account address, public key hex, raw public key, and external server key shares.
91
+ */
92
+ importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, onError, backUpToClientShareService, publicAddressCheck, }: {
93
+ privateKey: string;
94
+ chainName: string;
95
+ thresholdSignatureScheme: ThresholdSignatureScheme;
96
+ password?: string;
97
+ onError?: (error: Error) => void;
98
+ backUpToClientShareService?: boolean;
99
+ publicAddressCheck?: string;
100
+ }): Promise<{
101
+ accountAddress: string;
102
+ publicKeyHex: string;
103
+ rawPublicKey: Uint8Array | string | undefined;
104
+ externalServerKeyShares: ServerKeyShare[];
105
+ }>;
106
+ /**
107
+ * Derives the public key from a private key
108
+ * @param privateKeyHex - The private key as a hex string
109
+ * @returns The public key as a hex string
110
+ */
111
+ getPublicKeyFromPrivateKey(privateKeyHex: string): string;
112
+ /**
113
+ * Derives a TON address from a public key
114
+ * TON addresses are derived from the wallet contract state init
115
+ */
116
+ deriveTonAddress: ({ publicKeyHex, workchain, }: {
117
+ publicKeyHex: string;
118
+ workchain?: number;
119
+ }) => string;
120
+ /**
121
+ * Gets all TON wallets
122
+ * @returns Array of TON wallets
123
+ */
124
+ getTonWallets(): Promise<any>;
125
+ }
126
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAG9B,MAAM,2BAA2B,CAAC;AAenC,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,oBAAoB,GACrB,EAAE,wBAAwB;IAU3B;;;;;;;OAOG;IACG,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,OAAO,EACP,0BAAkC,GACnC,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;QACjC,0BAA0B,CAAC,EAAE,OAAO,CAAC;KACtC,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,UAAU,GAAG,MAAM,CAAC;QAClC,uBAAuB,EAAE,cAAc,EAAE,CAAC;QAC1C,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IA6EF;;;;;;;;OAQG;IACG,WAAW,CAAC,EAChB,OAAO,EACP,cAAc,EACd,QAAoB,EACpB,uBAAuB,EACvB,OAAO,GACR,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,uBAAuB,C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C,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;QAC9C,uBAAuB,EAAE,cAAc,EAAE,CAAC;KAC3C,CAAC;IA6GF;;;;OAIG;IACH,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;IAsBzD;;;OAGG;IACH,gBAAgB,iCAGb;QACD,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,KAAG,MAAM,CAmBR;IAEF;;;OAGG;IACG,aAAa;CAOpB"}
@@ -0,0 +1,8 @@
1
+ export declare const ERROR_KEYGEN_FAILED = "Error with keygen";
2
+ export declare const ERROR_CREATE_WALLET_ACCOUNT = "Error creating ton wallet account";
3
+ export declare const ERROR_IMPORT_PRIVATE_KEY = "Error importing private key";
4
+ export declare const ERROR_EXPORT_PRIVATE_KEY = "Error exporting private key";
5
+ export declare const ERROR_SIGN_MESSAGE = "Error signing message";
6
+ export declare const ERROR_ACCOUNT_ADDRESS_REQUIRED = "Account address is required";
7
+ export declare const ERROR_SIGN_TRANSACTION = "Error signing transaction";
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,sCAAsC,CAAC;AAE/E,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAEtE,eAAO,MAAM,wBAAwB,gCAAgC,CAAC;AAEtE,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAE5E,eAAO,MAAM,sBAAsB,8BAA8B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './client.js';
2
+ export * from './constants.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
package/src/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './client/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Logger } from '@dynamic-labs/logger';
2
+ export declare const logger: Logger;
3
+ declare const logError: ({ message, error, context, }: {
4
+ message: string;
5
+ error: Error;
6
+ context: Record<string, unknown>;
7
+ }) => void;
8
+ export { Logger } from '@dynamic-labs/logger';
9
+ export { logError };
10
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/services/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,eAAO,MAAM,MAAM,QAAwC,CAAC;AAE5D,QAAA,MAAM,QAAQ,iCAIX;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,KAAG,IAQH,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,CAAC"}