salt-sdk 0.0.1
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/README.md +26 -0
- package/dist/ccip-gULzfYCK.js +160 -0
- package/dist/index-_fV99sY9.js +77736 -0
- package/dist/index.d.ts +881 -0
- package/dist/salt.es.js +30 -0
- package/package.json +76 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,881 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { BigNumberish } from 'ethers';
|
|
3
|
+
import { ContractReceipt } from 'ethers';
|
|
4
|
+
import { providers } from 'ethers';
|
|
5
|
+
import { Signer } from 'ethers';
|
|
6
|
+
|
|
7
|
+
declare type AccountPolicy = {
|
|
8
|
+
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* Type of the policy
|
|
11
|
+
* @example 'POLICY_TRANSACTION_LIMIT_TOKEN_DENOMINATED'
|
|
12
|
+
*/
|
|
13
|
+
type: PolicyType;
|
|
14
|
+
/**
|
|
15
|
+
* The precise parameters of the policy, specific to the policy type.
|
|
16
|
+
* @todo Document the parameters for each policy type.
|
|
17
|
+
*/
|
|
18
|
+
params: unknown;
|
|
19
|
+
/**
|
|
20
|
+
* Chain ID of the policy. All policies are associated with a single chain.
|
|
21
|
+
* @example '11155111'
|
|
22
|
+
*/
|
|
23
|
+
chain: string;
|
|
24
|
+
/**
|
|
25
|
+
* ID of the account the policy belongs to
|
|
26
|
+
* @example '6824aa9c27c0fa91b32800a4'
|
|
27
|
+
*/
|
|
28
|
+
accountId: string;
|
|
29
|
+
/**
|
|
30
|
+
* ID of the organisation the policy belongs to
|
|
31
|
+
* @example '679240f8d14559b720d3ba54'
|
|
32
|
+
*/
|
|
33
|
+
organisationId: string;
|
|
34
|
+
/**
|
|
35
|
+
* Policy creator's name for the policy, a short summary of the policy.
|
|
36
|
+
* @example 'Limit Amount per Transfer'
|
|
37
|
+
*/
|
|
38
|
+
name: string;
|
|
39
|
+
/**
|
|
40
|
+
* Policy creator's longer description of the policy
|
|
41
|
+
* @example 'Limit the size of transfers on Ethereum Sepolia'
|
|
42
|
+
*/
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Response type for getAccounts API call
|
|
48
|
+
*/
|
|
49
|
+
declare type AccountsResponse = SaltAccount[];
|
|
50
|
+
|
|
51
|
+
declare type Address = string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Throw an error if the Signer is not connected to the appropriate orchestration
|
|
55
|
+
* network.
|
|
56
|
+
*
|
|
57
|
+
* @param signer
|
|
58
|
+
* @param orchestrationChain
|
|
59
|
+
*/
|
|
60
|
+
export declare function assertCorrectChain(signer: Signer, orchestrationChainId: SupportedChainId): Promise<void>;
|
|
61
|
+
|
|
62
|
+
export declare function assertHasAuthToken(token: string | null): asserts token is string;
|
|
63
|
+
|
|
64
|
+
export declare function assertValidAddress(address: string, fieldName?: string): asserts address is Address;
|
|
65
|
+
|
|
66
|
+
export declare function assertValidAuthToken(token: string | null): asserts token is string;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Assert that the chain is valid, and a decimal
|
|
70
|
+
* @param chain - The chain to assert
|
|
71
|
+
* @throws InvalidChain - If the chain is invalid
|
|
72
|
+
*/
|
|
73
|
+
export declare function assertValidChain(chain: number): asserts chain is SupportedChainId;
|
|
74
|
+
|
|
75
|
+
export declare function assertValidEnvironment(environment: string): asserts environment is PreconfiguredEnvironment;
|
|
76
|
+
|
|
77
|
+
export declare function assertValidParams(params: ConstructorParams): asserts params is ConstructorParams;
|
|
78
|
+
|
|
79
|
+
export declare function assertValidProvider(provider?: providers.Provider): asserts provider is providers.Provider;
|
|
80
|
+
|
|
81
|
+
export declare function assertValidSigner(signer?: Signer): asserts signer is Signer;
|
|
82
|
+
|
|
83
|
+
export declare function assertValidUrl(url: string, fieldName?: string): asserts url is string;
|
|
84
|
+
|
|
85
|
+
export declare function assertValidUrlNoTrailingSlash(url: string, fieldName?: string): asserts url is string;
|
|
86
|
+
|
|
87
|
+
export declare function assertValidValue(value: BigNumberish): asserts value is string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A subset of TransactionParams providing a minimal interface
|
|
91
|
+
* for building a token transfer transaction
|
|
92
|
+
*/
|
|
93
|
+
declare interface BaseTransferParams {
|
|
94
|
+
/**
|
|
95
|
+
* Salt account ID for the transaction
|
|
96
|
+
* @example '1234567890'
|
|
97
|
+
*/
|
|
98
|
+
accountId: TransactionParams['accountId'];
|
|
99
|
+
/**
|
|
100
|
+
* Recipient address for the transaction
|
|
101
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
102
|
+
*/
|
|
103
|
+
to: TransactionParams['to'];
|
|
104
|
+
/**
|
|
105
|
+
* Amount of token to send. This is a string representation of the amount of the token being sent.
|
|
106
|
+
* @example '1'
|
|
107
|
+
*/
|
|
108
|
+
value: string;
|
|
109
|
+
/**
|
|
110
|
+
* Decimals of the token being sent.
|
|
111
|
+
* @example 18
|
|
112
|
+
*/
|
|
113
|
+
decimals: number;
|
|
114
|
+
/**
|
|
115
|
+
* Ethers signer for the transaction.
|
|
116
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
117
|
+
*/
|
|
118
|
+
signer: TransactionParams['signer'];
|
|
119
|
+
/**
|
|
120
|
+
* Chain ID of the network (integer)
|
|
121
|
+
* @example 11155111
|
|
122
|
+
*/
|
|
123
|
+
chainId: TransactionParams['chainId'];
|
|
124
|
+
/**
|
|
125
|
+
* Sending provider of the transaction. If not provided, it will attempt to select a provider depending on the chainId
|
|
126
|
+
* @example new providers.JsonRpcProvider('https://rpc.ankr.com/eth')
|
|
127
|
+
*/
|
|
128
|
+
sendingProvider?: TransactionParams['sendingProvider'];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare interface BroadcastTxResponse {
|
|
132
|
+
/**
|
|
133
|
+
* instance of transaction receipt object
|
|
134
|
+
* @example
|
|
135
|
+
*/
|
|
136
|
+
receipt?: Receipt;
|
|
137
|
+
/**
|
|
138
|
+
* hex representation of the transactionId, this is not the nonce, it uniquely identifies every proposed transaction
|
|
139
|
+
* @example '0x1'
|
|
140
|
+
*/
|
|
141
|
+
txId: string;
|
|
142
|
+
/**
|
|
143
|
+
* address of the signer
|
|
144
|
+
* @example '0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97'
|
|
145
|
+
*/
|
|
146
|
+
signer: string;
|
|
147
|
+
/**
|
|
148
|
+
* address of the salt account's smart contract
|
|
149
|
+
* @example '0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97'
|
|
150
|
+
*/
|
|
151
|
+
accountAddress: string;
|
|
152
|
+
/**
|
|
153
|
+
* error
|
|
154
|
+
* @example
|
|
155
|
+
*/
|
|
156
|
+
error?: any;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
declare interface CombineTxResponse {
|
|
160
|
+
/**
|
|
161
|
+
* true when the combination of the signatures is succesful
|
|
162
|
+
* @example true
|
|
163
|
+
*/
|
|
164
|
+
success: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* hex representation of the transactionId, this is not the nonce, it uniquely identifies every proposed transaction
|
|
167
|
+
* @example '0x1'
|
|
168
|
+
*/
|
|
169
|
+
txId: string;
|
|
170
|
+
/**
|
|
171
|
+
* address of the signer
|
|
172
|
+
* @example '0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97'
|
|
173
|
+
*/
|
|
174
|
+
signer: string;
|
|
175
|
+
/**
|
|
176
|
+
* address of the salt account's smart contract
|
|
177
|
+
* @example '0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97'
|
|
178
|
+
*/
|
|
179
|
+
accountAddress: string;
|
|
180
|
+
/**
|
|
181
|
+
* error
|
|
182
|
+
* @example
|
|
183
|
+
*/
|
|
184
|
+
error?: any;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export declare type ConstructorParams = {
|
|
188
|
+
/**
|
|
189
|
+
* The authentication token for the Salt SDK. See {@link authenticate} for the full authentication flow,
|
|
190
|
+
* or {@link setAuthToken} to set a pre-existing token after calling the constructor.
|
|
191
|
+
* @defaultValue null
|
|
192
|
+
*/
|
|
193
|
+
authToken?: string;
|
|
194
|
+
/**
|
|
195
|
+
* Environment to use. This will be optional in the future, but right now
|
|
196
|
+
* it is required. Use 'TESTNET'
|
|
197
|
+
* @todo Make this optional in the future
|
|
198
|
+
*/
|
|
199
|
+
environment: Environment;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
declare type Environment = 'MAINNET' | 'TESTNET' | EnvironmentConfig;
|
|
203
|
+
|
|
204
|
+
declare type EnvironmentConfig = {
|
|
205
|
+
chainId: SupportedChainId;
|
|
206
|
+
websocketUrl: string;
|
|
207
|
+
saltDomain: string;
|
|
208
|
+
apiUrl: string;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
declare interface ERC20TransferParams extends BaseTransferParams {
|
|
212
|
+
type: TransferType.ERC20;
|
|
213
|
+
tokenAddress: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare enum EVENTS {
|
|
217
|
+
POLICY_BREACH = "policyBreach",
|
|
218
|
+
TRANSACTION_SIGN = "transactionSigningComplete",
|
|
219
|
+
TRANSACTION_COMBINE = "transactionCombiningComplete",
|
|
220
|
+
TRANSACTION_BROADCAST = "transactionBroadcastingComplete"
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Gas price information from Ethereum RPC, containing current network fee data
|
|
225
|
+
* for transaction cost estimation and execution
|
|
226
|
+
*/
|
|
227
|
+
declare type GasPrice = {
|
|
228
|
+
/**
|
|
229
|
+
* The base fee per gas from the most recent block (EIP-1559)
|
|
230
|
+
* This is the minimum fee required for transaction inclusion
|
|
231
|
+
*/
|
|
232
|
+
lastBaseFeePerGas: BigNumber;
|
|
233
|
+
/**
|
|
234
|
+
* The maximum total fee per gas willing to pay (base fee + priority fee)
|
|
235
|
+
* This caps the total transaction cost in case of network congestion
|
|
236
|
+
*/
|
|
237
|
+
maxFeePerGas: BigNumber;
|
|
238
|
+
/**
|
|
239
|
+
* The maximum priority fee (tip) per gas to incentivize miners/validators
|
|
240
|
+
* This is added to the base fee to prioritize transaction inclusion
|
|
241
|
+
*/
|
|
242
|
+
maxPriorityFeePerGas: BigNumber;
|
|
243
|
+
/**
|
|
244
|
+
* Legacy gas price for pre-EIP-1559 transactions
|
|
245
|
+
* Used for Type 0 and Type 1 transactions on networks that support them
|
|
246
|
+
*/
|
|
247
|
+
gasPrice: BigNumber;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export declare class InsufficientGas extends Error {
|
|
251
|
+
readonly cause?: Error;
|
|
252
|
+
constructor(message: string, originalError?: Error);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export declare class InvalidAddress extends Error {
|
|
256
|
+
readonly cause?: Error;
|
|
257
|
+
constructor(message: string, originalError?: Error);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export declare class InvalidAuthToken extends Error {
|
|
261
|
+
readonly cause?: Error;
|
|
262
|
+
constructor(message: string, originalError?: Error);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export declare class InvalidChain extends Error {
|
|
266
|
+
readonly cause?: Error;
|
|
267
|
+
constructor(message: string, originalError?: Error);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export declare class InvalidEnvironment extends Error {
|
|
271
|
+
readonly cause?: Error;
|
|
272
|
+
constructor(message: string, originalError?: Error);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export declare class InvalidParams extends Error {
|
|
276
|
+
readonly cause?: Error;
|
|
277
|
+
constructor(message: string, originalError?: Error);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export declare class InvalidProvider extends Error {
|
|
281
|
+
readonly cause?: Error;
|
|
282
|
+
constructor(message: string, originalError?: Error);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export declare class InvalidSigner extends Error {
|
|
286
|
+
readonly cause?: Error;
|
|
287
|
+
constructor(message: string, originalError?: Error);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export declare class InvalidUrl extends Error {
|
|
291
|
+
readonly cause?: Error;
|
|
292
|
+
constructor(message: string, originalError?: Error);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export declare class InvalidValue extends Error {
|
|
296
|
+
readonly cause?: Error;
|
|
297
|
+
constructor(message: string, originalError?: Error);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
declare type Member = {
|
|
301
|
+
name: string;
|
|
302
|
+
/**
|
|
303
|
+
* The public key of the member
|
|
304
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
305
|
+
*/
|
|
306
|
+
address: string;
|
|
307
|
+
/**
|
|
308
|
+
* The text description of the member's role, set by the user that invited
|
|
309
|
+
* this member.
|
|
310
|
+
* @example 'DeFI Team Lead'
|
|
311
|
+
*/
|
|
312
|
+
role: string;
|
|
313
|
+
/**
|
|
314
|
+
* The access level of the member.
|
|
315
|
+
* 1: Owner
|
|
316
|
+
* 2: Member
|
|
317
|
+
* 3: Agent
|
|
318
|
+
* 4: Member with no permissions
|
|
319
|
+
* @example 1
|
|
320
|
+
*/
|
|
321
|
+
accessLevel: MemberAccessLevel;
|
|
322
|
+
/**
|
|
323
|
+
* The current status of the member
|
|
324
|
+
* @example 'Invited'
|
|
325
|
+
*/
|
|
326
|
+
status: MemberStatus;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
declare type MemberAccessLevel = 1 | 2 | 3 | 4;
|
|
330
|
+
|
|
331
|
+
declare type MemberStatus = 'Active' | 'Invited' | 'Suspended' | 'Inactive';
|
|
332
|
+
|
|
333
|
+
declare interface NativeTransferParams extends BaseTransferParams {
|
|
334
|
+
type: TransferType.Native;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
declare type Organisation = {
|
|
338
|
+
/**
|
|
339
|
+
* Unique identifier of the organisation creator
|
|
340
|
+
* @example '6824aa9c27c0fa91b32800a4'
|
|
341
|
+
*/
|
|
342
|
+
user_id: string;
|
|
343
|
+
/**
|
|
344
|
+
* The display name of the Organisation
|
|
345
|
+
* @example 'My Organisation'
|
|
346
|
+
*/
|
|
347
|
+
name: string;
|
|
348
|
+
/**
|
|
349
|
+
* The members of the Organisation
|
|
350
|
+
* @example [{
|
|
351
|
+
* name: 'John Doe',
|
|
352
|
+
* address: '0x1234567890123456789012345678901234567890',
|
|
353
|
+
* role: 'Admin',
|
|
354
|
+
* accessLevel: 1,
|
|
355
|
+
* status: 'Active',
|
|
356
|
+
* }]
|
|
357
|
+
*/
|
|
358
|
+
members: Member[];
|
|
359
|
+
/**
|
|
360
|
+
* The last time the Organisation was updated
|
|
361
|
+
* @example '2021-01-01T00:00:00.000Z'
|
|
362
|
+
*/
|
|
363
|
+
lastUpdated?: string;
|
|
364
|
+
/**
|
|
365
|
+
* The Terms and Conditions revision that has been accepted by the Organisation creator
|
|
366
|
+
* @example 1
|
|
367
|
+
*/
|
|
368
|
+
termsAcceptedVersion?: number;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
declare type OrganisationsResponse = Organisation[];
|
|
372
|
+
|
|
373
|
+
declare interface PolicyBreachResponse {
|
|
374
|
+
/**
|
|
375
|
+
* address of the transaction proposer
|
|
376
|
+
* @example '0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97'
|
|
377
|
+
*/
|
|
378
|
+
proposerAddress: string;
|
|
379
|
+
/**
|
|
380
|
+
* array of rejected policies
|
|
381
|
+
* @example '[{}]'
|
|
382
|
+
*/
|
|
383
|
+
rejectedPolicies: any;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
declare type PolicyType = 'POLICY_ALLOWED_RECIPIENTS' | 'POLICY_DENIED_RECIPIENTS' | 'POLICY_TRANSACTION_LIMIT_TOKEN_DENOMINATED' | 'POLICY_NOMINATED_APPROVERS' | 'POLICY_DENIED_PROPOSERS';
|
|
387
|
+
|
|
388
|
+
declare type PreconfiguredEnvironment = 'MAINNET' | 'TESTNET';
|
|
389
|
+
|
|
390
|
+
declare const process_2: {
|
|
391
|
+
readonly env: {
|
|
392
|
+
readonly debug: false;
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
export { process_2 as process }
|
|
396
|
+
|
|
397
|
+
declare type ProposeTxResponse = SubmitTransactionResult;
|
|
398
|
+
|
|
399
|
+
declare interface Receipt {
|
|
400
|
+
/**
|
|
401
|
+
* transaction hash for the transaction
|
|
402
|
+
* @example '0xca8e42cca3cbb373ef1215a30b6a862f93758c8df5c0ce28390a39a80b867c36'
|
|
403
|
+
*/
|
|
404
|
+
transactionHash: string;
|
|
405
|
+
/**
|
|
406
|
+
* status of the broadcasted transaction, 1 for success, 0 for failure
|
|
407
|
+
* @example 1
|
|
408
|
+
*/
|
|
409
|
+
status: number;
|
|
410
|
+
/**
|
|
411
|
+
* block hash of the block in which the transaction was included
|
|
412
|
+
* @example '0xf47694b502f090d36a6d2281b016fceb260f6321a624dc780c178f1a126ea58f'
|
|
413
|
+
*/
|
|
414
|
+
blockHash: string;
|
|
415
|
+
/**
|
|
416
|
+
* gas used by the transaction
|
|
417
|
+
* @example '22500'
|
|
418
|
+
*/
|
|
419
|
+
gasUsed: string;
|
|
420
|
+
/**
|
|
421
|
+
* gas paid per unit of gas, in wei
|
|
422
|
+
* @example '777473623'
|
|
423
|
+
*/
|
|
424
|
+
effectiveGasPrice: string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* The Salt SDK
|
|
429
|
+
*/
|
|
430
|
+
export declare class Salt {
|
|
431
|
+
/**
|
|
432
|
+
* The authentication token for the Salt SDK. See {@link authenticate} for the full authentication flow,
|
|
433
|
+
* or {@link setAuthToken} to set a pre-existing token.
|
|
434
|
+
* @private
|
|
435
|
+
* @defaultValue null
|
|
436
|
+
*/
|
|
437
|
+
private authToken;
|
|
438
|
+
/**
|
|
439
|
+
* The environment for the Salt SDK. See {@link EnvironmentConfig} for the full environment config.
|
|
440
|
+
* @private
|
|
441
|
+
* @defaultValue Environments.TESTNET
|
|
442
|
+
*/
|
|
443
|
+
private environment;
|
|
444
|
+
/**
|
|
445
|
+
* The socketIO connector for the Salt SDK. See {@link SaltSocket} for the full socketIO connector.
|
|
446
|
+
* @todo Will be private
|
|
447
|
+
* @defaultValue null
|
|
448
|
+
*/
|
|
449
|
+
socketIOConnector: SaltSocket | null;
|
|
450
|
+
/**
|
|
451
|
+
* Creates an instance of the Salt SDK
|
|
452
|
+
* @param params - The constructor parameters
|
|
453
|
+
*/
|
|
454
|
+
constructor(params?: ConstructorParams);
|
|
455
|
+
/**
|
|
456
|
+
* Initiate a SIWE authentication flow to get an authentication token from the Salt API
|
|
457
|
+
* This will require a signature from the signer, which will be used to authenticate the user.
|
|
458
|
+
* @param signer - The Ethereum signer to use for the authentication flow
|
|
459
|
+
* @returns long lived authentication token
|
|
460
|
+
*/
|
|
461
|
+
authenticate(signer: Signer): Promise<void>;
|
|
462
|
+
initSocket(): Promise<unknown>;
|
|
463
|
+
/**
|
|
464
|
+
* Sets the authentication token for the Salt SDK. You can authenticate with {@link authenticate}, or set a
|
|
465
|
+
* pre-existing token with this function.
|
|
466
|
+
* @param authToken - The authentication token to use for this connection
|
|
467
|
+
*/
|
|
468
|
+
setAuthToken(authToken: string): void;
|
|
469
|
+
/**
|
|
470
|
+
* Gets the list of organisations that the user is a member of
|
|
471
|
+
* @returns The list of organisations
|
|
472
|
+
*/
|
|
473
|
+
getOrganisations(): Promise<OrganisationsResponse>;
|
|
474
|
+
/**
|
|
475
|
+
* Gets the details of a specific account
|
|
476
|
+
* @param accountId - The ID of the account
|
|
477
|
+
* @returns The account details
|
|
478
|
+
*/
|
|
479
|
+
getAccount(accountId: string): Promise<SaltAccount>;
|
|
480
|
+
/**
|
|
481
|
+
* Gets the list of accounts that belong to an organisation
|
|
482
|
+
* @param organisationId - The ID of the organisation
|
|
483
|
+
* @returns The list of accounts
|
|
484
|
+
*/
|
|
485
|
+
getAccounts(organisationId: string): Promise<AccountsResponse>;
|
|
486
|
+
/**
|
|
487
|
+
* Gets the list of token balances for an account. This list is not exhaustive.
|
|
488
|
+
* @param accountId - The ID of the account
|
|
489
|
+
* @returns The list of tokens & balances
|
|
490
|
+
*/
|
|
491
|
+
getAccountTokens(accountId: string): Promise<TokenBalanceResponse>;
|
|
492
|
+
/**
|
|
493
|
+
* Gets the nonce for an account on a specific chain. The nonce is an incrementing number stored
|
|
494
|
+
* by Salt that is used to prevent replay attacks.
|
|
495
|
+
* @param accountId - The ID of the account
|
|
496
|
+
* @param chainId - The ID of the chain
|
|
497
|
+
* @returns The nonce
|
|
498
|
+
*/
|
|
499
|
+
getAccountNonce(accountId: string, chainId: number): Promise<number>;
|
|
500
|
+
/**
|
|
501
|
+
* Gets the current gas price for a specific chain.
|
|
502
|
+
* @param chainId - The ID of the chain
|
|
503
|
+
* @returns The current gas price
|
|
504
|
+
*/
|
|
505
|
+
getGasPrice(chainId: number): Promise<GasPrice>;
|
|
506
|
+
/**
|
|
507
|
+
* creates a new transfer object
|
|
508
|
+
* @param params
|
|
509
|
+
*/
|
|
510
|
+
transfer(params: TransferParams): Promise<Transfer>;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* A specifc Salt account within an Organisation
|
|
515
|
+
*/
|
|
516
|
+
declare type SaltAccount = {
|
|
517
|
+
/**
|
|
518
|
+
* The ID of the account
|
|
519
|
+
* @example '6824aa9c27c0fa91b32800a4'
|
|
520
|
+
*/
|
|
521
|
+
id: string;
|
|
522
|
+
/**
|
|
523
|
+
* The address of the account on the orchestration chain. This is required for orchestration
|
|
524
|
+
* but is not the address that you will send or receive tokens from. See {@link publicKey} for that.
|
|
525
|
+
* @example '0x7890123456789012345678901234567890123456'
|
|
526
|
+
*/
|
|
527
|
+
address: string;
|
|
528
|
+
/**
|
|
529
|
+
* Public key of the account. This is the address that you will send or receive tokens from.
|
|
530
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
531
|
+
*/
|
|
532
|
+
publicKey: string;
|
|
533
|
+
/**
|
|
534
|
+
* The public key of the account creator
|
|
535
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
536
|
+
*/
|
|
537
|
+
creatorAddress: string;
|
|
538
|
+
/**
|
|
539
|
+
* The name of the account
|
|
540
|
+
* @example 'Staking'
|
|
541
|
+
*/
|
|
542
|
+
name: string;
|
|
543
|
+
/**
|
|
544
|
+
* Signers for the account
|
|
545
|
+
* @example ['0x1234567890123456789012345678901234567890', '0x2345678901234567890123456789012345678901', '0x3456789012345678901234567890123456789012']
|
|
546
|
+
*/
|
|
547
|
+
signers: string[];
|
|
548
|
+
/**
|
|
549
|
+
* Policies for the account
|
|
550
|
+
*/
|
|
551
|
+
policies: AccountPolicy[];
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
declare class SaltSocket {
|
|
555
|
+
/**
|
|
556
|
+
* The socketIO connector for the Salt SDK. Required for the async communication during transaction signing and setup
|
|
557
|
+
* @defaultValue null
|
|
558
|
+
*/
|
|
559
|
+
private socket;
|
|
560
|
+
private websocketUrl;
|
|
561
|
+
private authToken;
|
|
562
|
+
constructor(authToken: string, websocketUrl: string);
|
|
563
|
+
init(): Promise<unknown>;
|
|
564
|
+
/**
|
|
565
|
+
* join account's websocket events channel
|
|
566
|
+
* @param accountAddress
|
|
567
|
+
* @returns
|
|
568
|
+
*/
|
|
569
|
+
joinAccountChannel: (accountAddress: string) => void;
|
|
570
|
+
/**
|
|
571
|
+
* disconnect socket from server
|
|
572
|
+
*/
|
|
573
|
+
disconnect: () => void;
|
|
574
|
+
/**
|
|
575
|
+
* subsribe to POLICY_BREACH event
|
|
576
|
+
* @param callback
|
|
577
|
+
* @returns
|
|
578
|
+
*/
|
|
579
|
+
subscribeToPolicyBreachEvent: (callback: (data: PolicyBreachResponse) => void) => void;
|
|
580
|
+
/**
|
|
581
|
+
* subsribe to TRANSACTION_SIGN event
|
|
582
|
+
* @param callback
|
|
583
|
+
* @returns
|
|
584
|
+
*/
|
|
585
|
+
subscribeToTransactionSignEvent: (callback: (data: SignTxResponse) => void) => void;
|
|
586
|
+
/**
|
|
587
|
+
* SUBSCRIBE TO TRANSACTION_COMBINE event
|
|
588
|
+
* @param callback
|
|
589
|
+
* @returns
|
|
590
|
+
*/
|
|
591
|
+
subscribeToTransactionCombineEvent: (callback: (data: CombineTxResponse) => void) => void;
|
|
592
|
+
/**
|
|
593
|
+
* subscribe to TRANSACTION_BROADCAST event
|
|
594
|
+
* @param callback
|
|
595
|
+
* @returns
|
|
596
|
+
*/
|
|
597
|
+
subscribeToTransactionBroadcastEvent: (callback: (data: BroadcastTxResponse) => void) => void;
|
|
598
|
+
/**
|
|
599
|
+
* unsubscribe from socket any of EVENTS' events
|
|
600
|
+
* @param event
|
|
601
|
+
* @param callback
|
|
602
|
+
* @returns
|
|
603
|
+
*/
|
|
604
|
+
unsubscribe: (event: EVENTS) => void;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
declare interface SignTxResponse {
|
|
608
|
+
/**
|
|
609
|
+
* ethers.js transaction receipt object
|
|
610
|
+
* @example '
|
|
611
|
+
*/
|
|
612
|
+
receipt?: ContractReceipt;
|
|
613
|
+
/**
|
|
614
|
+
* hex representation of the transactionId, this is not the nonce, it uniquely identifies every proposed transaction
|
|
615
|
+
* @example '0x1'
|
|
616
|
+
*/
|
|
617
|
+
txId: string;
|
|
618
|
+
/**
|
|
619
|
+
* address of the signer
|
|
620
|
+
* @example '0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97'
|
|
621
|
+
*/
|
|
622
|
+
signer: string;
|
|
623
|
+
/**
|
|
624
|
+
* address of the salt account's smart contract
|
|
625
|
+
* @example '0x4838B106FCe9647Bdf1E7877BF73cE8B0BAD5f97'
|
|
626
|
+
*/
|
|
627
|
+
accountAddress: string;
|
|
628
|
+
/**
|
|
629
|
+
* error
|
|
630
|
+
* @example
|
|
631
|
+
*/
|
|
632
|
+
error?: any;
|
|
633
|
+
/**
|
|
634
|
+
* resource lock of the robos, if true it means another signer is currently using the robos.
|
|
635
|
+
* @example true
|
|
636
|
+
*/
|
|
637
|
+
locked?: boolean;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
declare type StateTransitionHandler = (data: TransitionData) => void | Promise<void>;
|
|
641
|
+
|
|
642
|
+
declare interface SubmitTransactionResult {
|
|
643
|
+
submittedTx: TransactionParams;
|
|
644
|
+
txId: string;
|
|
645
|
+
txInfo: string;
|
|
646
|
+
receipt: ContractReceipt;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
declare type SupportedChainId = 11155111 | 421614 | 80002 | 50312 | 1 | 42161;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Balance of a token for a specified account
|
|
653
|
+
*/
|
|
654
|
+
declare type TokenBalance = {
|
|
655
|
+
/**
|
|
656
|
+
* The address of the token
|
|
657
|
+
* @example '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
|
|
658
|
+
*/
|
|
659
|
+
address: string;
|
|
660
|
+
/**
|
|
661
|
+
* The symbol of the token
|
|
662
|
+
* @example 'WETH'
|
|
663
|
+
*/
|
|
664
|
+
symbol: string;
|
|
665
|
+
/**
|
|
666
|
+
* The name of the token
|
|
667
|
+
* @example 'Wrapped Ether'
|
|
668
|
+
*/
|
|
669
|
+
name: string;
|
|
670
|
+
/**
|
|
671
|
+
* The logo of the token
|
|
672
|
+
* @example 'https://assets.coingecko.com/coins/images/279/large/ethereum.png'
|
|
673
|
+
*/
|
|
674
|
+
logo: string;
|
|
675
|
+
/**
|
|
676
|
+
* Precision of the token
|
|
677
|
+
* @example 18
|
|
678
|
+
*/
|
|
679
|
+
decimals: number;
|
|
680
|
+
/**
|
|
681
|
+
* The balance of the token in human-readable format (decimal adjusted)
|
|
682
|
+
* @example '0.13191'
|
|
683
|
+
*/
|
|
684
|
+
balance: string;
|
|
685
|
+
/**
|
|
686
|
+
* The price of the token
|
|
687
|
+
* @example 1800
|
|
688
|
+
*/
|
|
689
|
+
price: number | string;
|
|
690
|
+
/**
|
|
691
|
+
* The chain ID of the token
|
|
692
|
+
* @example '11155111'
|
|
693
|
+
*/
|
|
694
|
+
chainId: string;
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Response type for getAccountTokens API call
|
|
699
|
+
*/
|
|
700
|
+
declare type TokenBalanceResponse = TokenBalance[];
|
|
701
|
+
|
|
702
|
+
export declare interface TransactionParams {
|
|
703
|
+
/**
|
|
704
|
+
* ID of the Salt account to use for the transaction
|
|
705
|
+
* @example '1234567890'
|
|
706
|
+
*/
|
|
707
|
+
accountId: string;
|
|
708
|
+
/**
|
|
709
|
+
* Recipient address for the transaction
|
|
710
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
711
|
+
*/
|
|
712
|
+
to: string;
|
|
713
|
+
/**
|
|
714
|
+
* Amount of token to send. This is a string, eventually parsed with ethers.utils.parseEther
|
|
715
|
+
*/
|
|
716
|
+
value: string;
|
|
717
|
+
/**
|
|
718
|
+
* Chain ID of the network (integer)
|
|
719
|
+
* @example 11155111
|
|
720
|
+
*/
|
|
721
|
+
chainId: number;
|
|
722
|
+
/**
|
|
723
|
+
* Nonce of the transaction. If not provided, it will be fetched from the Salt API
|
|
724
|
+
* @example 1
|
|
725
|
+
*/
|
|
726
|
+
nonce?: string | number;
|
|
727
|
+
/**
|
|
728
|
+
* Data of the transaction.
|
|
729
|
+
* @defaultValue '0x'
|
|
730
|
+
* @example '0x'
|
|
731
|
+
*/
|
|
732
|
+
data?: string;
|
|
733
|
+
/**
|
|
734
|
+
* Current gas price of the chain.
|
|
735
|
+
* @example '1000000000000000000'
|
|
736
|
+
*/
|
|
737
|
+
gasPrice?: string | number;
|
|
738
|
+
/**
|
|
739
|
+
* Gas fee of the transaction.
|
|
740
|
+
* @example '40000000'
|
|
741
|
+
*/
|
|
742
|
+
gas?: string | number;
|
|
743
|
+
/**
|
|
744
|
+
* Vault address of the transaction.
|
|
745
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
746
|
+
*/
|
|
747
|
+
vaultAddress: string;
|
|
748
|
+
/**
|
|
749
|
+
* Signer of the transaction. If not provided, it will be set to the accountId
|
|
750
|
+
* @todo This should be made optional, and inferred from the accountID
|
|
751
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
752
|
+
*/
|
|
753
|
+
signer: Signer;
|
|
754
|
+
/**
|
|
755
|
+
* Notes of the transaction. If not provided, it will be set to an empty string
|
|
756
|
+
* @example 'This is a note'
|
|
757
|
+
*/
|
|
758
|
+
notes?: string;
|
|
759
|
+
/**
|
|
760
|
+
* Return hash of the transaction. If not provided, it will be set to false
|
|
761
|
+
* @example true
|
|
762
|
+
* @defaultValue false
|
|
763
|
+
*/
|
|
764
|
+
returnHash?: boolean;
|
|
765
|
+
/**
|
|
766
|
+
* Sending provider of the transaction. If not provided, it will select a provider depending on the chainId
|
|
767
|
+
* @example new providers.JsonRpcProvider('https://rpc.ankr.com/eth')
|
|
768
|
+
*/
|
|
769
|
+
sendingProvider?: providers.Provider;
|
|
770
|
+
/**
|
|
771
|
+
* Vault public key of the transaction.
|
|
772
|
+
* @example '0x1234567890123456789012345678901234567890'
|
|
773
|
+
*/
|
|
774
|
+
vaultPublicKey: string;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
declare class Transfer {
|
|
778
|
+
/**
|
|
779
|
+
* The authentication token for the Salt SDK. See {@link authenticate} for the full authentication flow,
|
|
780
|
+
* or {@link setAuthToken} to set a pre-existing token.
|
|
781
|
+
* @private
|
|
782
|
+
*/
|
|
783
|
+
private authToken;
|
|
784
|
+
/**
|
|
785
|
+
* The environment for the Salt SDK. See {@link EnvironmentConfig} for the full environment config.
|
|
786
|
+
* @private
|
|
787
|
+
* @defaultValue Environments.TESTNET
|
|
788
|
+
*/
|
|
789
|
+
private environment;
|
|
790
|
+
/**
|
|
791
|
+
* The socketIO connector for the Salt SDK. See {@link SaltSocket} for the full socketIO connector.
|
|
792
|
+
*/
|
|
793
|
+
private socketIOConnector;
|
|
794
|
+
/**
|
|
795
|
+
* the current state of the transfer. See {@link TRANSFER_STATES} for the complete list of states
|
|
796
|
+
* @defaultValue TRANSFER_STATES.IDLE
|
|
797
|
+
*/
|
|
798
|
+
private currentState;
|
|
799
|
+
/**
|
|
800
|
+
* the number of signatures required for this transaction to gather in the TRANSFER_STATES.SIGN state
|
|
801
|
+
*/
|
|
802
|
+
private requiredSignatures;
|
|
803
|
+
/**
|
|
804
|
+
* the transaction parameters see {@link TransactionParams} for the comprehensive type description
|
|
805
|
+
*/
|
|
806
|
+
private params;
|
|
807
|
+
/**
|
|
808
|
+
* the object returned when proposing the transaction to the orchestration network in TRANSFER_STATE.propose state. See {@link SubmitTransactionResult} for the complete interface descriptions
|
|
809
|
+
*@defaultValue null
|
|
810
|
+
*/
|
|
811
|
+
private submitTransactionResult;
|
|
812
|
+
/**
|
|
813
|
+
* Signatures gathered in TRANSFER_STATE.SIGN. See {@link SignTxResponse} for the complete interface description
|
|
814
|
+
* @defaultValue []
|
|
815
|
+
*/
|
|
816
|
+
private signatures;
|
|
817
|
+
/**
|
|
818
|
+
* Response gathered in TRANSFER_STATE.COMBINE. See {@link CombineTxResponse} for the complete interface description
|
|
819
|
+
* @defaultValue null
|
|
820
|
+
*/
|
|
821
|
+
private combineResponse;
|
|
822
|
+
/**
|
|
823
|
+
* Response gathered in TRANSFER_STATE.BROADCAST. See {@link BroadcastTxResponse} for the complete interface description
|
|
824
|
+
* @defaultValue null
|
|
825
|
+
*/
|
|
826
|
+
private broadcastResponse;
|
|
827
|
+
/**
|
|
828
|
+
* user defined state transition handlers. See {@link StateTransitionHandler} for the complete type description
|
|
829
|
+
* @defaultValue new Map()
|
|
830
|
+
*/
|
|
831
|
+
private transitionHandlers;
|
|
832
|
+
constructor(socketIOConnector: SaltSocket, environment: EnvironmentConfig, authToken: string, requiredSignatures: number, params: TransactionParams);
|
|
833
|
+
private isValidTransition;
|
|
834
|
+
getCurrentState(): TRANSFER_STATES;
|
|
835
|
+
getBroadcastTxResponse(): BroadcastTxResponse | null;
|
|
836
|
+
getRequiredSignatures(): number;
|
|
837
|
+
getSignatures(): SignTxResponse[];
|
|
838
|
+
getCombineResponse(): CombineTxResponse | null;
|
|
839
|
+
onTransition(fromState: TRANSFER_STATES, toState: TRANSFER_STATES, handler: StateTransitionHandler): void;
|
|
840
|
+
transitionTo(data: TransitionData, newState: TRANSFER_STATES): Promise<void>;
|
|
841
|
+
initListeners(): void;
|
|
842
|
+
/**
|
|
843
|
+
* Submits a transaction to the blockchain using the Intu and Salt
|
|
844
|
+
* @param params - The transaction parameters
|
|
845
|
+
* @returns true if it was successfully submitted
|
|
846
|
+
*/
|
|
847
|
+
submitTransaction(): Promise<boolean>;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
declare enum TRANSFER_STATES {
|
|
851
|
+
IDLE = 0,
|
|
852
|
+
PROPOSE = 1,
|
|
853
|
+
SIGN = 2,
|
|
854
|
+
COMBINE = 3,
|
|
855
|
+
BROADCAST = 4,
|
|
856
|
+
END = 5
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
export declare type TransferParams = ERC20TransferParams | NativeTransferParams;
|
|
860
|
+
|
|
861
|
+
export declare enum TransferType {
|
|
862
|
+
ERC20 = "ERC20",
|
|
863
|
+
Native = "Native"
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
declare type TransitionData = BroadcastTxResponse | CombineTxResponse | SignTxResponse[] | PolicyBreachResponse | ProposeTxResponse | null;
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Thrown when parameters provided for a function are invalid.
|
|
870
|
+
*/
|
|
871
|
+
export declare class ValidationError extends Error {
|
|
872
|
+
readonly cause?: Error;
|
|
873
|
+
constructor(message: string, originalError?: Error);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
export declare class WrongChain extends Error {
|
|
877
|
+
readonly cause?: Error;
|
|
878
|
+
constructor(message: string, originalError?: Error);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
export { }
|