@thru/chain-interfaces 0.0.4
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/dist/index.d.ts +65 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +20 -0
- package/src/IThruChain.ts +27 -0
- package/src/index.ts +2 -0
- package/src/types.ts +43 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +10 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Thru chain interface exposed to SDK consumers.
|
|
3
|
+
* The concrete implementation will evolve as the Thru transaction
|
|
4
|
+
* flow is fleshed out, but maintaining a dedicated contract now
|
|
5
|
+
* keeps the Surface area aligned with other chain adapters.
|
|
6
|
+
*/
|
|
7
|
+
interface IThruChain {
|
|
8
|
+
/** The active Thru address, if connected. */
|
|
9
|
+
readonly publicKey: string | null;
|
|
10
|
+
/** Indicates whether the wallet has approved a Thru connection. */
|
|
11
|
+
readonly connected: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Initiate a Thru connection flow. Resolves with the connected address once
|
|
14
|
+
* the user has approved the request.
|
|
15
|
+
*/
|
|
16
|
+
connect(): Promise<{
|
|
17
|
+
publicKey: string;
|
|
18
|
+
}>;
|
|
19
|
+
/** Disconnect the currently connected Thru account. */
|
|
20
|
+
disconnect(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Sign a serialized Thru transaction payload (base64 string) and return the
|
|
23
|
+
* signed payload encoded as base64.
|
|
24
|
+
*/
|
|
25
|
+
signTransaction(serializedTransaction: string): Promise<string>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const AddressType: {
|
|
29
|
+
readonly THRU: "thru";
|
|
30
|
+
};
|
|
31
|
+
type AddressType = typeof AddressType[keyof typeof AddressType];
|
|
32
|
+
interface WalletAddress {
|
|
33
|
+
addressType: AddressType;
|
|
34
|
+
address: string;
|
|
35
|
+
}
|
|
36
|
+
interface AppMetadata {
|
|
37
|
+
appId: string;
|
|
38
|
+
appName: string;
|
|
39
|
+
appUrl: string;
|
|
40
|
+
imageUrl?: string;
|
|
41
|
+
}
|
|
42
|
+
interface ConnectResult {
|
|
43
|
+
walletId?: string;
|
|
44
|
+
addresses: WalletAddress[];
|
|
45
|
+
status?: 'pending' | 'completed';
|
|
46
|
+
metadata?: AppMetadata;
|
|
47
|
+
}
|
|
48
|
+
interface ConnectedApp {
|
|
49
|
+
accountId: number;
|
|
50
|
+
appId: string;
|
|
51
|
+
origin: string;
|
|
52
|
+
metadata: AppMetadata;
|
|
53
|
+
connectedAt: number;
|
|
54
|
+
updatedAt: number;
|
|
55
|
+
}
|
|
56
|
+
interface SignMessageParams {
|
|
57
|
+
message: string | Uint8Array;
|
|
58
|
+
networkId: string;
|
|
59
|
+
}
|
|
60
|
+
interface SignMessageResult {
|
|
61
|
+
signature: Uint8Array;
|
|
62
|
+
publicKey: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { AddressType, type AppMetadata, type ConnectResult, type ConnectedApp, type IThruChain, type SignMessageParams, type SignMessageResult, type WalletAddress };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";AAAO,IAAM,WAAA,GAAc;AAAA,EACzB,IAAA,EAAM;AACR","file":"index.js","sourcesContent":["export const AddressType = {\n THRU: 'thru',\n} as const;\n\nexport type AddressType = typeof AddressType[keyof typeof AddressType];\n\nexport interface WalletAddress {\n addressType: AddressType;\n address: string;\n}\n\nexport interface AppMetadata {\n appId: string;\n appName: string;\n appUrl: string;\n imageUrl?: string;\n}\n\nexport interface ConnectResult {\n walletId?: string;\n addresses: WalletAddress[];\n status?: 'pending' | 'completed';\n metadata?: AppMetadata;\n}\n\nexport interface ConnectedApp {\n accountId: number;\n appId: string;\n origin: string;\n metadata: AppMetadata;\n connectedAt: number;\n updatedAt: number;\n}\n\nexport interface SignMessageParams {\n message: string | Uint8Array;\n networkId: string;\n}\n\nexport interface SignMessageResult {\n signature: Uint8Array;\n publicKey: string;\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thru/chain-interfaces",
|
|
3
|
+
"version": "0.0.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup",
|
|
16
|
+
"dev": "tsup --watch",
|
|
17
|
+
"lint": "eslint src/",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal Thru chain interface exposed to SDK consumers.
|
|
3
|
+
* The concrete implementation will evolve as the Thru transaction
|
|
4
|
+
* flow is fleshed out, but maintaining a dedicated contract now
|
|
5
|
+
* keeps the Surface area aligned with other chain adapters.
|
|
6
|
+
*/
|
|
7
|
+
export interface IThruChain {
|
|
8
|
+
/** The active Thru address, if connected. */
|
|
9
|
+
readonly publicKey: string | null;
|
|
10
|
+
/** Indicates whether the wallet has approved a Thru connection. */
|
|
11
|
+
readonly connected: boolean;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initiate a Thru connection flow. Resolves with the connected address once
|
|
15
|
+
* the user has approved the request.
|
|
16
|
+
*/
|
|
17
|
+
connect(): Promise<{ publicKey: string }>;
|
|
18
|
+
|
|
19
|
+
/** Disconnect the currently connected Thru account. */
|
|
20
|
+
disconnect(): Promise<void>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Sign a serialized Thru transaction payload (base64 string) and return the
|
|
24
|
+
* signed payload encoded as base64.
|
|
25
|
+
*/
|
|
26
|
+
signTransaction(serializedTransaction: string): Promise<string>;
|
|
27
|
+
}
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const AddressType = {
|
|
2
|
+
THRU: 'thru',
|
|
3
|
+
} as const;
|
|
4
|
+
|
|
5
|
+
export type AddressType = typeof AddressType[keyof typeof AddressType];
|
|
6
|
+
|
|
7
|
+
export interface WalletAddress {
|
|
8
|
+
addressType: AddressType;
|
|
9
|
+
address: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AppMetadata {
|
|
13
|
+
appId: string;
|
|
14
|
+
appName: string;
|
|
15
|
+
appUrl: string;
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ConnectResult {
|
|
20
|
+
walletId?: string;
|
|
21
|
+
addresses: WalletAddress[];
|
|
22
|
+
status?: 'pending' | 'completed';
|
|
23
|
+
metadata?: AppMetadata;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface ConnectedApp {
|
|
27
|
+
accountId: number;
|
|
28
|
+
appId: string;
|
|
29
|
+
origin: string;
|
|
30
|
+
metadata: AppMetadata;
|
|
31
|
+
connectedAt: number;
|
|
32
|
+
updatedAt: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SignMessageParams {
|
|
36
|
+
message: string | Uint8Array;
|
|
37
|
+
networkId: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface SignMessageResult {
|
|
41
|
+
signature: Uint8Array;
|
|
42
|
+
publicKey: string;
|
|
43
|
+
}
|
package/tsconfig.json
ADDED