salt-sdk 0.0.5 → 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/README.md +9 -7
- package/dist/browser-Dmczxitw.js +41 -0
- package/dist/{ccip-Z1D2kqng.js → ccip-BaZlwqki.js} +1 -1
- package/dist/{index-Dnnec9n9.js → index-DgJYJqk3.js} +183 -146
- package/dist/index.d.ts +11 -1
- package/dist/salt.es.js +23 -23
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ await sdk.authenticate(signer);
|
|
|
33
33
|
const orgs = await sdk.getOrganisations();
|
|
34
34
|
const accounts = await sdk.getAccounts(orgs[0]._id);
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const transactionObj = await sdk.transfer({
|
|
37
37
|
accountId: accounts[0].id,
|
|
38
38
|
to: '0xaD94c511350Cced6DcffCcC34D36558Db86a42A8',
|
|
39
39
|
value: '0.0001',
|
|
@@ -46,12 +46,14 @@ const transfer = await sdk.transfer({
|
|
|
46
46
|
|
|
47
47
|
//subscribe to state transition events
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
transactionObj.onPropose((data) => console.log(data));
|
|
50
|
+
transactionObj.onSign((data) => console.log(data));
|
|
51
|
+
transactionObj.onCombine((data) => console.log(data));
|
|
52
|
+
transactionObj.onBroadcast((data) => console.log(data));
|
|
53
|
+
transactionObj.onEnd((data) => console.log(data));
|
|
54
|
+
transactionObj.onTransition(4, 5, (data) =>
|
|
55
|
+
console.log('BROADCAST->END:', data)
|
|
56
|
+
);
|
|
55
57
|
```
|
|
56
58
|
|
|
57
59
|
## Transfer State Machine
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { g as getDefaultExportFromCjs } from "./index-DgJYJqk3.js";
|
|
2
|
+
function _mergeNamespaces(n, m) {
|
|
3
|
+
for (var i = 0; i < m.length; i++) {
|
|
4
|
+
const e = m[i];
|
|
5
|
+
if (typeof e !== "string" && !Array.isArray(e)) {
|
|
6
|
+
for (const k in e) {
|
|
7
|
+
if (k !== "default" && !(k in n)) {
|
|
8
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
9
|
+
if (d) {
|
|
10
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: () => e[k]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
|
|
20
|
+
}
|
|
21
|
+
var browser$2;
|
|
22
|
+
var hasRequiredBrowser;
|
|
23
|
+
function requireBrowser() {
|
|
24
|
+
if (hasRequiredBrowser) return browser$2;
|
|
25
|
+
hasRequiredBrowser = 1;
|
|
26
|
+
browser$2 = function() {
|
|
27
|
+
throw new Error(
|
|
28
|
+
"ws does not work in the browser. Browser clients must use the native WebSocket object"
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
return browser$2;
|
|
32
|
+
}
|
|
33
|
+
var browserExports = requireBrowser();
|
|
34
|
+
const browser = /* @__PURE__ */ getDefaultExportFromCjs(browserExports);
|
|
35
|
+
const browser$1 = /* @__PURE__ */ _mergeNamespaces({
|
|
36
|
+
__proto__: null,
|
|
37
|
+
default: browser
|
|
38
|
+
}, [browserExports]);
|
|
39
|
+
export {
|
|
40
|
+
browser$1 as b
|
|
41
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseError,
|
|
1
|
+
import { B as BaseError, a as getUrl, s as stringify, d as decodeErrorResult, i as isAddressEqual, l as localBatchGatewayUrl, b as localBatchGatewayRequest, c as call, e as concat, f as encodeAbiParameters, H as HttpRequestError, h as isHex } from "./index-DgJYJqk3.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.", {
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
import { io } from "socket.io-client";
|
|
2
|
-
function _mergeNamespaces(n, m) {
|
|
3
|
-
for (var i = 0; i < m.length; i++) {
|
|
4
|
-
const e = m[i];
|
|
5
|
-
if (typeof e !== "string" && !Array.isArray(e)) {
|
|
6
|
-
for (const k in e) {
|
|
7
|
-
if (k !== "default" && !(k in n)) {
|
|
8
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
9
|
-
if (d) {
|
|
10
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: () => e[k]
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
|
|
20
|
-
}
|
|
21
2
|
function getDefaultExportFromCjs$1(x) {
|
|
22
3
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
23
4
|
}
|
|
@@ -10323,14 +10304,14 @@ var utils_1$1 = createCommonjsModule(function(module2, exports) {
|
|
|
10323
10304
|
for (i = 0; i < naf.length; i += 1) {
|
|
10324
10305
|
naf[i] = 0;
|
|
10325
10306
|
}
|
|
10326
|
-
var
|
|
10307
|
+
var ws = 1 << w + 1;
|
|
10327
10308
|
var k = num.clone();
|
|
10328
10309
|
for (i = 0; i < naf.length; i++) {
|
|
10329
10310
|
var z;
|
|
10330
|
-
var mod2 = k.andln(
|
|
10311
|
+
var mod2 = k.andln(ws - 1);
|
|
10331
10312
|
if (k.isOdd()) {
|
|
10332
|
-
if (mod2 > (
|
|
10333
|
-
z = (
|
|
10313
|
+
if (mod2 > (ws >> 1) - 1)
|
|
10314
|
+
z = (ws >> 1) - mod2;
|
|
10334
10315
|
else
|
|
10335
10316
|
z = mod2;
|
|
10336
10317
|
k.isubn(z);
|
|
@@ -30439,7 +30420,7 @@ async function call(client2, args) {
|
|
|
30439
30420
|
return { data: response };
|
|
30440
30421
|
} catch (err) {
|
|
30441
30422
|
const data2 = getRevertErrorData(err);
|
|
30442
|
-
const { offchainLookup, offchainLookupSignature } = await import("./ccip-
|
|
30423
|
+
const { offchainLookup, offchainLookupSignature } = await import("./ccip-BaZlwqki.js");
|
|
30443
30424
|
if (client2.ccipRead !== false && data2?.slice(0, 10) === offchainLookupSignature && to)
|
|
30444
30425
|
return { data: await offchainLookup(client2, { data: data2, to }) };
|
|
30445
30426
|
if (deploylessCall && data2?.slice(0, 10) === "0x101bb98d")
|
|
@@ -39666,44 +39647,9 @@ const ARBITRUM_SEPOLIA_GRAPHQL_ENDPOINT = "https://indexer.hyperindex.xyz/501af9
|
|
|
39666
39647
|
const XFI_GRAPHQL_ENDPOINT = "https://graph.intu.xyz/subgraphs/name/xfi-test2/";
|
|
39667
39648
|
const ARBITRUM_ONE_GRAPHQL_ENDPOINT = "https://indexer.hyperindex.xyz/4eaacee/v1/graphql";
|
|
39668
39649
|
const ETHERLINK_GRAPHQL_ENDPOINT = "https://rpc.intu.xyz/graph/subgraphs/name/etherlink";
|
|
39669
|
-
const
|
|
39670
|
-
|
|
39671
|
-
};
|
|
39672
|
-
let _cachedActiveNetwork = null;
|
|
39673
|
-
const getActiveNetworkCached = () => {
|
|
39674
|
-
if (_cachedActiveNetwork === null) {
|
|
39675
|
-
_cachedActiveNetwork = getActiveNetwork().toLowerCase();
|
|
39676
|
-
console.log("🔧 [Constants] Computing ACTIVE_NETWORK:", _cachedActiveNetwork);
|
|
39677
|
-
console.log("🔧 [Constants] Available env vars:", {
|
|
39678
|
-
INTU_NETWORK: "testnet",
|
|
39679
|
-
REACT_APP_INTU_NETWORK: process.env.REACT_APP_INTU_NETWORK
|
|
39680
|
-
});
|
|
39681
|
-
}
|
|
39682
|
-
return _cachedActiveNetwork;
|
|
39683
|
-
};
|
|
39684
|
-
function endpointFromNetworkAlias() {
|
|
39685
|
-
const activeNetwork = getActiveNetworkCached();
|
|
39686
|
-
switch (activeNetwork) {
|
|
39687
|
-
case "arbitrum-main":
|
|
39688
|
-
case "arbitrum-mainnet":
|
|
39689
|
-
case "arbitrum-one":
|
|
39690
|
-
case "mainnet":
|
|
39691
|
-
case "main":
|
|
39692
|
-
case "arbitrum":
|
|
39693
|
-
return ARBITRUM_ONE_GRAPHQL_ENDPOINT;
|
|
39694
|
-
case "arbitrum-sepolia":
|
|
39695
|
-
case "sepolia":
|
|
39696
|
-
case "testnet":
|
|
39697
|
-
return ARBITRUM_SEPOLIA_GRAPHQL_ENDPOINT;
|
|
39698
|
-
default:
|
|
39699
|
-
return void 0;
|
|
39700
|
-
}
|
|
39701
|
-
}
|
|
39650
|
+
const GOLD_SKY_ARBITRUM_SEPOLIA_GRAPHQL_ENDPOINT = "https://api.goldsky.com/api/public/project_cm1jkqjytq51s01yr9q6h3idj/subgraphs/intu-arb-sepolia/1.0.0/gn";
|
|
39651
|
+
const GOLD_SKY_ARBITRUM_MAINNET_GRAPHQL_ENDPOINT = "https://api.goldsky.com/api/public/project_cm1jkqjytq51s01yr9q6h3idj/subgraphs/intu-arb-main/0.0.1/gn";
|
|
39702
39652
|
const getGraphEndpoint = (chainId) => {
|
|
39703
|
-
const aliasEndpoint = endpointFromNetworkAlias();
|
|
39704
|
-
if (aliasEndpoint) {
|
|
39705
|
-
return aliasEndpoint;
|
|
39706
|
-
}
|
|
39707
39653
|
if (chainId === 4157) {
|
|
39708
39654
|
return XFI_GRAPHQL_ENDPOINT;
|
|
39709
39655
|
} else if (chainId === 421614) {
|
|
@@ -39716,6 +39662,15 @@ const getGraphEndpoint = (chainId) => {
|
|
|
39716
39662
|
return ARBITRUM_ONE_GRAPHQL_ENDPOINT;
|
|
39717
39663
|
}
|
|
39718
39664
|
};
|
|
39665
|
+
const getBackupGraphEndpoint = (chainId) => {
|
|
39666
|
+
if (chainId === 421614) {
|
|
39667
|
+
return GOLD_SKY_ARBITRUM_SEPOLIA_GRAPHQL_ENDPOINT;
|
|
39668
|
+
} else if (chainId === 42161) {
|
|
39669
|
+
return GOLD_SKY_ARBITRUM_MAINNET_GRAPHQL_ENDPOINT;
|
|
39670
|
+
} else {
|
|
39671
|
+
return GOLD_SKY_ARBITRUM_SEPOLIA_GRAPHQL_ENDPOINT;
|
|
39672
|
+
}
|
|
39673
|
+
};
|
|
39719
39674
|
const BNB_TESTNET = defineChain({
|
|
39720
39675
|
id: 97,
|
|
39721
39676
|
name: "BNB Chain Testnet",
|
|
@@ -39814,8 +39769,11 @@ const constants = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePro
|
|
|
39814
39769
|
ARBITRUM_ONE_GRAPHQL_ENDPOINT,
|
|
39815
39770
|
ARBITRUM_SEPOLIA_GRAPHQL_ENDPOINT,
|
|
39816
39771
|
ETHERLINK_GRAPHQL_ENDPOINT,
|
|
39772
|
+
GOLD_SKY_ARBITRUM_MAINNET_GRAPHQL_ENDPOINT,
|
|
39773
|
+
GOLD_SKY_ARBITRUM_SEPOLIA_GRAPHQL_ENDPOINT,
|
|
39817
39774
|
XFI_GRAPHQL_ENDPOINT,
|
|
39818
39775
|
chainConfig,
|
|
39776
|
+
getBackupGraphEndpoint,
|
|
39819
39777
|
getGraphEndpoint
|
|
39820
39778
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
39821
39779
|
let VaultJson$1;
|
|
@@ -43592,29 +43550,19 @@ const parseRequestExtendedArgs = (urlOrOptions, document, ...variablesAndRequest
|
|
|
43592
43550
|
const gql = (chunks, ...variables) => {
|
|
43593
43551
|
return chunks.reduce((acc, chunk, index2) => `${acc}${chunk}${index2 in variables ? String(variables[index2]) : ``}`, ``);
|
|
43594
43552
|
};
|
|
43595
|
-
var browser$3;
|
|
43596
|
-
var hasRequiredBrowser$2;
|
|
43597
|
-
function requireBrowser$2() {
|
|
43598
|
-
if (hasRequiredBrowser$2) return browser$3;
|
|
43599
|
-
hasRequiredBrowser$2 = 1;
|
|
43600
|
-
browser$3 = function() {
|
|
43601
|
-
throw new Error(
|
|
43602
|
-
"ws does not work in the browser. Browser clients must use the native WebSocket object"
|
|
43603
|
-
);
|
|
43604
|
-
};
|
|
43605
|
-
return browser$3;
|
|
43606
|
-
}
|
|
43607
|
-
var browserExports$1 = requireBrowser$2();
|
|
43608
|
-
const ws = /* @__PURE__ */ getDefaultExportFromCjs$1(browserExports$1);
|
|
43609
|
-
const browser$2 = /* @__PURE__ */ _mergeNamespaces({
|
|
43610
|
-
__proto__: null,
|
|
43611
|
-
default: ws
|
|
43612
|
-
}, [browserExports$1]);
|
|
43613
43553
|
const isBrowser = typeof window !== "undefined";
|
|
43614
43554
|
if (!isBrowser) {
|
|
43615
|
-
|
|
43555
|
+
try {
|
|
43556
|
+
import("./browser-Dmczxitw.js").then((n) => n.b).then((ws) => {
|
|
43557
|
+
globalThis.WebSocket = ws.default || ws;
|
|
43558
|
+
}).catch((error) => {
|
|
43559
|
+
console.warn("WebSocket polyfill not available:", error);
|
|
43560
|
+
});
|
|
43561
|
+
} catch (error) {
|
|
43562
|
+
console.warn("WebSocket polyfill not available:", error);
|
|
43563
|
+
}
|
|
43616
43564
|
}
|
|
43617
|
-
const isHyperindex = (url) => true;
|
|
43565
|
+
const isHyperindex = (url) => url ? url.includes("indexer.hyperindex.xyz") : true;
|
|
43618
43566
|
const standardQueries = {
|
|
43619
43567
|
getVaultTransactions: ({ vaultAddress }) => `
|
|
43620
43568
|
query {
|
|
@@ -43791,9 +43739,9 @@ const standardQueries = {
|
|
|
43791
43739
|
}
|
|
43792
43740
|
`
|
|
43793
43741
|
};
|
|
43794
|
-
|
|
43742
|
+
const arbitrumSepoliaGoldskyQueries = {
|
|
43795
43743
|
...standardQueries
|
|
43796
|
-
}
|
|
43744
|
+
};
|
|
43797
43745
|
const arbitrumSepoliaQueries = {
|
|
43798
43746
|
getVaultTransactions: ({ vaultAddress }) => `
|
|
43799
43747
|
query {
|
|
@@ -43903,33 +43851,73 @@ const arbitrumSepoliaQueries = {
|
|
|
43903
43851
|
};
|
|
43904
43852
|
const getQuery = (queryName, chainId, params, endpoint2) => {
|
|
43905
43853
|
if (chainId === 421614) {
|
|
43906
|
-
|
|
43854
|
+
if (endpoint2 === "goldsky") {
|
|
43855
|
+
return arbitrumSepoliaGoldskyQueries[queryName](params);
|
|
43856
|
+
}
|
|
43857
|
+
const tmpl = isHyperindex(endpoint2) ? arbitrumSepoliaQueries : arbitrumSepoliaGoldskyQueries;
|
|
43907
43858
|
return tmpl[queryName](params);
|
|
43908
43859
|
}
|
|
43909
|
-
if (chainId === 42161
|
|
43910
|
-
|
|
43860
|
+
if (chainId === 42161) {
|
|
43861
|
+
if (endpoint2 === "goldsky") {
|
|
43862
|
+
return standardQueries[queryName](params);
|
|
43863
|
+
}
|
|
43864
|
+
if (isHyperindex(endpoint2)) {
|
|
43865
|
+
return arbitrumSepoliaQueries[queryName](params);
|
|
43866
|
+
}
|
|
43911
43867
|
}
|
|
43912
43868
|
return standardQueries[queryName](params);
|
|
43913
43869
|
};
|
|
43870
|
+
const graph = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
43871
|
+
__proto__: null,
|
|
43872
|
+
getQuery
|
|
43873
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
43914
43874
|
async function fetchSubgraphData(chainId, query) {
|
|
43915
43875
|
const primaryEndpoint = getGraphEndpoint(chainId);
|
|
43916
|
-
const goldskyBackup =
|
|
43876
|
+
const goldskyBackup = getBackupGraphEndpoint(chainId);
|
|
43877
|
+
console.debug(`🌐 [FETCH_SUBGRAPH] Primary endpoint (Hyperindex): ${primaryEndpoint}`);
|
|
43878
|
+
console.debug(`🌐 [FETCH_SUBGRAPH] Backup endpoint (Goldsky): ${goldskyBackup}`);
|
|
43917
43879
|
try {
|
|
43880
|
+
console.debug(`📡 [FETCH_SUBGRAPH] Attempting primary request to Hyperindex...`);
|
|
43918
43881
|
const response = await request(primaryEndpoint, query);
|
|
43919
|
-
if (response)
|
|
43882
|
+
if (response && Object.keys(response).length > 0) {
|
|
43883
|
+
console.debug(`✅ [FETCH_SUBGRAPH] Primary Hyperindex request successful`);
|
|
43920
43884
|
return response;
|
|
43921
|
-
|
|
43922
|
-
|
|
43885
|
+
}
|
|
43886
|
+
console.debug(`⚠️ [FETCH_SUBGRAPH] Primary Hyperindex returned empty data, trying Goldsky backup...`);
|
|
43887
|
+
const goldskyQuery = await getGoldskyQuery(chainId, query);
|
|
43888
|
+
const backupResponse = await request(goldskyBackup, goldskyQuery);
|
|
43889
|
+
console.debug(`✅ [FETCH_SUBGRAPH] Goldsky backup request successful`);
|
|
43890
|
+
return backupResponse;
|
|
43923
43891
|
} catch (err) {
|
|
43924
|
-
console.
|
|
43892
|
+
console.debug(`❌ [FETCH_SUBGRAPH] Primary Hyperindex error:`, err?.message || err);
|
|
43925
43893
|
try {
|
|
43926
|
-
|
|
43894
|
+
console.debug(`📡 [FETCH_SUBGRAPH] Attempting backup request to Goldsky...`);
|
|
43895
|
+
const goldskyQuery = await getGoldskyQuery(chainId, query);
|
|
43896
|
+
const backupResponse = await request(goldskyBackup, goldskyQuery);
|
|
43897
|
+
console.debug(`✅ [FETCH_SUBGRAPH] Goldsky backup request successful`);
|
|
43898
|
+
return backupResponse;
|
|
43927
43899
|
} catch (backupErr) {
|
|
43928
|
-
console.
|
|
43900
|
+
console.debug(`❌ [FETCH_SUBGRAPH] Goldsky backup error:`, backupErr?.message || backupErr);
|
|
43901
|
+
console.debug(`❌ [FETCH_SUBGRAPH] Both data sources failed for chainId ${chainId}`);
|
|
43929
43902
|
return null;
|
|
43930
43903
|
}
|
|
43931
43904
|
}
|
|
43932
43905
|
}
|
|
43906
|
+
async function getGoldskyQuery(chainId, hyperindexQuery) {
|
|
43907
|
+
const { getQuery: getQuery2 } = await Promise.resolve().then(() => graph);
|
|
43908
|
+
const vaultAddressMatch = hyperindexQuery.match(/vaultAddress.*?_ilike.*?"([^"]+)"/);
|
|
43909
|
+
const txIdMatch = hyperindexQuery.match(/txId.*?_eq.*?"([^"]+)"/);
|
|
43910
|
+
if (vaultAddressMatch && txIdMatch) {
|
|
43911
|
+
const vaultAddress = vaultAddressMatch[1];
|
|
43912
|
+
const txId = txIdMatch[1];
|
|
43913
|
+
return getQuery2("getTransactionById", chainId, { vaultAddress, txId }, "goldsky");
|
|
43914
|
+
} else if (vaultAddressMatch) {
|
|
43915
|
+
const vaultAddress = vaultAddressMatch[1];
|
|
43916
|
+
return getQuery2("getVaultTransactions", chainId, { vaultAddress }, "goldsky");
|
|
43917
|
+
}
|
|
43918
|
+
console.warn("⚠️ [GOLDSKY_QUERY] Could not convert query, using original");
|
|
43919
|
+
return hyperindexQuery;
|
|
43920
|
+
}
|
|
43933
43921
|
async function getUserIndex(vaultAddress, userAddress, provider) {
|
|
43934
43922
|
const client2 = await createViemClient(provider);
|
|
43935
43923
|
const vaultContract = await getVaultContractViem(vaultAddress, client2);
|
|
@@ -44164,9 +44152,21 @@ async function _getTransactionLean(vaultAddress, txId, provider) {
|
|
|
44164
44152
|
const query = gql`
|
|
44165
44153
|
${queryString}
|
|
44166
44154
|
`;
|
|
44155
|
+
console.log(`📡 [GET_TX_LEAN] Fetching transaction data from subgraph for txId ${txId} on chain ${chainId}`);
|
|
44167
44156
|
try {
|
|
44168
44157
|
const data = await fetchSubgraphData(chainId, query);
|
|
44169
44158
|
const resultKey = chainId === 421614 || chainId === 42161 ? "TransactionProposed" : "transactionProposeds";
|
|
44159
|
+
if (!data || !data[resultKey] || data[resultKey].length === 0) {
|
|
44160
|
+
console.warn(`⚠️ [GET_TX_LEAN] No transaction data found for txId ${txId}. Data sources may be indexing.`);
|
|
44161
|
+
console.log(`📊 [GET_TX_LEAN] Available data keys:`, data ? Object.keys(data) : "null");
|
|
44162
|
+
return {
|
|
44163
|
+
id: id2.toNumber(),
|
|
44164
|
+
transactionData: "",
|
|
44165
|
+
transactionNotes: "",
|
|
44166
|
+
signedTransactionsNeeded: Number(votesNeeded),
|
|
44167
|
+
userSignedTransactions: []
|
|
44168
|
+
};
|
|
44169
|
+
}
|
|
44170
44170
|
const transaction = {
|
|
44171
44171
|
id: id2.toNumber(),
|
|
44172
44172
|
transactionData: data[resultKey][0].transactionInfo,
|
|
@@ -44174,10 +44174,12 @@ async function _getTransactionLean(vaultAddress, txId, provider) {
|
|
|
44174
44174
|
signedTransactionsNeeded: Number(votesNeeded),
|
|
44175
44175
|
userSignedTransactions: []
|
|
44176
44176
|
};
|
|
44177
|
+
console.log(`✅ [GET_TX_LEAN] Successfully retrieved transaction data for txId ${txId}`);
|
|
44177
44178
|
return transaction;
|
|
44178
44179
|
} catch (error) {
|
|
44180
|
+
console.error(`❌ [GET_TX_LEAN] Error fetching transaction ${txId}:`, error);
|
|
44179
44181
|
return {
|
|
44180
|
-
id:
|
|
44182
|
+
id: id2.toNumber(),
|
|
44181
44183
|
transactionData: "",
|
|
44182
44184
|
transactionNotes: "",
|
|
44183
44185
|
signedTransactionsNeeded: Number(votesNeeded),
|
|
@@ -44211,7 +44213,19 @@ const getProviderForChain = (chainId) => {
|
|
|
44211
44213
|
(async () => {
|
|
44212
44214
|
await loadJson(JSON_PATHS.VAULT);
|
|
44213
44215
|
})();
|
|
44214
|
-
async
|
|
44216
|
+
if ((async () => {
|
|
44217
|
+
var e = await Promise.resolve().then(() => constants);
|
|
44218
|
+
e.getGraphEndpoint;
|
|
44219
|
+
})(), "undefined" == typeof window) try {
|
|
44220
|
+
import("./browser-Dmczxitw.js").then((n) => n.b).then((e) => {
|
|
44221
|
+
globalThis.WebSocket = e.default || e;
|
|
44222
|
+
}).catch((e) => {
|
|
44223
|
+
console.warn("WebSocket polyfill not available:", e);
|
|
44224
|
+
});
|
|
44225
|
+
} catch (e) {
|
|
44226
|
+
console.warn("WebSocket polyfill not available:", e);
|
|
44227
|
+
}
|
|
44228
|
+
async function submitTransaction$1(e, t, a, r2, n, o, i, s, l, g = "n/a", c = false, p) {
|
|
44215
44229
|
var d = /* @__PURE__ */ new Date();
|
|
44216
44230
|
let _;
|
|
44217
44231
|
_ = p ? "string" == typeof p ? new StaticJsonRpcProvider(p) : p : await getProviderForChain(a);
|
|
@@ -44219,10 +44233,10 @@ async function submitTransaction$1(e, t, a, r2, n, i, o, s, l, g = "n/a", c = fa
|
|
|
44219
44233
|
await l.getAddress();
|
|
44220
44234
|
let u;
|
|
44221
44235
|
var h = await _.getFeeData();
|
|
44222
|
-
if (null ==
|
|
44236
|
+
if (null == o || "" === o) {
|
|
44223
44237
|
if (!h.gasPrice) throw new Error("Unable to determine gas price");
|
|
44224
44238
|
u = h.gasPrice.mul(105).div(100);
|
|
44225
|
-
} else u = BigNumber.from(
|
|
44239
|
+
} else u = BigNumber.from(o);
|
|
44226
44240
|
let m = null;
|
|
44227
44241
|
h = (await (await getVaultContract(s, l.provider)).vaultInfos()).masterPublicKey;
|
|
44228
44242
|
try {
|
|
@@ -44231,17 +44245,17 @@ async function submitTransaction$1(e, t, a, r2, n, i, o, s, l, g = "n/a", c = fa
|
|
|
44231
44245
|
return console.warn(`You are likely experiencing an error because the account ${h} doesn't have enough funds to cover the gas+value being requested to transfer on ` + a), void console.log(e2);
|
|
44232
44246
|
}
|
|
44233
44247
|
let y;
|
|
44234
|
-
if (null ==
|
|
44248
|
+
if (null == i || "" === i) {
|
|
44235
44249
|
if (!m) throw new Error("Unable to determine gas limit");
|
|
44236
44250
|
y = BigNumber.from(m).mul(105).div(100);
|
|
44237
|
-
} else y = BigNumber.from(
|
|
44238
|
-
|
|
44251
|
+
} else y = BigNumber.from(i);
|
|
44252
|
+
o = await formTransaction(e, String(t), String(a), String(r2), String(n), u.toString(), y.toString(), String(18)), p = await proposeTransaction(s, o, l, g, c), h = /* @__PURE__ */ new Date();
|
|
44239
44253
|
return process.env.DEBUG && console.log("SUBMIT TX TIME : ", h.getTime() - d.getTime()), p;
|
|
44240
44254
|
}
|
|
44241
|
-
async function signTx(t, a, r2, n,
|
|
44255
|
+
async function signTx(t, a, r2, n, o, i) {
|
|
44242
44256
|
var s = /* @__PURE__ */ new Date();
|
|
44243
44257
|
let l = await r2.getAddress(), g = "", c, e, p, d, _, u;
|
|
44244
|
-
|
|
44258
|
+
i = i || false;
|
|
44245
44259
|
g = n || await getUserSignature(t, r2);
|
|
44246
44260
|
var { users: n, resharingOccurred: h } = await (await getVaultContract(t, r2.provider)).vaultInfos(), n = n.findIndex((e2) => l == e2), m = (d && _ && u && e && p || (m = await getUtilsParams(t, l, r2.provider), d = m.seed, _ = m.threshold, u = m.index, e = m.megaPkArray, p = m.encMegaSecretKey[n]), Math.ceil(e.length * _ / 100));
|
|
44247
44261
|
if ("bigint" == typeof a ? a = Number(a) : "string" == typeof a && (a = parseInt(a, 10)), !c) {
|
|
@@ -44254,17 +44268,11 @@ async function signTx(t, a, r2, n, i, o) {
|
|
|
44254
44268
|
if (y && "" !== n.step3Crypto) {
|
|
44255
44269
|
var f2, y = JSON.parse(atob(n.step3Crypto));
|
|
44256
44270
|
let e2;
|
|
44257
|
-
h ? (h = n.pedersenOpeningLambdaReshare, f2 = await getRegistrationReshareStep3InfosDB(t, r2.provider), e2 = await reshareSignTransaction(d, w, u, c, g, p, f2.pedersenDealingsLambdaReshareArray, f2.dealingsKeyXLambdaReshareArray, f2.dealingsKappaXLambdaReshareArray, h || "", y[4], y[5])) : ({ dealingKeyXLambdaArray: w, dealingKappaXLambdaArray: f2 } = await getRegistrationStep3InfosDB(t, r2.provider),
|
|
44271
|
+
h ? (h = n.pedersenOpeningLambdaReshare, f2 = await getRegistrationReshareStep3InfosDB(t, r2.provider), e2 = await reshareSignTransaction(d, w, u, c, g, p, f2.pedersenDealingsLambdaReshareArray, f2.dealingsKeyXLambdaReshareArray, f2.dealingsKappaXLambdaReshareArray, h || "", y[4], y[5])) : ({ dealingKeyXLambdaArray: w, dealingKappaXLambdaArray: f2 } = await getRegistrationStep3InfosDB(t, r2.provider), o ? e2 = await signTransactionWithoutLambda(d, c, g, y[0], y[1], y[4], y[5]) : (h = /* @__PURE__ */ new Date(), e2 = await signTransaction$1(d, m, u, c, g, p, w, f2, n.pedersenOpeningLambda || "", y[4], y[5], n.pedersenTranscriptLambda || ""), o = /* @__PURE__ */ new Date(), console.log("sign transaction CRYPTO : " + (o.getTime() - h.getTime()) / 1e3)));
|
|
44258
44272
|
m = /* @__PURE__ */ new Date();
|
|
44259
|
-
return process.env.DEBUG && console.log("Time to sign : " + (m.getTime() - s.getTime()) / 1e3), userConfirmTx(t, a, e2.signedTransaction, r2,
|
|
44273
|
+
return process.env.DEBUG && console.log("Time to sign : " + (m.getTime() - s.getTime()) / 1e3), userConfirmTx(t, a, e2.signedTransaction, r2, i);
|
|
44260
44274
|
}
|
|
44261
44275
|
}
|
|
44262
|
-
(async () => {
|
|
44263
|
-
var e = await Promise.resolve().then(() => constants);
|
|
44264
|
-
e.getGraphEndpoint;
|
|
44265
|
-
})(), "undefined" == typeof window && Promise.resolve().then(() => browser$2).then((e) => {
|
|
44266
|
-
globalThis.WebSocket = e.default || e;
|
|
44267
|
-
});
|
|
44268
44276
|
let retryWithDelay = async (t, a = 3, r2 = 1e3) => {
|
|
44269
44277
|
try {
|
|
44270
44278
|
return await t();
|
|
@@ -44275,10 +44283,11 @@ let retryWithDelay = async (t, a = 3, r2 = 1e3) => {
|
|
|
44275
44283
|
};
|
|
44276
44284
|
async function getTransactionLean(a, r2, n) {
|
|
44277
44285
|
return retryWithDelay(async () => {
|
|
44286
|
+
console.log(`🔍 [GET_TX_LEAN] Attempting to fetch transaction ${r2} for vault ` + a);
|
|
44278
44287
|
var e, t = await _getTransactionLean(a, r2, n);
|
|
44279
44288
|
if (t?.transactionData) return e = await parseTransaction(t.transactionData), { ...t, chainId: e.chainId, data: e.data, gas: e.gas, gasPrice: e.gasPrice, nonce: e.nonce, to: e.to, value: e.value };
|
|
44280
|
-
throw new Error(
|
|
44281
|
-
});
|
|
44289
|
+
throw console.warn(`⚠️ [GET_TX_LEAN] Transaction ${r2} data is empty or unavailable`), new Error(`Transaction data not available for txId ${r2}. This may be due to subgraph indexing delays.`);
|
|
44290
|
+
}, 5, 1250);
|
|
44282
44291
|
}
|
|
44283
44292
|
var buffer = {};
|
|
44284
44293
|
var base64Js = {};
|
|
@@ -74092,6 +74101,28 @@ class Transaction2 {
|
|
|
74092
74101
|
}
|
|
74093
74102
|
this.transitionHandlers.get(key2).push(handler);
|
|
74094
74103
|
}
|
|
74104
|
+
addWildcardHandler(toState, handler) {
|
|
74105
|
+
const key2 = `*->${toState}`;
|
|
74106
|
+
if (!this.transitionHandlers.has(key2)) {
|
|
74107
|
+
this.transitionHandlers.set(key2, []);
|
|
74108
|
+
}
|
|
74109
|
+
this.transitionHandlers.get(key2).push(handler);
|
|
74110
|
+
}
|
|
74111
|
+
onPropose(handler) {
|
|
74112
|
+
this.addWildcardHandler(1, handler);
|
|
74113
|
+
}
|
|
74114
|
+
onSign(handler) {
|
|
74115
|
+
this.addWildcardHandler(2, handler);
|
|
74116
|
+
}
|
|
74117
|
+
onCombine(handler) {
|
|
74118
|
+
this.addWildcardHandler(3, handler);
|
|
74119
|
+
}
|
|
74120
|
+
onBroadcast(handler) {
|
|
74121
|
+
this.addWildcardHandler(4, handler);
|
|
74122
|
+
}
|
|
74123
|
+
onEnd(handler) {
|
|
74124
|
+
this.addWildcardHandler(5, handler);
|
|
74125
|
+
}
|
|
74095
74126
|
async transitionTo(data, newState) {
|
|
74096
74127
|
if (!this.isValidTransition(this.currentState, newState)) {
|
|
74097
74128
|
throw new InvalidTransitionError(
|
|
@@ -74099,9 +74130,14 @@ class Transaction2 {
|
|
|
74099
74130
|
);
|
|
74100
74131
|
}
|
|
74101
74132
|
const fromState = this.currentState;
|
|
74102
|
-
const
|
|
74103
|
-
const
|
|
74104
|
-
|
|
74133
|
+
const transitionSpecificKey = `${fromState}->${newState}`;
|
|
74134
|
+
const transitionWildcardKey = `*->${newState}`;
|
|
74135
|
+
const transitionSpecificHandlers = this.transitionHandlers.get(transitionSpecificKey) || [];
|
|
74136
|
+
for (const handler of transitionSpecificHandlers) {
|
|
74137
|
+
await handler(data);
|
|
74138
|
+
}
|
|
74139
|
+
const transitionWildcardHandlers = this.transitionHandlers.get(transitionWildcardKey) || [];
|
|
74140
|
+
for (const handler of transitionWildcardHandlers) {
|
|
74105
74141
|
await handler(data);
|
|
74106
74142
|
}
|
|
74107
74143
|
this.currentState = newState;
|
|
@@ -74201,11 +74237,11 @@ class Transaction2 {
|
|
|
74201
74237
|
this.submitTransactionResult = submitTransactionResult;
|
|
74202
74238
|
} catch (submitError) {
|
|
74203
74239
|
await this.transitionTo(
|
|
74204
|
-
|
|
74240
|
+
submitError,
|
|
74205
74241
|
5
|
|
74206
74242
|
/* END */
|
|
74207
74243
|
);
|
|
74208
|
-
|
|
74244
|
+
return false;
|
|
74209
74245
|
}
|
|
74210
74246
|
await this.transitionTo(
|
|
74211
74247
|
this.submitTransactionResult,
|
|
@@ -74226,11 +74262,11 @@ class Transaction2 {
|
|
|
74226
74262
|
);
|
|
74227
74263
|
} catch (signError) {
|
|
74228
74264
|
await this.transitionTo(
|
|
74229
|
-
|
|
74265
|
+
signError,
|
|
74230
74266
|
5
|
|
74231
74267
|
/* END */
|
|
74232
74268
|
);
|
|
74233
|
-
|
|
74269
|
+
return false;
|
|
74234
74270
|
}
|
|
74235
74271
|
return true;
|
|
74236
74272
|
}
|
|
@@ -74480,44 +74516,45 @@ class Salt {
|
|
|
74480
74516
|
}
|
|
74481
74517
|
}
|
|
74482
74518
|
export {
|
|
74483
|
-
|
|
74519
|
+
InvalidParams as A,
|
|
74484
74520
|
BaseError$1 as B,
|
|
74485
|
-
|
|
74486
|
-
|
|
74487
|
-
|
|
74488
|
-
|
|
74489
|
-
|
|
74521
|
+
assertValidParams as C,
|
|
74522
|
+
InvalidProvider as D,
|
|
74523
|
+
assertValidProvider as E,
|
|
74524
|
+
InvalidSigner as F,
|
|
74525
|
+
assertValidSigner as G,
|
|
74490
74526
|
HttpRequestError as H,
|
|
74491
74527
|
InvalidAuthToken as I,
|
|
74492
|
-
|
|
74528
|
+
assertCorrectChain as J,
|
|
74529
|
+
InsufficientGas as K,
|
|
74493
74530
|
Salt as S,
|
|
74494
74531
|
TransferType as T,
|
|
74495
74532
|
ValidationError as V,
|
|
74496
74533
|
WrongChain as W,
|
|
74497
|
-
|
|
74498
|
-
|
|
74534
|
+
getUrl as a,
|
|
74535
|
+
localBatchGatewayRequest as b,
|
|
74499
74536
|
call as c,
|
|
74500
74537
|
decodeErrorResult as d,
|
|
74501
|
-
|
|
74502
|
-
|
|
74503
|
-
|
|
74504
|
-
|
|
74538
|
+
concat$1 as e,
|
|
74539
|
+
encodeAbiParameters as f,
|
|
74540
|
+
getDefaultExportFromCjs$1 as g,
|
|
74541
|
+
isHex as h,
|
|
74505
74542
|
isAddressEqual as i,
|
|
74506
|
-
|
|
74507
|
-
|
|
74543
|
+
InvalidChain as j,
|
|
74544
|
+
InvalidAddress as k,
|
|
74508
74545
|
localBatchGatewayUrl as l,
|
|
74509
|
-
|
|
74510
|
-
|
|
74511
|
-
|
|
74546
|
+
InvalidValue as m,
|
|
74547
|
+
SaltAccountError as n,
|
|
74548
|
+
assertValidAddress as o,
|
|
74512
74549
|
process$1 as p,
|
|
74513
|
-
|
|
74514
|
-
|
|
74550
|
+
InvalidUrl as q,
|
|
74551
|
+
assertValidUrl as r,
|
|
74515
74552
|
stringify$2 as s,
|
|
74516
|
-
|
|
74517
|
-
|
|
74518
|
-
|
|
74519
|
-
|
|
74520
|
-
|
|
74521
|
-
|
|
74522
|
-
|
|
74553
|
+
assertValidUrlNoTrailingSlash as t,
|
|
74554
|
+
InvalidEnvironment as u,
|
|
74555
|
+
assertValidEnvironment as v,
|
|
74556
|
+
assertHasAuthToken as w,
|
|
74557
|
+
assertValidAuthToken as x,
|
|
74558
|
+
assertValidChain as y,
|
|
74559
|
+
assertValidValue as z
|
|
74523
74560
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -646,6 +646,8 @@ declare class SaltSocket {
|
|
|
646
646
|
unsubscribe: (event: EVENTS) => void;
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
+
declare type SignError = unknown;
|
|
650
|
+
|
|
649
651
|
declare interface SignTxResponse {
|
|
650
652
|
/**
|
|
651
653
|
* ethers.js transaction receipt object
|
|
@@ -681,6 +683,8 @@ declare interface SignTxResponse {
|
|
|
681
683
|
|
|
682
684
|
declare type StateTransitionHandler = (data: TransitionData) => void | Promise<void>;
|
|
683
685
|
|
|
686
|
+
declare type SubmitError = unknown;
|
|
687
|
+
|
|
684
688
|
declare interface SubmitTransactionResult {
|
|
685
689
|
submittedTx: TransactionParams;
|
|
686
690
|
txId: string;
|
|
@@ -882,6 +886,12 @@ declare class Transaction {
|
|
|
882
886
|
getSignatures(): SignTxResponse[];
|
|
883
887
|
getCombineResponse(): CombineTxResponse | null;
|
|
884
888
|
onTransition(fromState: TRANSACTION_STATES, toState: TRANSACTION_STATES, handler: StateTransitionHandler): void;
|
|
889
|
+
private addWildcardHandler;
|
|
890
|
+
onPropose(handler: StateTransitionHandler): void;
|
|
891
|
+
onSign(handler: StateTransitionHandler): void;
|
|
892
|
+
onCombine(handler: StateTransitionHandler): void;
|
|
893
|
+
onBroadcast(handler: StateTransitionHandler): void;
|
|
894
|
+
onEnd(handler: StateTransitionHandler): void;
|
|
885
895
|
transitionTo(data: TransitionData, newState: TRANSACTION_STATES): Promise<void>;
|
|
886
896
|
initListeners(): void;
|
|
887
897
|
/**
|
|
@@ -983,7 +993,7 @@ export declare enum TransferType {
|
|
|
983
993
|
Native = "Native"
|
|
984
994
|
}
|
|
985
995
|
|
|
986
|
-
declare type TransitionData = BroadcastTxResponse | CombineTxResponse | SignTxResponse[] | PolicyBreachResponse | ProposeTxResponse | null;
|
|
996
|
+
declare type TransitionData = BroadcastTxResponse | CombineTxResponse | SignTxResponse[] | PolicyBreachResponse | ProposeTxResponse | SignError | SubmitError | null;
|
|
987
997
|
|
|
988
998
|
/**
|
|
989
999
|
* Thrown when parameters provided for a function are invalid.
|
package/dist/salt.es.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { K, k, I, j, u, A, D, F, q, m, S, n, T, V, W, J, w, o, x, y, v, C, E, G, r, t, z, p } from "./index-DgJYJqk3.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
K as InsufficientGas,
|
|
4
|
+
k as InvalidAddress,
|
|
5
5
|
I as InvalidAuthToken,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
j as InvalidChain,
|
|
7
|
+
u as InvalidEnvironment,
|
|
8
|
+
A as InvalidParams,
|
|
9
|
+
D as InvalidProvider,
|
|
10
|
+
F as InvalidSigner,
|
|
11
|
+
q as InvalidUrl,
|
|
12
|
+
m as InvalidValue,
|
|
13
13
|
S as Salt,
|
|
14
|
-
|
|
14
|
+
n as SaltAccountError,
|
|
15
15
|
T as TransferType,
|
|
16
16
|
V as ValidationError,
|
|
17
17
|
W as WrongChain,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
J as assertCorrectChain,
|
|
19
|
+
w as assertHasAuthToken,
|
|
20
|
+
o as assertValidAddress,
|
|
21
|
+
x as assertValidAuthToken,
|
|
22
|
+
y as assertValidChain,
|
|
23
|
+
v as assertValidEnvironment,
|
|
24
|
+
C as assertValidParams,
|
|
25
|
+
E as assertValidProvider,
|
|
26
|
+
G as assertValidSigner,
|
|
27
|
+
r as assertValidUrl,
|
|
28
|
+
t as assertValidUrlNoTrailingSlash,
|
|
29
|
+
z as assertValidValue,
|
|
30
30
|
p as process
|
|
31
31
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "salt-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "SDK for interacting with Salt's MPC self custody & treasury",
|
|
5
5
|
"author": "Salt",
|
|
6
6
|
"homepace": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@ethersproject/providers": "5.8.0",
|
|
52
|
-
"@intuweb3/sdk": "0.0.
|
|
52
|
+
"@intuweb3/sdk": "0.0.533",
|
|
53
53
|
"ethers": "5.8.0",
|
|
54
54
|
"siwe": "3.0.0",
|
|
55
55
|
"socket.io-client": "4.8.1"
|