@vleap/warps-adapter-fastset 0.1.0-alpha.2 → 0.1.0-alpha.3

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.mts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { AdapterFactory, CombinedWarpBuilder, WarpClientConfig, Warp, BaseWarpBuilder, WarpAction, AdapterWarpExecutor, WarpExecutable, WarpChainInfo, WarpActionInputType, AdapterWarpExplorer, AdapterWarpResults, WarpExecution, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
2
+ import * as _mysten_bcs from '@mysten/bcs';
2
3
 
3
4
  declare const WarpFastsetConstants: {
4
- ChainName: string;
5
- ChainPrefix: string;
6
5
  Pi: {
7
6
  Identifier: string;
8
7
  DisplayName: string;
@@ -22,23 +21,6 @@ declare const WarpFastsetConstants: {
22
21
  Medium: string;
23
22
  High: string;
24
23
  };
25
- Network: {
26
- Mainnet: {
27
- ChainId: string;
28
- Name: string;
29
- BlockTime: number;
30
- };
31
- Testnet: {
32
- ChainId: string;
33
- Name: string;
34
- BlockTime: number;
35
- };
36
- Devnet: {
37
- ChainId: string;
38
- Name: string;
39
- BlockTime: number;
40
- };
41
- };
42
24
  Validation: {
43
25
  AddressLength: number;
44
26
  HexPrefix: string;
@@ -54,6 +36,174 @@ declare const WarpFastsetConstants: {
54
36
 
55
37
  declare const getFastsetAdapter: AdapterFactory;
56
38
 
39
+ declare const Bytes32: _mysten_bcs.BcsType<number[], Iterable<number> & {
40
+ length: number;
41
+ }, string>;
42
+ declare const PublicKey: _mysten_bcs.BcsType<number[], Iterable<number> & {
43
+ length: number;
44
+ }, string>;
45
+ declare const Address: _mysten_bcs.BcsEnum<{
46
+ External: _mysten_bcs.BcsType<number[], Iterable<number> & {
47
+ length: number;
48
+ }, string>;
49
+ FastSet: _mysten_bcs.BcsType<number[], Iterable<number> & {
50
+ length: number;
51
+ }, string>;
52
+ }, "Address">;
53
+ declare const Amount: _mysten_bcs.BcsType<string, unknown, "u256">;
54
+ declare const UserData: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
55
+ length: number;
56
+ }) | null | undefined, `Option<${string}>`>;
57
+ declare const Nonce: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
58
+ declare const Transfer: _mysten_bcs.BcsStruct<{
59
+ recipient: _mysten_bcs.BcsEnum<{
60
+ External: _mysten_bcs.BcsType<number[], Iterable<number> & {
61
+ length: number;
62
+ }, string>;
63
+ FastSet: _mysten_bcs.BcsType<number[], Iterable<number> & {
64
+ length: number;
65
+ }, string>;
66
+ }, "Address">;
67
+ amount: _mysten_bcs.BcsType<string, unknown, "u256">;
68
+ user_data: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
69
+ length: number;
70
+ }) | null | undefined, `Option<${string}>`>;
71
+ }, string>;
72
+ declare const ClaimType: _mysten_bcs.BcsEnum<{
73
+ Transfer: _mysten_bcs.BcsStruct<{
74
+ recipient: _mysten_bcs.BcsEnum<{
75
+ External: _mysten_bcs.BcsType<number[], Iterable<number> & {
76
+ length: number;
77
+ }, string>;
78
+ FastSet: _mysten_bcs.BcsType<number[], Iterable<number> & {
79
+ length: number;
80
+ }, string>;
81
+ }, "Address">;
82
+ amount: _mysten_bcs.BcsType<string, unknown, "u256">;
83
+ user_data: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
84
+ length: number;
85
+ }) | null | undefined, `Option<${string}>`>;
86
+ }, string>;
87
+ }, "ClaimType">;
88
+ declare const Transaction: _mysten_bcs.BcsStruct<{
89
+ sender: _mysten_bcs.BcsType<number[], Iterable<number> & {
90
+ length: number;
91
+ }, string>;
92
+ nonce: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
93
+ timestamp_nanos: _mysten_bcs.BcsType<string, string | number | bigint, "u128">;
94
+ claim: _mysten_bcs.BcsEnum<{
95
+ Transfer: _mysten_bcs.BcsStruct<{
96
+ recipient: _mysten_bcs.BcsEnum<{
97
+ External: _mysten_bcs.BcsType<number[], Iterable<number> & {
98
+ length: number;
99
+ }, string>;
100
+ FastSet: _mysten_bcs.BcsType<number[], Iterable<number> & {
101
+ length: number;
102
+ }, string>;
103
+ }, "Address">;
104
+ amount: _mysten_bcs.BcsType<string, unknown, "u256">;
105
+ user_data: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
106
+ length: number;
107
+ }) | null | undefined, `Option<${string}>`>;
108
+ }, string>;
109
+ }, "ClaimType">;
110
+ }, string>;
111
+ interface FastsetTransaction {
112
+ sender: Uint8Array;
113
+ nonce: number;
114
+ timestamp_nanos: bigint;
115
+ claim: {
116
+ Transfer: {
117
+ recipient: {
118
+ FastSet: Uint8Array;
119
+ } | {
120
+ External: Uint8Array;
121
+ };
122
+ amount: string;
123
+ user_data: Uint8Array | null;
124
+ };
125
+ };
126
+ }
127
+ interface FastsetTransferRequest {
128
+ recipient: Uint8Array;
129
+ amount: string;
130
+ user_data?: Uint8Array;
131
+ }
132
+ interface FastsetAccountInfo {
133
+ balance: string;
134
+ next_nonce: number;
135
+ sequence_number: number;
136
+ }
137
+ interface FastsetSubmitTransactionRequest {
138
+ transaction: FastsetTransaction;
139
+ signature: Uint8Array;
140
+ }
141
+ interface FastsetSubmitTransactionResponse {
142
+ transaction_hash: Uint8Array;
143
+ validator: Uint8Array;
144
+ signature: Uint8Array;
145
+ }
146
+ interface FastsetSubmitCertificateRequest {
147
+ transaction: FastsetTransaction;
148
+ signature: Uint8Array;
149
+ validator_signatures: [Uint8Array, Uint8Array][];
150
+ }
151
+ interface FastsetFaucetRequest {
152
+ recipient: Uint8Array;
153
+ amount: string;
154
+ }
155
+ interface FastsetFaucetResponse {
156
+ balance: string;
157
+ }
158
+ interface FastsetJsonRpcRequest {
159
+ jsonrpc: '2.0';
160
+ id: number;
161
+ method: string;
162
+ params: Record<string, unknown>;
163
+ }
164
+ interface FastsetJsonRpcResponse<T = unknown> {
165
+ jsonrpc: '2.0';
166
+ id: number;
167
+ result?: T;
168
+ error?: {
169
+ code: number;
170
+ message: string;
171
+ data?: unknown;
172
+ };
173
+ }
174
+
175
+ interface FastsetClientConfig {
176
+ validatorUrl: string;
177
+ proxyUrl: string;
178
+ }
179
+ declare class FastsetClient {
180
+ private config;
181
+ constructor(config: FastsetClientConfig);
182
+ getAccountInfo(address: Uint8Array): Promise<FastsetAccountInfo | null>;
183
+ getNextNonce(senderAddress: Uint8Array): Promise<number>;
184
+ fundFromFaucet(request: FastsetFaucetRequest): Promise<FastsetFaucetResponse>;
185
+ submitTransaction(request: FastsetSubmitTransactionRequest): Promise<FastsetSubmitTransactionResponse>;
186
+ submitCertificate(request: FastsetSubmitCertificateRequest): Promise<void>;
187
+ executeTransfer(senderPrivateKey: Uint8Array, recipient: Uint8Array, amount: string, userData?: Uint8Array): Promise<Uint8Array>;
188
+ signTransaction(transaction: FastsetTransaction, privateKey: Uint8Array): Promise<Uint8Array>;
189
+ private serializeTransaction;
190
+ private requestValidator;
191
+ private requestProxy;
192
+ private request;
193
+ private jsonReplacer;
194
+ }
195
+
196
+ declare function isValidFastsetAddress(address: string): boolean;
197
+ declare function fromBase64(base64: string): Uint8Array;
198
+ declare function toBase64String(bytes: Uint8Array): string;
199
+ declare function toHexString(bytes: Uint8Array): string;
200
+ declare function hexToDecimal(hex: string): string;
201
+ declare function decimalToHex(decimal: string): string;
202
+ declare function validateAmount(amount: string): boolean;
203
+ declare function normalizeAmount(amount: string): string;
204
+ declare function validatePrivateKey(privateKey: string | Uint8Array): boolean;
205
+ declare function validatePublicKey(publicKey: string | Uint8Array): boolean;
206
+
57
207
  declare class WarpFastsetBuilder implements CombinedWarpBuilder {
58
208
  private readonly config;
59
209
  private warp;
@@ -78,22 +228,23 @@ declare class WarpFastsetBuilder implements CombinedWarpBuilder {
78
228
  declare class WarpFastsetExecutor implements AdapterWarpExecutor {
79
229
  private readonly config;
80
230
  private readonly serializer;
231
+ private readonly fastsetClient;
81
232
  constructor(config: WarpClientConfig);
82
233
  createTransaction(executable: WarpExecutable): Promise<any>;
83
234
  createTransferTransaction(executable: WarpExecutable): Promise<any>;
84
235
  createContractCallTransaction(executable: WarpExecutable): Promise<any>;
85
236
  executeQuery(executable: WarpExecutable): Promise<any>;
86
237
  preprocessInput(chain: WarpChainInfo, input: string, type: WarpActionInputType, value: string): Promise<string>;
87
- private isValidFastsetAddress;
88
238
  private encodeFunctionData;
89
239
  private executeFastsetQuery;
90
240
  signMessage(message: string, privateKey: string): Promise<string>;
241
+ executeTransfer(executable: WarpExecutable): Promise<any>;
242
+ executeTransferWithKey(executable: WarpExecutable, privateKey: string): Promise<any>;
91
243
  }
92
244
 
93
245
  declare class WarpFastsetExplorer implements AdapterWarpExplorer {
94
246
  private readonly chainInfo;
95
- private readonly chainName;
96
- constructor(chainInfo: WarpChainInfo, chainName?: string);
247
+ constructor(chainInfo: WarpChainInfo);
97
248
  getAccountUrl(address: string): string;
98
249
  getTransactionUrl(hash: string): string;
99
250
  getBlockUrl(blockNumber: string | number): string;
@@ -129,4 +280,4 @@ declare class WarpFastsetSerializer implements AdapterWarpSerializer {
129
280
  stringToTyped(value: string): any;
130
281
  }
131
282
 
132
- export { WarpFastsetBuilder, WarpFastsetConstants, WarpFastsetExecutor, WarpFastsetExplorer, WarpFastsetResults, WarpFastsetSerializer, getFastsetAdapter };
283
+ export { Address, Amount, Bytes32, ClaimType, type FastsetAccountInfo, FastsetClient, type FastsetClientConfig, type FastsetFaucetRequest, type FastsetFaucetResponse, type FastsetJsonRpcRequest, type FastsetJsonRpcResponse, type FastsetSubmitCertificateRequest, type FastsetSubmitTransactionRequest, type FastsetSubmitTransactionResponse, type FastsetTransaction, type FastsetTransferRequest, Nonce, PublicKey, Transaction, Transfer, UserData, WarpFastsetBuilder, WarpFastsetConstants, WarpFastsetExecutor, WarpFastsetExplorer, WarpFastsetResults, WarpFastsetSerializer, decimalToHex, fromBase64, getFastsetAdapter, hexToDecimal, isValidFastsetAddress, normalizeAmount, toBase64String, toHexString, validateAmount, validatePrivateKey, validatePublicKey };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { AdapterFactory, CombinedWarpBuilder, WarpClientConfig, Warp, BaseWarpBuilder, WarpAction, AdapterWarpExecutor, WarpExecutable, WarpChainInfo, WarpActionInputType, AdapterWarpExplorer, AdapterWarpResults, WarpExecution, ResolvedInput, WarpExecutionResults, AdapterWarpSerializer, WarpSerializer, WarpNativeValue, BaseWarpActionInputType, WarpAdapterGenericType } from '@vleap/warps';
2
+ import * as _mysten_bcs from '@mysten/bcs';
2
3
 
3
4
  declare const WarpFastsetConstants: {
4
- ChainName: string;
5
- ChainPrefix: string;
6
5
  Pi: {
7
6
  Identifier: string;
8
7
  DisplayName: string;
@@ -22,23 +21,6 @@ declare const WarpFastsetConstants: {
22
21
  Medium: string;
23
22
  High: string;
24
23
  };
25
- Network: {
26
- Mainnet: {
27
- ChainId: string;
28
- Name: string;
29
- BlockTime: number;
30
- };
31
- Testnet: {
32
- ChainId: string;
33
- Name: string;
34
- BlockTime: number;
35
- };
36
- Devnet: {
37
- ChainId: string;
38
- Name: string;
39
- BlockTime: number;
40
- };
41
- };
42
24
  Validation: {
43
25
  AddressLength: number;
44
26
  HexPrefix: string;
@@ -54,6 +36,174 @@ declare const WarpFastsetConstants: {
54
36
 
55
37
  declare const getFastsetAdapter: AdapterFactory;
56
38
 
39
+ declare const Bytes32: _mysten_bcs.BcsType<number[], Iterable<number> & {
40
+ length: number;
41
+ }, string>;
42
+ declare const PublicKey: _mysten_bcs.BcsType<number[], Iterable<number> & {
43
+ length: number;
44
+ }, string>;
45
+ declare const Address: _mysten_bcs.BcsEnum<{
46
+ External: _mysten_bcs.BcsType<number[], Iterable<number> & {
47
+ length: number;
48
+ }, string>;
49
+ FastSet: _mysten_bcs.BcsType<number[], Iterable<number> & {
50
+ length: number;
51
+ }, string>;
52
+ }, "Address">;
53
+ declare const Amount: _mysten_bcs.BcsType<string, unknown, "u256">;
54
+ declare const UserData: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
55
+ length: number;
56
+ }) | null | undefined, `Option<${string}>`>;
57
+ declare const Nonce: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
58
+ declare const Transfer: _mysten_bcs.BcsStruct<{
59
+ recipient: _mysten_bcs.BcsEnum<{
60
+ External: _mysten_bcs.BcsType<number[], Iterable<number> & {
61
+ length: number;
62
+ }, string>;
63
+ FastSet: _mysten_bcs.BcsType<number[], Iterable<number> & {
64
+ length: number;
65
+ }, string>;
66
+ }, "Address">;
67
+ amount: _mysten_bcs.BcsType<string, unknown, "u256">;
68
+ user_data: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
69
+ length: number;
70
+ }) | null | undefined, `Option<${string}>`>;
71
+ }, string>;
72
+ declare const ClaimType: _mysten_bcs.BcsEnum<{
73
+ Transfer: _mysten_bcs.BcsStruct<{
74
+ recipient: _mysten_bcs.BcsEnum<{
75
+ External: _mysten_bcs.BcsType<number[], Iterable<number> & {
76
+ length: number;
77
+ }, string>;
78
+ FastSet: _mysten_bcs.BcsType<number[], Iterable<number> & {
79
+ length: number;
80
+ }, string>;
81
+ }, "Address">;
82
+ amount: _mysten_bcs.BcsType<string, unknown, "u256">;
83
+ user_data: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
84
+ length: number;
85
+ }) | null | undefined, `Option<${string}>`>;
86
+ }, string>;
87
+ }, "ClaimType">;
88
+ declare const Transaction: _mysten_bcs.BcsStruct<{
89
+ sender: _mysten_bcs.BcsType<number[], Iterable<number> & {
90
+ length: number;
91
+ }, string>;
92
+ nonce: _mysten_bcs.BcsType<string, string | number | bigint, "u64">;
93
+ timestamp_nanos: _mysten_bcs.BcsType<string, string | number | bigint, "u128">;
94
+ claim: _mysten_bcs.BcsEnum<{
95
+ Transfer: _mysten_bcs.BcsStruct<{
96
+ recipient: _mysten_bcs.BcsEnum<{
97
+ External: _mysten_bcs.BcsType<number[], Iterable<number> & {
98
+ length: number;
99
+ }, string>;
100
+ FastSet: _mysten_bcs.BcsType<number[], Iterable<number> & {
101
+ length: number;
102
+ }, string>;
103
+ }, "Address">;
104
+ amount: _mysten_bcs.BcsType<string, unknown, "u256">;
105
+ user_data: _mysten_bcs.BcsType<number[] | null, (Iterable<number> & {
106
+ length: number;
107
+ }) | null | undefined, `Option<${string}>`>;
108
+ }, string>;
109
+ }, "ClaimType">;
110
+ }, string>;
111
+ interface FastsetTransaction {
112
+ sender: Uint8Array;
113
+ nonce: number;
114
+ timestamp_nanos: bigint;
115
+ claim: {
116
+ Transfer: {
117
+ recipient: {
118
+ FastSet: Uint8Array;
119
+ } | {
120
+ External: Uint8Array;
121
+ };
122
+ amount: string;
123
+ user_data: Uint8Array | null;
124
+ };
125
+ };
126
+ }
127
+ interface FastsetTransferRequest {
128
+ recipient: Uint8Array;
129
+ amount: string;
130
+ user_data?: Uint8Array;
131
+ }
132
+ interface FastsetAccountInfo {
133
+ balance: string;
134
+ next_nonce: number;
135
+ sequence_number: number;
136
+ }
137
+ interface FastsetSubmitTransactionRequest {
138
+ transaction: FastsetTransaction;
139
+ signature: Uint8Array;
140
+ }
141
+ interface FastsetSubmitTransactionResponse {
142
+ transaction_hash: Uint8Array;
143
+ validator: Uint8Array;
144
+ signature: Uint8Array;
145
+ }
146
+ interface FastsetSubmitCertificateRequest {
147
+ transaction: FastsetTransaction;
148
+ signature: Uint8Array;
149
+ validator_signatures: [Uint8Array, Uint8Array][];
150
+ }
151
+ interface FastsetFaucetRequest {
152
+ recipient: Uint8Array;
153
+ amount: string;
154
+ }
155
+ interface FastsetFaucetResponse {
156
+ balance: string;
157
+ }
158
+ interface FastsetJsonRpcRequest {
159
+ jsonrpc: '2.0';
160
+ id: number;
161
+ method: string;
162
+ params: Record<string, unknown>;
163
+ }
164
+ interface FastsetJsonRpcResponse<T = unknown> {
165
+ jsonrpc: '2.0';
166
+ id: number;
167
+ result?: T;
168
+ error?: {
169
+ code: number;
170
+ message: string;
171
+ data?: unknown;
172
+ };
173
+ }
174
+
175
+ interface FastsetClientConfig {
176
+ validatorUrl: string;
177
+ proxyUrl: string;
178
+ }
179
+ declare class FastsetClient {
180
+ private config;
181
+ constructor(config: FastsetClientConfig);
182
+ getAccountInfo(address: Uint8Array): Promise<FastsetAccountInfo | null>;
183
+ getNextNonce(senderAddress: Uint8Array): Promise<number>;
184
+ fundFromFaucet(request: FastsetFaucetRequest): Promise<FastsetFaucetResponse>;
185
+ submitTransaction(request: FastsetSubmitTransactionRequest): Promise<FastsetSubmitTransactionResponse>;
186
+ submitCertificate(request: FastsetSubmitCertificateRequest): Promise<void>;
187
+ executeTransfer(senderPrivateKey: Uint8Array, recipient: Uint8Array, amount: string, userData?: Uint8Array): Promise<Uint8Array>;
188
+ signTransaction(transaction: FastsetTransaction, privateKey: Uint8Array): Promise<Uint8Array>;
189
+ private serializeTransaction;
190
+ private requestValidator;
191
+ private requestProxy;
192
+ private request;
193
+ private jsonReplacer;
194
+ }
195
+
196
+ declare function isValidFastsetAddress(address: string): boolean;
197
+ declare function fromBase64(base64: string): Uint8Array;
198
+ declare function toBase64String(bytes: Uint8Array): string;
199
+ declare function toHexString(bytes: Uint8Array): string;
200
+ declare function hexToDecimal(hex: string): string;
201
+ declare function decimalToHex(decimal: string): string;
202
+ declare function validateAmount(amount: string): boolean;
203
+ declare function normalizeAmount(amount: string): string;
204
+ declare function validatePrivateKey(privateKey: string | Uint8Array): boolean;
205
+ declare function validatePublicKey(publicKey: string | Uint8Array): boolean;
206
+
57
207
  declare class WarpFastsetBuilder implements CombinedWarpBuilder {
58
208
  private readonly config;
59
209
  private warp;
@@ -78,22 +228,23 @@ declare class WarpFastsetBuilder implements CombinedWarpBuilder {
78
228
  declare class WarpFastsetExecutor implements AdapterWarpExecutor {
79
229
  private readonly config;
80
230
  private readonly serializer;
231
+ private readonly fastsetClient;
81
232
  constructor(config: WarpClientConfig);
82
233
  createTransaction(executable: WarpExecutable): Promise<any>;
83
234
  createTransferTransaction(executable: WarpExecutable): Promise<any>;
84
235
  createContractCallTransaction(executable: WarpExecutable): Promise<any>;
85
236
  executeQuery(executable: WarpExecutable): Promise<any>;
86
237
  preprocessInput(chain: WarpChainInfo, input: string, type: WarpActionInputType, value: string): Promise<string>;
87
- private isValidFastsetAddress;
88
238
  private encodeFunctionData;
89
239
  private executeFastsetQuery;
90
240
  signMessage(message: string, privateKey: string): Promise<string>;
241
+ executeTransfer(executable: WarpExecutable): Promise<any>;
242
+ executeTransferWithKey(executable: WarpExecutable, privateKey: string): Promise<any>;
91
243
  }
92
244
 
93
245
  declare class WarpFastsetExplorer implements AdapterWarpExplorer {
94
246
  private readonly chainInfo;
95
- private readonly chainName;
96
- constructor(chainInfo: WarpChainInfo, chainName?: string);
247
+ constructor(chainInfo: WarpChainInfo);
97
248
  getAccountUrl(address: string): string;
98
249
  getTransactionUrl(hash: string): string;
99
250
  getBlockUrl(blockNumber: string | number): string;
@@ -129,4 +280,4 @@ declare class WarpFastsetSerializer implements AdapterWarpSerializer {
129
280
  stringToTyped(value: string): any;
130
281
  }
131
282
 
132
- export { WarpFastsetBuilder, WarpFastsetConstants, WarpFastsetExecutor, WarpFastsetExplorer, WarpFastsetResults, WarpFastsetSerializer, getFastsetAdapter };
283
+ export { Address, Amount, Bytes32, ClaimType, type FastsetAccountInfo, FastsetClient, type FastsetClientConfig, type FastsetFaucetRequest, type FastsetFaucetResponse, type FastsetJsonRpcRequest, type FastsetJsonRpcResponse, type FastsetSubmitCertificateRequest, type FastsetSubmitTransactionRequest, type FastsetSubmitTransactionResponse, type FastsetTransaction, type FastsetTransferRequest, Nonce, PublicKey, Transaction, Transfer, UserData, WarpFastsetBuilder, WarpFastsetConstants, WarpFastsetExecutor, WarpFastsetExplorer, WarpFastsetResults, WarpFastsetSerializer, decimalToHex, fromBase64, getFastsetAdapter, hexToDecimal, isValidFastsetAddress, normalizeAmount, toBase64String, toHexString, validateAmount, validatePrivateKey, validatePublicKey };