salt-sdk 0.0.2 → 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/README.md +32 -6
- package/dist/{ccip-BghU8qQS.js → ccip-nMOI806K.js} +1 -1
- package/dist/{index-DHF1u4T7.js → index-pLKoquxy.js} +74 -62
- package/dist/index.d.ts +12 -2
- package/dist/salt.es.js +23 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Salt SDK
|
|
2
2
|
|
|
3
|
+
## Prerequesites
|
|
4
|
+
|
|
5
|
+
We currently do not support account creation via the sdk. In order to use the sdk please visit https://testnet.salt.space. Once you're on Salt please create or join an Organisation and create an account.
|
|
6
|
+
|
|
3
7
|
## Usage
|
|
4
8
|
|
|
5
9
|
```typescript
|
|
@@ -40,17 +44,39 @@ const transfer = await sdk.transfer({
|
|
|
40
44
|
sendingProvider: broadcasting_network_provider,
|
|
41
45
|
});
|
|
42
46
|
|
|
43
|
-
//
|
|
47
|
+
//subscribe to state transition events
|
|
44
48
|
|
|
45
49
|
transfer.onTransition(0, 1, (data) => console.log('IDLE->PROPOSE:', data));
|
|
46
50
|
transfer.onTransition(1, 2, (data) => console.log('PROPOSE->SIGN:', data));
|
|
47
|
-
|
|
48
|
-
// in case of policy breach
|
|
49
51
|
transfer.onTransition(2, 5, (data) => console.log('SIGN->END:', data));
|
|
50
|
-
|
|
51
52
|
transfer.onTransition(2, 3, (data) => console.log('SIGN->COMBINE:', data));
|
|
52
53
|
transfer.onTransition(3, 4, (data) => console.log('COMBINE->BROADCAST:', data));
|
|
53
|
-
|
|
54
|
-
//transaction hash in the data
|
|
55
54
|
transfer.onTransition(4, 5, (data) => console.log('BROADCAST->END:', data));
|
|
56
55
|
```
|
|
56
|
+
|
|
57
|
+
## Transfer State Machine
|
|
58
|
+
|
|
59
|
+
```mermaid
|
|
60
|
+
stateDiagram-v2
|
|
61
|
+
[*] --> IDLE[0]
|
|
62
|
+
|
|
63
|
+
IDLE[0] --> PROPOSE[1] : Start Transfer
|
|
64
|
+
IDLE[0] --> END[5] : Error Starting Transfer
|
|
65
|
+
|
|
66
|
+
PROPOSE[1] --> SIGN[2] : Proposal Created
|
|
67
|
+
PROPOSE[1] --> END[5] : Policy Breach
|
|
68
|
+
|
|
69
|
+
SIGN[2] --> COMBINE[3] : collected_signatures >= signature_threshold
|
|
70
|
+
SIGN[2] --> END[5] : Error Signing
|
|
71
|
+
|
|
72
|
+
COMBINE[3] --> BROADCAST[4] : Signatures Combined
|
|
73
|
+
COMBINE[3] --> END[5] : Error Combining
|
|
74
|
+
|
|
75
|
+
BROADCAST[4] --> END[5] : Transaction Broadcasted
|
|
76
|
+
|
|
77
|
+
END[5] --> [*]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Notes
|
|
81
|
+
|
|
82
|
+
As of now the SDK is only available to use on TESTNETS via our testnet environment https://testnet.salt.space.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseError, g as getUrl, s as stringify, d as decodeErrorResult, i as isAddressEqual, l as localBatchGatewayUrl, a as localBatchGatewayRequest, c as call, b as concat, e as encodeAbiParameters, H as HttpRequestError, f as isHex } from "./index-
|
|
1
|
+
import { B as BaseError, g as getUrl, s as stringify, d as decodeErrorResult, i as isAddressEqual, l as localBatchGatewayUrl, a as localBatchGatewayRequest, c as call, b as concat, e as encodeAbiParameters, H as HttpRequestError, f as isHex } from "./index-pLKoquxy.js";
|
|
2
2
|
class OffchainLookupError extends BaseError {
|
|
3
3
|
constructor({ callbackSelector, cause, data, extraData, sender, urls }) {
|
|
4
4
|
super(cause.shortMessage || "An error occurred while fetching for an offchain result.", {
|
|
@@ -30408,7 +30408,7 @@ async function call(client2, args) {
|
|
|
30408
30408
|
return { data: response };
|
|
30409
30409
|
} catch (err) {
|
|
30410
30410
|
const data2 = getRevertErrorData(err);
|
|
30411
|
-
const { offchainLookup, offchainLookupSignature } = await import("./ccip-
|
|
30411
|
+
const { offchainLookup, offchainLookupSignature } = await import("./ccip-nMOI806K.js");
|
|
30412
30412
|
if (client2.ccipRead !== false && data2?.slice(0, 10) === offchainLookupSignature && to)
|
|
30413
30413
|
return { data: await offchainLookup(client2, { data: data2, to }) };
|
|
30414
30414
|
if (deploylessCall && data2?.slice(0, 10) === "0x101bb98d")
|
|
@@ -73849,6 +73849,49 @@ function requireSiwe() {
|
|
|
73849
73849
|
return siwe;
|
|
73850
73850
|
}
|
|
73851
73851
|
var siweExports = requireSiwe();
|
|
73852
|
+
const SIGNER_COUNTS = {
|
|
73853
|
+
twoHumans: {
|
|
73854
|
+
humanCount: 2,
|
|
73855
|
+
roboCount: 1,
|
|
73856
|
+
totalSigners: 3
|
|
73857
|
+
},
|
|
73858
|
+
threeHumans: {
|
|
73859
|
+
humanCount: 3,
|
|
73860
|
+
roboCount: 2,
|
|
73861
|
+
totalSigners: 5
|
|
73862
|
+
},
|
|
73863
|
+
fourHumans: {
|
|
73864
|
+
humanCount: 4,
|
|
73865
|
+
roboCount: 3,
|
|
73866
|
+
totalSigners: 7
|
|
73867
|
+
}
|
|
73868
|
+
};
|
|
73869
|
+
Math.min(
|
|
73870
|
+
...Object.values(SIGNER_COUNTS).map((config) => config.roboCount)
|
|
73871
|
+
);
|
|
73872
|
+
function getRoboConfigForAccountsize(accountSize) {
|
|
73873
|
+
const robo_count = Object.values(SIGNER_COUNTS).find(
|
|
73874
|
+
(config) => config.totalSigners === accountSize
|
|
73875
|
+
)?.roboCount;
|
|
73876
|
+
if (!robo_count) {
|
|
73877
|
+
throw new Error(
|
|
73878
|
+
`Invalid account size: ${accountSize}. Must be either ${SIGNER_COUNTS.twoHumans.totalSigners}, ${SIGNER_COUNTS.threeHumans.totalSigners} or ${SIGNER_COUNTS.fourHumans.totalSigners}`
|
|
73879
|
+
);
|
|
73880
|
+
}
|
|
73881
|
+
return robo_count;
|
|
73882
|
+
}
|
|
73883
|
+
class SocketConnectError extends Error {
|
|
73884
|
+
cause;
|
|
73885
|
+
constructor(message, originalError) {
|
|
73886
|
+
super(message);
|
|
73887
|
+
this.name = "SocketConnectError";
|
|
73888
|
+
this.cause = originalError;
|
|
73889
|
+
if (originalError?.stack) {
|
|
73890
|
+
this.stack = `${this.stack}
|
|
73891
|
+
Caused by: ${originalError.stack}`;
|
|
73892
|
+
}
|
|
73893
|
+
}
|
|
73894
|
+
}
|
|
73852
73895
|
class InvalidTransitionError extends Error {
|
|
73853
73896
|
cause;
|
|
73854
73897
|
constructor(message, originalError) {
|
|
@@ -73878,6 +73921,15 @@ async function signTransaction(txId, params) {
|
|
|
73878
73921
|
throw new Error("Invalid sign result");
|
|
73879
73922
|
}
|
|
73880
73923
|
}
|
|
73924
|
+
var TRANSFER_STATES = /* @__PURE__ */ ((TRANSFER_STATES2) => {
|
|
73925
|
+
TRANSFER_STATES2[TRANSFER_STATES2["IDLE"] = 0] = "IDLE";
|
|
73926
|
+
TRANSFER_STATES2[TRANSFER_STATES2["PROPOSE"] = 1] = "PROPOSE";
|
|
73927
|
+
TRANSFER_STATES2[TRANSFER_STATES2["SIGN"] = 2] = "SIGN";
|
|
73928
|
+
TRANSFER_STATES2[TRANSFER_STATES2["COMBINE"] = 3] = "COMBINE";
|
|
73929
|
+
TRANSFER_STATES2[TRANSFER_STATES2["BROADCAST"] = 4] = "BROADCAST";
|
|
73930
|
+
TRANSFER_STATES2[TRANSFER_STATES2["END"] = 5] = "END";
|
|
73931
|
+
return TRANSFER_STATES2;
|
|
73932
|
+
})(TRANSFER_STATES || {});
|
|
73881
73933
|
const validTransitions = {
|
|
73882
73934
|
[
|
|
73883
73935
|
0
|
|
@@ -74165,49 +74217,6 @@ class Transfer {
|
|
|
74165
74217
|
return true;
|
|
74166
74218
|
}
|
|
74167
74219
|
}
|
|
74168
|
-
const SIGNER_COUNTS = {
|
|
74169
|
-
twoHumans: {
|
|
74170
|
-
humanCount: 2,
|
|
74171
|
-
roboCount: 1,
|
|
74172
|
-
totalSigners: 3
|
|
74173
|
-
},
|
|
74174
|
-
threeHumans: {
|
|
74175
|
-
humanCount: 3,
|
|
74176
|
-
roboCount: 2,
|
|
74177
|
-
totalSigners: 5
|
|
74178
|
-
},
|
|
74179
|
-
fourHumans: {
|
|
74180
|
-
humanCount: 4,
|
|
74181
|
-
roboCount: 3,
|
|
74182
|
-
totalSigners: 7
|
|
74183
|
-
}
|
|
74184
|
-
};
|
|
74185
|
-
Math.min(
|
|
74186
|
-
...Object.values(SIGNER_COUNTS).map((config) => config.roboCount)
|
|
74187
|
-
);
|
|
74188
|
-
function getRoboConfigForAccountsize(accountSize) {
|
|
74189
|
-
const robo_count = Object.values(SIGNER_COUNTS).find(
|
|
74190
|
-
(config) => config.totalSigners === accountSize
|
|
74191
|
-
)?.roboCount;
|
|
74192
|
-
if (!robo_count) {
|
|
74193
|
-
throw new Error(
|
|
74194
|
-
`Invalid account size: ${accountSize}. Must be either ${SIGNER_COUNTS.twoHumans.totalSigners}, ${SIGNER_COUNTS.threeHumans.totalSigners} or ${SIGNER_COUNTS.fourHumans.totalSigners}`
|
|
74195
|
-
);
|
|
74196
|
-
}
|
|
74197
|
-
return robo_count;
|
|
74198
|
-
}
|
|
74199
|
-
class SocketConnectError extends Error {
|
|
74200
|
-
cause;
|
|
74201
|
-
constructor(message, originalError) {
|
|
74202
|
-
super(message);
|
|
74203
|
-
this.name = "SocketConnectError";
|
|
74204
|
-
this.cause = originalError;
|
|
74205
|
-
if (originalError?.stack) {
|
|
74206
|
-
this.stack = `${this.stack}
|
|
74207
|
-
Caused by: ${originalError.stack}`;
|
|
74208
|
-
}
|
|
74209
|
-
}
|
|
74210
|
-
}
|
|
74211
74220
|
if (typeof window !== "undefined") {
|
|
74212
74221
|
window.process = {
|
|
74213
74222
|
env: {
|
|
@@ -74394,15 +74403,18 @@ class Salt {
|
|
|
74394
74403
|
}
|
|
74395
74404
|
}
|
|
74396
74405
|
export {
|
|
74397
|
-
|
|
74406
|
+
assertValidValue as A,
|
|
74398
74407
|
BaseError$1 as B,
|
|
74399
|
-
|
|
74400
|
-
|
|
74401
|
-
|
|
74402
|
-
|
|
74403
|
-
|
|
74408
|
+
InvalidParams as C,
|
|
74409
|
+
assertValidParams as D,
|
|
74410
|
+
InvalidProvider as E,
|
|
74411
|
+
assertValidProvider as F,
|
|
74412
|
+
InvalidSigner as G,
|
|
74404
74413
|
HttpRequestError as H,
|
|
74405
74414
|
InvalidAuthToken as I,
|
|
74415
|
+
assertValidSigner as J,
|
|
74416
|
+
assertCorrectChain as K,
|
|
74417
|
+
InsufficientGas as L,
|
|
74406
74418
|
Salt as S,
|
|
74407
74419
|
TransferType as T,
|
|
74408
74420
|
ValidationError as V,
|
|
@@ -74419,18 +74431,18 @@ export {
|
|
|
74419
74431
|
InvalidAddress as j,
|
|
74420
74432
|
InvalidValue as k,
|
|
74421
74433
|
localBatchGatewayUrl as l,
|
|
74422
|
-
|
|
74423
|
-
|
|
74424
|
-
|
|
74434
|
+
Transfer as m,
|
|
74435
|
+
TRANSFER_STATES as n,
|
|
74436
|
+
assertValidAddress as o,
|
|
74425
74437
|
process as p,
|
|
74426
|
-
|
|
74427
|
-
|
|
74438
|
+
InvalidUrl as q,
|
|
74439
|
+
assertValidUrl as r,
|
|
74428
74440
|
stringify$2 as s,
|
|
74429
|
-
|
|
74430
|
-
|
|
74431
|
-
|
|
74432
|
-
|
|
74433
|
-
|
|
74434
|
-
|
|
74435
|
-
|
|
74441
|
+
assertValidUrlNoTrailingSlash as t,
|
|
74442
|
+
InvalidEnvironment as u,
|
|
74443
|
+
validTransitions as v,
|
|
74444
|
+
assertValidEnvironment as w,
|
|
74445
|
+
assertHasAuthToken as x,
|
|
74446
|
+
assertValidAuthToken as y,
|
|
74447
|
+
assertValidChain as z
|
|
74436
74448
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -644,6 +644,14 @@ declare interface SignTxResponse {
|
|
|
644
644
|
locked?: boolean;
|
|
645
645
|
}
|
|
646
646
|
|
|
647
|
+
export declare type STATE_TRANSITIONS = {
|
|
648
|
+
[TRANSFER_STATES.PROPOSE]: TRANSFER_STATES.SIGN | TRANSFER_STATES.END;
|
|
649
|
+
[TRANSFER_STATES.SIGN]: TRANSFER_STATES.COMBINE | TRANSFER_STATES.END;
|
|
650
|
+
[TRANSFER_STATES.COMBINE]: TRANSFER_STATES.BROADCAST | TRANSFER_STATES.END;
|
|
651
|
+
[TRANSFER_STATES.BROADCAST]: TRANSFER_STATES.END;
|
|
652
|
+
[TRANSFER_STATES.END]: never;
|
|
653
|
+
};
|
|
654
|
+
|
|
647
655
|
declare type StateTransitionHandler = (data: TransitionData) => void | Promise<void>;
|
|
648
656
|
|
|
649
657
|
declare interface SubmitTransactionResult {
|
|
@@ -781,7 +789,7 @@ export declare interface TransactionParams {
|
|
|
781
789
|
vaultPublicKey: string;
|
|
782
790
|
}
|
|
783
791
|
|
|
784
|
-
declare class Transfer {
|
|
792
|
+
export declare class Transfer {
|
|
785
793
|
/**
|
|
786
794
|
* The authentication token for the Salt SDK. See {@link authenticate} for the full authentication flow,
|
|
787
795
|
* or {@link setAuthToken} to set a pre-existing token.
|
|
@@ -854,7 +862,7 @@ declare class Transfer {
|
|
|
854
862
|
submitTransaction(): Promise<boolean>;
|
|
855
863
|
}
|
|
856
864
|
|
|
857
|
-
declare enum TRANSFER_STATES {
|
|
865
|
+
export declare enum TRANSFER_STATES {
|
|
858
866
|
IDLE = 0,
|
|
859
867
|
PROPOSE = 1,
|
|
860
868
|
SIGN = 2,
|
|
@@ -880,6 +888,8 @@ export declare class ValidationError extends Error {
|
|
|
880
888
|
constructor(message: string, originalError?: Error);
|
|
881
889
|
}
|
|
882
890
|
|
|
891
|
+
export declare const validTransitions: Record<TRANSFER_STATES, TRANSFER_STATES[]>;
|
|
892
|
+
|
|
883
893
|
export declare class WrongChain extends Error {
|
|
884
894
|
readonly cause?: Error;
|
|
885
895
|
constructor(message: string, originalError?: Error);
|
package/dist/salt.es.js
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { L, j, I, h, u, C, E, G, q, k, S, n, m, T, V, W, K, x, o, y, z, w, D, F, J, r, t, A, p, v } from "./index-pLKoquxy.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
L as InsufficientGas,
|
|
4
4
|
j as InvalidAddress,
|
|
5
5
|
I as InvalidAuthToken,
|
|
6
6
|
h as InvalidChain,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
u as InvalidEnvironment,
|
|
8
|
+
C as InvalidParams,
|
|
9
|
+
E as InvalidProvider,
|
|
10
|
+
G as InvalidSigner,
|
|
11
|
+
q as InvalidUrl,
|
|
12
12
|
k as InvalidValue,
|
|
13
13
|
S as Salt,
|
|
14
|
+
n as TRANSFER_STATES,
|
|
15
|
+
m as Transfer,
|
|
14
16
|
T as TransferType,
|
|
15
17
|
V as ValidationError,
|
|
16
18
|
W as WrongChain,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
p as process
|
|
19
|
+
K as assertCorrectChain,
|
|
20
|
+
x as assertHasAuthToken,
|
|
21
|
+
o as assertValidAddress,
|
|
22
|
+
y as assertValidAuthToken,
|
|
23
|
+
z as assertValidChain,
|
|
24
|
+
w as assertValidEnvironment,
|
|
25
|
+
D as assertValidParams,
|
|
26
|
+
F as assertValidProvider,
|
|
27
|
+
J as assertValidSigner,
|
|
28
|
+
r as assertValidUrl,
|
|
29
|
+
t as assertValidUrlNoTrailingSlash,
|
|
30
|
+
A as assertValidValue,
|
|
31
|
+
p as process,
|
|
32
|
+
v as validTransitions
|
|
30
33
|
};
|