@thru/thru-sdk 0.0.4 → 0.0.6
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/chunk-VYHB2OSU.js +1064 -0
- package/dist/chunk-VYHB2OSU.js.map +1 -0
- package/dist/client.d.ts +57 -0
- package/dist/client.js +73 -0
- package/dist/client.js.map +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/sdk.d.ts +7 -1347
- package/dist/sdk.js +1 -1128
- package/dist/sdk.js.map +1 -1
- package/dist/transactions-DAkq8mUc.d.ts +1296 -0
- package/package.json +6 -1
- package/thru-ts-client-sdk/client.ts +9 -0
- package/thru-ts-client-sdk/core/bound-client.ts +6 -6
- package/thru-ts-client-sdk/core/client.ts +3 -3
- package/thru-ts-client-sdk/sdk.ts +2 -17
- package/thru-ts-client-sdk/{counter.ts → test-scripts/counter.ts} +2 -2
- package/thru-ts-client-sdk/{create-account.ts → test-scripts/create-account.ts} +3 -2
- package/thru-ts-client-sdk/{get-height.ts → test-scripts/get-height.ts} +1 -1
- package/tsup.config.ts +5 -1
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thru/thru-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/sdk.js",
|
|
6
6
|
"types": "./dist/sdk.d.ts",
|
|
7
|
+
"sideEffects": false,
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
10
|
"import": "./dist/sdk.js",
|
|
10
11
|
"types": "./dist/sdk.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./client": {
|
|
14
|
+
"import": "./dist/client.js",
|
|
15
|
+
"types": "./dist/client.d.ts"
|
|
11
16
|
}
|
|
12
17
|
},
|
|
13
18
|
"dependencies": {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createBoundThruClient, Thru } from "./core/bound-client";
|
|
2
|
+
import { createThruClientContext, ThruClientConfig } from "./core/client";
|
|
3
|
+
|
|
4
|
+
export type { Thru } from "./core/bound-client";
|
|
5
|
+
|
|
6
|
+
export function createThruClient(config: ThruClientConfig = {}): Thru {
|
|
7
|
+
const ctx = createThruClientContext(config);
|
|
8
|
+
return createBoundThruClient(ctx);
|
|
9
|
+
}
|
|
@@ -32,21 +32,21 @@ function bind<F extends (ctx: ThruClientContext, ...args: any[]) => any>(
|
|
|
32
32
|
return ((...args: ContextualParameters<F>) => fn(ctx, ...args)) as BoundFunction<F>;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
interface BoundBlocks {
|
|
36
36
|
get: BoundFunction<typeof blocksModule.getBlock>;
|
|
37
37
|
getRaw: BoundFunction<typeof blocksModule.getRawBlock>;
|
|
38
38
|
list: BoundFunction<typeof blocksModule.listBlocks>;
|
|
39
39
|
getBlockHeight: BoundFunction<typeof heightModule.getBlockHeight>;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
interface BoundAccounts {
|
|
43
43
|
get: BoundFunction<typeof accountsModule.getAccount>;
|
|
44
44
|
getRaw: BoundFunction<typeof accountsModule.getRawAccount>;
|
|
45
45
|
listOwned: BoundFunction<typeof accountsModule.listOwnedAccounts>;
|
|
46
46
|
create: BoundFunction<typeof accountsModule.createAccount>;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
interface BoundTransactions {
|
|
50
50
|
get: BoundFunction<typeof transactionsModule.getTransaction>;
|
|
51
51
|
getRaw: BoundFunction<typeof transactionsModule.getRawTransaction>;
|
|
52
52
|
getStatus: BoundFunction<typeof transactionsModule.getTransactionStatus>;
|
|
@@ -56,15 +56,15 @@ export interface BoundTransactions {
|
|
|
56
56
|
track: BoundFunction<typeof streamingModule.trackTransaction>;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
interface BoundEvents {
|
|
60
60
|
get: BoundFunction<typeof eventsModule.getEvent>;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
interface BoundProofs {
|
|
64
64
|
generate: BoundFunction<typeof proofsModule.generateStateProof>;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
interface Helpers {
|
|
68
68
|
toSignature(value: Uint8Array | string): Signature;
|
|
69
69
|
toPubkey(value: Uint8Array | string, field: string): Pubkey;
|
|
70
70
|
toBlockHash(value: Uint8Array | string): BlockHash;
|
|
@@ -10,9 +10,9 @@ export interface ThruClientConfig {
|
|
|
10
10
|
baseUrl?: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
type QueryClient = ReturnType<typeof createClient<typeof QueryService>>;
|
|
14
|
+
type CommandClient = ReturnType<typeof createClient<typeof CommandService>>;
|
|
15
|
+
type StreamingClient = ReturnType<typeof createClient<typeof StreamingService>>;
|
|
16
16
|
|
|
17
17
|
export interface ThruClientContext {
|
|
18
18
|
baseUrl: string;
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import { createBoundThruClient, Thru } from "./core/bound-client";
|
|
2
|
-
import type { ThruClientConfig } from "./core/client";
|
|
3
|
-
import { createThruClientContext } from "./core/client";
|
|
4
1
|
import type { SignedTransactionResult } from "./transactions";
|
|
5
2
|
import { TransactionBuilder } from "./transactions";
|
|
6
3
|
|
|
7
|
-
export { createBoundThruClient } from "./core/bound-client";
|
|
8
|
-
export type { Thru } from "./core/bound-client";
|
|
9
|
-
|
|
10
|
-
export { createThruClientContext } from "./core/client";
|
|
11
|
-
export type { ThruClientConfig, ThruClientContext } from "./core/client";
|
|
12
|
-
|
|
13
4
|
export * as accounts from "./modules/accounts";
|
|
14
5
|
export * as blocks from "./modules/blocks";
|
|
15
6
|
export * as events from "./modules/events";
|
|
@@ -21,10 +12,8 @@ export * as transactions from "./modules/transactions";
|
|
|
21
12
|
export { ConsensusStatus } from "./proto/thru/common/v1/consensus_pb";
|
|
22
13
|
|
|
23
14
|
export type {
|
|
24
|
-
AccountQueryOptions,
|
|
25
|
-
|
|
26
|
-
RawAccountQueryOptions,
|
|
27
|
-
CreateAccountOptions,
|
|
15
|
+
AccountQueryOptions, CreateAccountOptions, ListOwnedAccountsOptions,
|
|
16
|
+
RawAccountQueryOptions
|
|
28
17
|
} from "./modules/accounts";
|
|
29
18
|
export type { BlockQueryOptions, ListBlocksOptions, RawBlockQueryOptions } from "./modules/blocks";
|
|
30
19
|
export type { GetEventOptions } from "./modules/events";
|
|
@@ -52,7 +41,3 @@ export type { GenerateStateProofOptions } from "./types/types";
|
|
|
52
41
|
export { TransactionBuilder };
|
|
53
42
|
export type { SignedTransactionResult };
|
|
54
43
|
|
|
55
|
-
export function createThruClient(config: ThruClientConfig = {}): Thru {
|
|
56
|
-
const ctx = createThruClientContext(config);
|
|
57
|
-
return createBoundThruClient(ctx);
|
|
58
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createThruClient } from "../client";
|
|
2
|
+
import { ConsensusStatus } from "../proto/thru/common/v1/consensus_pb";
|
|
3
3
|
|
|
4
4
|
const sdk = createThruClient({
|
|
5
5
|
// Configure the SDK to connect to the desired Thru cluster
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getPublicKeyAsync } from "@noble/ed25519";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { createThruClient } from "../client";
|
|
3
|
+
import { ConsensusStatus } from "../proto/thru/common/v1/consensus_pb";
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
const sdk = createThruClient({
|
|
6
7
|
// endpoint: "https://api.thru.network", // Set to your cluster endpoint.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createClient } from "@connectrpc/connect";
|
|
3
3
|
|
|
4
4
|
import { createGrpcWebTransport } from "@connectrpc/connect-web";
|
|
5
|
-
import { GetHeightRequestSchema, QueryService } from '
|
|
5
|
+
import { GetHeightRequestSchema, QueryService } from '../proto/thru/services/v1/query_service_pb';
|
|
6
6
|
|
|
7
7
|
import { create } from "@bufbuild/protobuf";
|
|
8
8
|
|
package/tsup.config.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { defineConfig } from 'tsup';
|
|
2
2
|
|
|
3
3
|
export default defineConfig({
|
|
4
|
-
entry:
|
|
4
|
+
entry: {
|
|
5
|
+
sdk: 'thru-ts-client-sdk/sdk.ts',
|
|
6
|
+
client: 'thru-ts-client-sdk/client.ts'
|
|
7
|
+
},
|
|
5
8
|
format: ['esm'],
|
|
6
9
|
dts: true,
|
|
7
10
|
sourcemap: true,
|
|
8
11
|
clean: true,
|
|
9
12
|
treeshake: true,
|
|
13
|
+
metafile: true
|
|
10
14
|
});
|