@thru/chain-interfaces 0.2.8 → 0.2.10
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 +56 -28
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/IThruChain.ts +20 -2
- package/src/types.ts +20 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
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
|
-
/** Indicates whether the wallet has approved a Thru connection. */
|
|
9
|
-
readonly connected: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Initiate a Thru connection flow. Resolves with the connected address once
|
|
12
|
-
* the user has approved the request.
|
|
13
|
-
*/
|
|
14
|
-
connect(): Promise<{
|
|
15
|
-
publicKey: string;
|
|
16
|
-
}>;
|
|
17
|
-
/** Disconnect the currently connected Thru account. */
|
|
18
|
-
disconnect(): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Sign a serialized Thru transaction payload (base64 string) and return the
|
|
21
|
-
* signed payload encoded as base64.
|
|
22
|
-
*/
|
|
23
|
-
signTransaction(serializedTransaction: string): Promise<string>;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
1
|
declare const AddressType: {
|
|
27
2
|
readonly THRU: "thru";
|
|
28
3
|
};
|
|
29
|
-
type AddressType = typeof AddressType[keyof typeof AddressType];
|
|
4
|
+
type AddressType = (typeof AddressType)[keyof typeof AddressType];
|
|
30
5
|
interface WalletAccount {
|
|
31
6
|
accountType: AddressType;
|
|
32
7
|
address: string;
|
|
@@ -41,9 +16,22 @@ interface AppMetadata {
|
|
|
41
16
|
interface ConnectResult {
|
|
42
17
|
walletId?: string;
|
|
43
18
|
accounts: WalletAccount[];
|
|
44
|
-
status?:
|
|
19
|
+
status?: "pending" | "completed";
|
|
45
20
|
metadata?: AppMetadata;
|
|
46
21
|
}
|
|
22
|
+
declare const ThruTransactionEncoding: {
|
|
23
|
+
readonly SIGNING_PAYLOAD_BASE64: "signing_payload_base64";
|
|
24
|
+
readonly RAW_TRANSACTION_BASE64: "raw_transaction_base64";
|
|
25
|
+
};
|
|
26
|
+
type ThruTransactionEncoding = (typeof ThruTransactionEncoding)[keyof typeof ThruTransactionEncoding];
|
|
27
|
+
interface ThruSigningContext {
|
|
28
|
+
mode: "managed_fee_payer";
|
|
29
|
+
selectedAccountPublicKey: string | null;
|
|
30
|
+
feePayerPublicKey: string;
|
|
31
|
+
signerPublicKey: string;
|
|
32
|
+
acceptedInputEncodings: ThruTransactionEncoding[];
|
|
33
|
+
outputEncoding: typeof ThruTransactionEncoding.RAW_TRANSACTION_BASE64;
|
|
34
|
+
}
|
|
47
35
|
interface ConnectedApp {
|
|
48
36
|
accountId: number;
|
|
49
37
|
appId: string;
|
|
@@ -61,4 +49,44 @@ interface SignMessageResult {
|
|
|
61
49
|
publicKey: string;
|
|
62
50
|
}
|
|
63
51
|
|
|
64
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Minimal Thru chain interface exposed to SDK consumers.
|
|
54
|
+
* The concrete implementation will evolve as the Thru transaction
|
|
55
|
+
* flow is fleshed out, but maintaining a dedicated contract now
|
|
56
|
+
* keeps the Surface area aligned with other chain adapters.
|
|
57
|
+
*/
|
|
58
|
+
interface IThruChain {
|
|
59
|
+
/** Indicates whether the wallet has approved a Thru connection. */
|
|
60
|
+
readonly connected: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Initiate a Thru connection flow. Resolves with the connected address once
|
|
63
|
+
* the user has approved the request.
|
|
64
|
+
*/
|
|
65
|
+
connect(): Promise<{
|
|
66
|
+
publicKey: string;
|
|
67
|
+
}>;
|
|
68
|
+
/** Disconnect the currently connected Thru account. */
|
|
69
|
+
disconnect(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Return the current embedded signing contract for Thru transactions.
|
|
72
|
+
*
|
|
73
|
+
* The selected account is the managed wallet account shown to the user.
|
|
74
|
+
* The fee payer / signer can differ when the wallet routes transactions
|
|
75
|
+
* through an embedded manager profile.
|
|
76
|
+
*/
|
|
77
|
+
getSigningContext(): Promise<ThruSigningContext>;
|
|
78
|
+
/**
|
|
79
|
+
* Sign a serialized Thru transaction (base64 string) and return canonical
|
|
80
|
+
* raw transaction bytes encoded as base64.
|
|
81
|
+
*
|
|
82
|
+
* Implementations may accept either:
|
|
83
|
+
* - signing payload bytes produced by `Transaction.toWireForSigning()`
|
|
84
|
+
* - raw transaction bytes produced by `Transaction.toWire()`
|
|
85
|
+
*
|
|
86
|
+
* The returned bytes are always safe for direct submission via the supported
|
|
87
|
+
* RPC path without any app-side wire reordering.
|
|
88
|
+
*/
|
|
89
|
+
signTransaction(serializedTransaction: string): Promise<string>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { AddressType, type AppMetadata, type ConnectResult, type ConnectedApp, type IThruChain, type SignMessageParams, type SignMessageResult, type ThruSigningContext, ThruTransactionEncoding, type WalletAccount };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
var AddressType = {
|
|
3
3
|
THRU: "thru"
|
|
4
4
|
};
|
|
5
|
+
var ThruTransactionEncoding = {
|
|
6
|
+
SIGNING_PAYLOAD_BASE64: "signing_payload_base64",
|
|
7
|
+
RAW_TRANSACTION_BASE64: "raw_transaction_base64"
|
|
8
|
+
};
|
|
5
9
|
|
|
6
|
-
export { AddressType };
|
|
10
|
+
export { AddressType, ThruTransactionEncoding };
|
|
7
11
|
//# sourceMappingURL=index.js.map
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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:
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";AAAO,IAAM,WAAA,GAAc;AAAA,EACzB,IAAA,EAAM;AACR;AAwBO,IAAM,uBAAA,GAA0B;AAAA,EACrC,sBAAA,EAAwB,wBAAA;AAAA,EACxB,sBAAA,EAAwB;AAC1B","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 WalletAccount {\n accountType: AddressType;\n address: string;\n label: 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 accounts: WalletAccount[];\n status?: \"pending\" | \"completed\";\n metadata?: AppMetadata;\n}\n\nexport const ThruTransactionEncoding = {\n SIGNING_PAYLOAD_BASE64: \"signing_payload_base64\",\n RAW_TRANSACTION_BASE64: \"raw_transaction_base64\",\n} as const;\n\nexport type ThruTransactionEncoding =\n (typeof ThruTransactionEncoding)[keyof typeof ThruTransactionEncoding];\n\nexport interface ThruSigningContext {\n mode: \"managed_fee_payer\";\n selectedAccountPublicKey: string | null;\n feePayerPublicKey: string;\n signerPublicKey: string;\n acceptedInputEncodings: ThruTransactionEncoding[];\n outputEncoding: typeof ThruTransactionEncoding.RAW_TRANSACTION_BASE64;\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
CHANGED
package/src/IThruChain.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ThruSigningContext } from "./types";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Minimal Thru chain interface exposed to SDK consumers.
|
|
3
5
|
* The concrete implementation will evolve as the Thru transaction
|
|
@@ -18,8 +20,24 @@ export interface IThruChain {
|
|
|
18
20
|
disconnect(): Promise<void>;
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
+
* Return the current embedded signing contract for Thru transactions.
|
|
24
|
+
*
|
|
25
|
+
* The selected account is the managed wallet account shown to the user.
|
|
26
|
+
* The fee payer / signer can differ when the wallet routes transactions
|
|
27
|
+
* through an embedded manager profile.
|
|
28
|
+
*/
|
|
29
|
+
getSigningContext(): Promise<ThruSigningContext>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Sign a serialized Thru transaction (base64 string) and return canonical
|
|
33
|
+
* raw transaction bytes encoded as base64.
|
|
34
|
+
*
|
|
35
|
+
* Implementations may accept either:
|
|
36
|
+
* - signing payload bytes produced by `Transaction.toWireForSigning()`
|
|
37
|
+
* - raw transaction bytes produced by `Transaction.toWire()`
|
|
38
|
+
*
|
|
39
|
+
* The returned bytes are always safe for direct submission via the supported
|
|
40
|
+
* RPC path without any app-side wire reordering.
|
|
23
41
|
*/
|
|
24
42
|
signTransaction(serializedTransaction: string): Promise<string>;
|
|
25
43
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export const AddressType = {
|
|
2
|
-
THRU:
|
|
2
|
+
THRU: "thru",
|
|
3
3
|
} as const;
|
|
4
4
|
|
|
5
|
-
export type AddressType = typeof AddressType[keyof typeof AddressType];
|
|
5
|
+
export type AddressType = (typeof AddressType)[keyof typeof AddressType];
|
|
6
6
|
|
|
7
7
|
export interface WalletAccount {
|
|
8
8
|
accountType: AddressType;
|
|
@@ -20,10 +20,27 @@ export interface AppMetadata {
|
|
|
20
20
|
export interface ConnectResult {
|
|
21
21
|
walletId?: string;
|
|
22
22
|
accounts: WalletAccount[];
|
|
23
|
-
status?:
|
|
23
|
+
status?: "pending" | "completed";
|
|
24
24
|
metadata?: AppMetadata;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export const ThruTransactionEncoding = {
|
|
28
|
+
SIGNING_PAYLOAD_BASE64: "signing_payload_base64",
|
|
29
|
+
RAW_TRANSACTION_BASE64: "raw_transaction_base64",
|
|
30
|
+
} as const;
|
|
31
|
+
|
|
32
|
+
export type ThruTransactionEncoding =
|
|
33
|
+
(typeof ThruTransactionEncoding)[keyof typeof ThruTransactionEncoding];
|
|
34
|
+
|
|
35
|
+
export interface ThruSigningContext {
|
|
36
|
+
mode: "managed_fee_payer";
|
|
37
|
+
selectedAccountPublicKey: string | null;
|
|
38
|
+
feePayerPublicKey: string;
|
|
39
|
+
signerPublicKey: string;
|
|
40
|
+
acceptedInputEncodings: ThruTransactionEncoding[];
|
|
41
|
+
outputEncoding: typeof ThruTransactionEncoding.RAW_TRANSACTION_BASE64;
|
|
42
|
+
}
|
|
43
|
+
|
|
27
44
|
export interface ConnectedApp {
|
|
28
45
|
accountId: number;
|
|
29
46
|
appId: string;
|