@tomo-inc/chains-service 0.0.7 → 0.0.8
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 +4 -0
- package/dist/index.cjs +602 -95
- package/dist/index.d.cts +117 -43
- package/dist/index.d.ts +117 -43
- package/dist/index.js +608 -102
- package/package.json +2 -2
- package/src/api/network-data.ts +19 -5
- package/src/api/token.ts +11 -6
- package/src/base/service.ts +4 -4
- package/src/base/token.ts +8 -9
- package/src/dogecoin/service.ts +46 -252
- package/src/dogecoin/type.ts +12 -0
- package/src/dogecoin/utils-doge.ts +75 -2
- package/src/dogecoin/utils.ts +3 -380
- package/src/evm/service.ts +57 -73
- package/src/index.ts +5 -4
- package/src/solana/service.ts +6 -6
- package/src/types/account.ts +4 -3
- package/src/types/index.ts +3 -3
- package/src/utils/index.ts +7 -0
package/src/solana/service.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { BaseService } from "../base/service";
|
|
|
5
5
|
import { BaseConfig, MSG_PREFIX } from "./config";
|
|
6
6
|
import { createLegacyTx, createTokenLegacyTransaction2, txToHex } from "./utils";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { IAccountInfo, QueryGasParams, QueryGasResponse, TomoAppInfo, TransactionParams } from "../types";
|
|
9
9
|
import { QueryRentParams, SolanaRentInfo } from "./types";
|
|
10
10
|
|
|
11
11
|
import { getAssociatedTokenAddress } from "@solana/spl-token";
|
|
@@ -20,7 +20,7 @@ export class SolanaService extends BaseService {
|
|
|
20
20
|
public rpcUrl: string;
|
|
21
21
|
private connection: Connection;
|
|
22
22
|
|
|
23
|
-
public constructor(chainType: ChainTypes, accountInfo:
|
|
23
|
+
public constructor(chainType: ChainTypes, accountInfo: IAccountInfo, tomoAppInfo: TomoAppInfo) {
|
|
24
24
|
super(tomoAppInfo, accountInfo);
|
|
25
25
|
this.chainType = chainType;
|
|
26
26
|
const config: any = {
|
|
@@ -38,7 +38,7 @@ export class SolanaService extends BaseService {
|
|
|
38
38
|
this.connection = new Connection(rpcUrl, config);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
public static getInstance(chainType: ChainTypes, accountInfo:
|
|
41
|
+
public static getInstance(chainType: ChainTypes, accountInfo: IAccountInfo, tomoAppInfo: TomoAppInfo) {
|
|
42
42
|
if (!SolanaService.instance) {
|
|
43
43
|
SolanaService.instance = new SolanaService(chainType, accountInfo, tomoAppInfo);
|
|
44
44
|
}
|
|
@@ -50,12 +50,12 @@ export class SolanaService extends BaseService {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
public async getAccount(): Promise<{ publicKey: string; address: string }> {
|
|
53
|
-
const { currentAddress, publicKey }: any = await this.accountInfo.
|
|
53
|
+
const { address: currentAddress, publicKey }: any = await this.accountInfo.getCurrent();
|
|
54
54
|
return { publicKey: publicKey || currentAddress, address: currentAddress };
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
public async signMessage(params: any): Promise<{ message: string; signature: string; publicKey: string }> {
|
|
58
|
-
const { currentAddress, publicKey }: any = await this.accountInfo.
|
|
58
|
+
const { address: currentAddress, publicKey }: any = await this.accountInfo.getCurrent();
|
|
59
59
|
|
|
60
60
|
const { message } = params;
|
|
61
61
|
const signature = await this.accountInfo.signMessage(message);
|
|
@@ -70,7 +70,7 @@ export class SolanaService extends BaseService {
|
|
|
70
70
|
public async signIn(
|
|
71
71
|
params: any,
|
|
72
72
|
): Promise<{ address: string; publicKey: string; signature: string; signedMessage: string }> {
|
|
73
|
-
const { currentAddress, publicKey }: any = await this.accountInfo.
|
|
73
|
+
const { address: currentAddress, publicKey }: any = await this.accountInfo.getCurrent();
|
|
74
74
|
|
|
75
75
|
const { signature = "" } = await this.signMessage(params);
|
|
76
76
|
|
package/src/types/account.ts
CHANGED
|
@@ -31,9 +31,9 @@ export interface ChainAddress {
|
|
|
31
31
|
export interface IAccount {
|
|
32
32
|
readonly id: string;
|
|
33
33
|
readonly userId?: string | number;
|
|
34
|
-
readonly name
|
|
34
|
+
readonly name?: string;
|
|
35
35
|
readonly type: AccountType;
|
|
36
|
-
readonly lastUsedTime
|
|
36
|
+
readonly lastUsedTime?: number;
|
|
37
37
|
readonly sortIndex?: number;
|
|
38
38
|
readonly addresses: Record<ChainTypes, ChainAddress[]>;
|
|
39
39
|
|
|
@@ -50,9 +50,10 @@ export interface IAccount {
|
|
|
50
50
|
readonly totalAssets?: string;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export interface
|
|
53
|
+
export interface IAccountInfo {
|
|
54
54
|
getCurrent: () => Promise<any[]>;
|
|
55
55
|
signMessage: (message: string) => Promise<string>;
|
|
56
56
|
signTypedData: (message: any) => Promise<string>;
|
|
57
57
|
signTransaction: (transaction: any) => Promise<string>;
|
|
58
|
+
decryptedMessage?: (message: string) => Promise<any>;
|
|
58
59
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -10,9 +10,9 @@ export * from "./wallet";
|
|
|
10
10
|
export interface TomoAppInfo {
|
|
11
11
|
tomoStage: TomoStage;
|
|
12
12
|
tomoClientId: string;
|
|
13
|
-
apiKey
|
|
14
|
-
apiSecret
|
|
15
|
-
salt
|
|
13
|
+
apiKey?: string;
|
|
14
|
+
apiSecret?: string;
|
|
15
|
+
salt?: string;
|
|
16
16
|
jwtToken?: string;
|
|
17
17
|
}
|
|
18
18
|
|