@ledgerhq/coin-sui 0.15.1-nightly.0 → 0.16.0-nightly.2
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +31 -0
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.integration.test.js +1 -0
- package/lib/api/index.integration.test.js.map +1 -1
- package/lib/api/index.js +3 -0
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/buildTransaction.d.ts.map +1 -1
- package/lib/bridge/buildTransaction.js +1 -0
- package/lib/bridge/buildTransaction.js.map +1 -1
- package/lib/bridge/buildTransaction.test.js +2 -0
- package/lib/bridge/buildTransaction.test.js.map +1 -1
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib/bridge/getFeesForTransaction.js +4 -0
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +3 -0
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/preload.d.ts +3 -1
- package/lib/bridge/preload.d.ts.map +1 -1
- package/lib/bridge/preload.js +76 -5
- package/lib/bridge/preload.js.map +1 -1
- package/lib/bridge/preload.test.js +3 -3
- package/lib/bridge/preload.test.js.map +1 -1
- package/lib/logic/craftTransaction.integration.test.js +4 -0
- package/lib/logic/craftTransaction.integration.test.js.map +1 -1
- package/lib/logic/craftTransaction.test.js +14 -0
- package/lib/logic/craftTransaction.test.js.map +1 -1
- package/lib/logic/estimateFees.integration.test.js +3 -0
- package/lib/logic/estimateFees.integration.test.js.map +1 -1
- package/lib/logic/estimateFees.test.js +2 -0
- package/lib/logic/estimateFees.test.js.map +1 -1
- package/lib/types/bridge.d.ts +12 -0
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.integration.test.js +1 -0
- package/lib-es/api/index.integration.test.js.map +1 -1
- package/lib-es/api/index.js +3 -0
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
- package/lib-es/bridge/buildTransaction.js +1 -0
- package/lib-es/bridge/buildTransaction.js.map +1 -1
- package/lib-es/bridge/buildTransaction.test.js +2 -0
- package/lib-es/bridge/buildTransaction.test.js.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.js +4 -0
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +3 -0
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/preload.d.ts +3 -1
- package/lib-es/bridge/preload.d.ts.map +1 -1
- package/lib-es/bridge/preload.js +50 -4
- package/lib-es/bridge/preload.js.map +1 -1
- package/lib-es/bridge/preload.test.js +3 -3
- package/lib-es/bridge/preload.test.js.map +1 -1
- package/lib-es/logic/craftTransaction.integration.test.js +4 -0
- package/lib-es/logic/craftTransaction.integration.test.js.map +1 -1
- package/lib-es/logic/craftTransaction.test.js +14 -0
- package/lib-es/logic/craftTransaction.test.js.map +1 -1
- package/lib-es/logic/estimateFees.integration.test.js +3 -0
- package/lib-es/logic/estimateFees.integration.test.js.map +1 -1
- package/lib-es/logic/estimateFees.test.js +2 -0
- package/lib-es/logic/estimateFees.test.js.map +1 -1
- package/lib-es/types/bridge.d.ts +12 -0
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/api/index.integration.test.ts +1 -0
- package/src/api/index.ts +8 -0
- package/src/bridge/buildTransaction.test.ts +2 -0
- package/src/bridge/buildTransaction.ts +1 -0
- package/src/bridge/getFeesForTransaction.ts +4 -0
- package/src/bridge/index.ts +3 -0
- package/src/bridge/preload.test.ts +3 -3
- package/src/bridge/preload.ts +68 -6
- package/src/logic/craftTransaction.integration.test.ts +4 -0
- package/src/logic/craftTransaction.test.ts +14 -0
- package/src/logic/estimateFees.integration.test.ts +3 -0
- package/src/logic/estimateFees.test.ts +2 -0
- package/src/types/bridge.ts +13 -1
|
@@ -16,6 +16,7 @@ describe("estimateFees", () => {
|
|
|
16
16
|
});
|
|
17
17
|
it("should estimate fees for native SUI transaction", async () => {
|
|
18
18
|
const transactionIntent = {
|
|
19
|
+
intentType: "transaction",
|
|
19
20
|
sender: SENDER,
|
|
20
21
|
recipient: RECIPIENT,
|
|
21
22
|
amount: BigInt(1000),
|
|
@@ -30,6 +31,7 @@ describe("estimateFees", () => {
|
|
|
30
31
|
it("should estimate fees for token transaction", async () => {
|
|
31
32
|
const coinType = "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT";
|
|
32
33
|
const transactionIntent = {
|
|
34
|
+
intentType: "transaction",
|
|
33
35
|
sender: SENDER,
|
|
34
36
|
recipient: RECIPIENT,
|
|
35
37
|
amount: BigInt(1000),
|
|
@@ -46,6 +48,7 @@ describe("estimateFees", () => {
|
|
|
46
48
|
}, 25000);
|
|
47
49
|
it("should handle concurrent fee estimations", async () => {
|
|
48
50
|
const transactionIntent = {
|
|
51
|
+
intentType: "transaction",
|
|
49
52
|
sender: SENDER,
|
|
50
53
|
recipient: RECIPIENT,
|
|
51
54
|
amount: BigInt(1000),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateFees.integration.test.js","sourceRoot":"","sources":["../../src/logic/estimateFees.integration.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,MAAM,GAAG,oEAAoE,CAAC;AACpF,MAAM,SAAS,GAAG,oEAAoE,CAAC;AAEvF,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC5B,SAAS,CAAC,GAAG,EAAE;QACb,UAAU,CAAC,aAAa,CAAC,GAAG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G,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE5C,8BAA8B;QAC9B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACrB,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,yDAAyD;QACzD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QAErC,yDAAyD;QACzD,MAAM,CAAC,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC7D,CAAC,EAAE,KAAK,CAAC,CAAC;AACZ,CAAC,CAAC,CAAC"}
|
|
@@ -19,6 +19,7 @@ describe("estimateFees", () => {
|
|
|
19
19
|
gasBudget: mockGasBudget,
|
|
20
20
|
});
|
|
21
21
|
const transactionIntent = {
|
|
22
|
+
intentType: "transaction",
|
|
22
23
|
sender: "0x123",
|
|
23
24
|
recipient: "0x456",
|
|
24
25
|
amount: BigInt("1000000000"),
|
|
@@ -42,6 +43,7 @@ describe("estimateFees", () => {
|
|
|
42
43
|
gasBudget: mockGasBudget,
|
|
43
44
|
});
|
|
44
45
|
const transactionIntent = {
|
|
46
|
+
intentType: "transaction",
|
|
45
47
|
sender: "0x123",
|
|
46
48
|
recipient: "0x456",
|
|
47
49
|
amount: BigInt("0"),
|
|
@@ -1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MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,aAAa,GAAG,QAAQ,CAAC;QAC9B,MAAM,CAAC,WAAyB,CAAC,iBAAiB,CAAC;YAClD,SAAS,EAAE,aAAa;SACzB,CAAC,CAAC;QAEH,MAAM,iBAAiB,GAAG;YACxB,UAAU,EAAE,aAAsB;YAClC,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,OAAO;YAClB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC;YACnB,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,EAAE,IAAI,EAAE,QAAiB,EAAE;SACnC,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,iBAAiB,CAAC,CAAC;QAErD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,MAAM,EAAE;YACxE,SAAS,EAAE,iBAAiB,CAAC,SAAS;YACtC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC;YACtB,QAAQ,EAAE,eAAe;YACzB,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,MAAM;SACb,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib-es/types/bridge.d.ts
CHANGED
|
@@ -56,6 +56,17 @@ export type TransactionRaw = TransactionCommonRaw & {
|
|
|
56
56
|
export type SuiValidator = SuiValidatorSummary & {
|
|
57
57
|
apy: number;
|
|
58
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Sui token data from CAL
|
|
61
|
+
*/
|
|
62
|
+
export type SuiToken = [
|
|
63
|
+
string,
|
|
64
|
+
string,
|
|
65
|
+
string,
|
|
66
|
+
string,
|
|
67
|
+
number,
|
|
68
|
+
string
|
|
69
|
+
];
|
|
59
70
|
/**
|
|
60
71
|
* Sui currency data that will be preloaded.
|
|
61
72
|
* You can for instance add a list of validators for Proof-of-Stake blockchains,
|
|
@@ -63,6 +74,7 @@ export type SuiValidator = SuiValidatorSummary & {
|
|
|
63
74
|
*/
|
|
64
75
|
export type SuiPreloadData = {
|
|
65
76
|
validators: SuiValidator[];
|
|
77
|
+
tokens: SuiToken[];
|
|
66
78
|
};
|
|
67
79
|
export type SuiAccount = Account & {
|
|
68
80
|
suiResources?: SuiResources;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,SAAS,EACT,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC,MAAM,MAA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C;CAC5B,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE1D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,YAAY,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG,eAAe,GAAG,oBAAoB,CAAC;AAE7D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CAC/B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-sui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0-nightly.2",
|
|
4
4
|
"description": "Ledger Sui Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -120,19 +120,20 @@
|
|
|
120
120
|
"dependencies": {
|
|
121
121
|
"@mysten/signers": "0.5.0",
|
|
122
122
|
"@mysten/sui": "1.38.0",
|
|
123
|
+
"axios": "1.11.0",
|
|
123
124
|
"bignumber.js": "^9.1.2",
|
|
124
125
|
"lodash": "4.17.21",
|
|
125
126
|
"rxjs": "^7.8.1",
|
|
126
|
-
"@ledgerhq/
|
|
127
|
-
"@ledgerhq/
|
|
127
|
+
"@ledgerhq/coin-framework": "^6.7.0-nightly.1",
|
|
128
|
+
"@ledgerhq/cryptoassets": "^13.31.0-nightly.1",
|
|
128
129
|
"@ledgerhq/errors": "^6.26.0",
|
|
129
130
|
"@ledgerhq/hw-app-sui": "^1.4.0",
|
|
130
|
-
"@ledgerhq/live-env": "^2.
|
|
131
|
-
"@ledgerhq/live-network": "^2.0.
|
|
131
|
+
"@ledgerhq/live-env": "^2.19.0-nightly.0",
|
|
132
|
+
"@ledgerhq/live-network": "^2.0.20-nightly.0",
|
|
132
133
|
"@ledgerhq/live-promise": "^0.1.1",
|
|
133
134
|
"@ledgerhq/logs": "^6.13.0",
|
|
134
|
-
"@ledgerhq/types-cryptoassets": "^7.
|
|
135
|
-
"@ledgerhq/types-live": "^6.
|
|
135
|
+
"@ledgerhq/types-cryptoassets": "^7.29.0-nightly.0",
|
|
136
|
+
"@ledgerhq/types-live": "^6.87.0-nightly.1"
|
|
136
137
|
},
|
|
137
138
|
"devDependencies": {
|
|
138
139
|
"@faker-js/faker": "^8.4.1",
|
package/src/api/index.ts
CHANGED
|
@@ -26,6 +26,14 @@ export function createApi(config: SuiConfig): AlpacaApi {
|
|
|
26
26
|
broadcast,
|
|
27
27
|
combine,
|
|
28
28
|
craftTransaction: craft,
|
|
29
|
+
craftRawTransaction: (
|
|
30
|
+
_transaction: string,
|
|
31
|
+
_sender: string,
|
|
32
|
+
_publicKey: string,
|
|
33
|
+
_sequence: number,
|
|
34
|
+
): Promise<CraftedTransaction> => {
|
|
35
|
+
throw new Error("craftRawTransaction is not supported");
|
|
36
|
+
},
|
|
29
37
|
estimateFees: estimate,
|
|
30
38
|
getBalance,
|
|
31
39
|
lastBlock,
|
|
@@ -71,6 +71,7 @@ describe("buildTransaction", () => {
|
|
|
71
71
|
|
|
72
72
|
// THEN
|
|
73
73
|
expect(craftTransaction).toHaveBeenCalledWith({
|
|
74
|
+
intentType: "transaction",
|
|
74
75
|
sender: mockAccount.freshAddress,
|
|
75
76
|
recipient: mockTransaction.recipient,
|
|
76
77
|
type: mockTransaction.mode,
|
|
@@ -107,6 +108,7 @@ describe("buildTransaction", () => {
|
|
|
107
108
|
|
|
108
109
|
// THEN
|
|
109
110
|
expect(craftTransaction).toHaveBeenCalledWith({
|
|
111
|
+
intentType: "transaction",
|
|
110
112
|
sender: account.freshAddress,
|
|
111
113
|
recipient: mockTransaction.recipient,
|
|
112
114
|
type: mockTransaction.mode,
|
|
@@ -38,12 +38,15 @@ export default async function getEstimatedFees({
|
|
|
38
38
|
const asset = toSuiAsset(subAccount?.token.contractAddress ?? DEFAULT_COIN_TYPE);
|
|
39
39
|
|
|
40
40
|
let transactionType: "send" | "delegate" | "undelegate";
|
|
41
|
+
let intentType: "transaction" | "staking" = "transaction";
|
|
41
42
|
switch (transaction.mode) {
|
|
42
43
|
case "delegate":
|
|
43
44
|
transactionType = "delegate";
|
|
45
|
+
intentType = "staking";
|
|
44
46
|
break;
|
|
45
47
|
case "undelegate":
|
|
46
48
|
transactionType = "undelegate";
|
|
49
|
+
intentType = "staking";
|
|
47
50
|
break;
|
|
48
51
|
default:
|
|
49
52
|
transactionType = "send";
|
|
@@ -51,6 +54,7 @@ export default async function getEstimatedFees({
|
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
const fees = await estimateFees({
|
|
57
|
+
intentType,
|
|
54
58
|
recipient: getAbandonSeedAddress(account.currency.id),
|
|
55
59
|
sender: account.freshAddress,
|
|
56
60
|
amount: BigInt(t.amount.toString()),
|
package/src/bridge/index.ts
CHANGED
|
@@ -16,12 +16,12 @@ jest.mock("@ledgerhq/logs", () => ({
|
|
|
16
16
|
describe("Sui Preload Functions", () => {
|
|
17
17
|
beforeEach(() => {
|
|
18
18
|
// Reset the preload data before each test
|
|
19
|
-
setSuiPreloadData({ validators: [] });
|
|
19
|
+
setSuiPreloadData({ validators: [], tokens: [] });
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
describe("getCurrentSuiPreloadData", () => {
|
|
23
23
|
it("should return the current preloaded data", () => {
|
|
24
|
-
const testData: SuiPreloadData = { validators: [] };
|
|
24
|
+
const testData: SuiPreloadData = { validators: [], tokens: [] };
|
|
25
25
|
setSuiPreloadData(testData);
|
|
26
26
|
|
|
27
27
|
const data = getCurrentSuiPreloadData();
|
|
@@ -36,7 +36,7 @@ describe("Sui Preload Functions", () => {
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it("should emit updates when data is set", done => {
|
|
39
|
-
const testData: SuiPreloadData = { validators: [] };
|
|
39
|
+
const testData: SuiPreloadData = { validators: [], tokens: [] };
|
|
40
40
|
const updates = getSuiPreloadDataUpdates();
|
|
41
41
|
|
|
42
42
|
updates.pipe(take(1)).subscribe(data => {
|
package/src/bridge/preload.ts
CHANGED
|
@@ -1,15 +1,64 @@
|
|
|
1
1
|
import { Observable, Subject } from "rxjs";
|
|
2
2
|
import { log } from "@ledgerhq/logs";
|
|
3
|
-
|
|
4
|
-
import type { SuiPreloadData } from "../types";
|
|
3
|
+
import type { SuiPreloadData, SuiToken } from "../types";
|
|
5
4
|
import { getValidators } from "../network/sdk";
|
|
5
|
+
import suiTokens, { hash } from "@ledgerhq/cryptoassets/data/sui";
|
|
6
|
+
import { fetchTokensFromCALService } from "@ledgerhq/cryptoassets/crypto-assets-importer/fetch/index";
|
|
7
|
+
import { addTokens, convertSuiTokens } from "@ledgerhq/cryptoassets/tokens";
|
|
8
|
+
import { AxiosError } from "axios";
|
|
6
9
|
|
|
7
10
|
const PRELOAD_MAX_AGE = 30 * 60 * 1000; // 30 minutes
|
|
8
11
|
|
|
9
|
-
let currentPreloadedData: SuiPreloadData = { validators: [] };
|
|
12
|
+
let currentPreloadedData: SuiPreloadData = { validators: [], tokens: [] };
|
|
13
|
+
|
|
14
|
+
let latestCALHash = "";
|
|
15
|
+
|
|
16
|
+
export const fetchSuiTokens: () => Promise<SuiToken[]> = async () => {
|
|
17
|
+
const embeddedHash = hash;
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const { tokens, hash } = await fetchTokensFromCALService(
|
|
21
|
+
{
|
|
22
|
+
blockchain_name: "sui",
|
|
23
|
+
},
|
|
24
|
+
["id", "name", "ticker", "contract_address", "decimals", "live_signature"],
|
|
25
|
+
latestCALHash || embeddedHash,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
latestCALHash = hash || "";
|
|
29
|
+
|
|
30
|
+
return tokens.map(token => {
|
|
31
|
+
return [
|
|
32
|
+
token.id,
|
|
33
|
+
token.name,
|
|
34
|
+
token.ticker.toUpperCase(),
|
|
35
|
+
token.contract_address,
|
|
36
|
+
token.decimals,
|
|
37
|
+
token.live_signature,
|
|
38
|
+
];
|
|
39
|
+
});
|
|
40
|
+
} catch (e) {
|
|
41
|
+
if (e instanceof AxiosError && e.response?.status === 304) {
|
|
42
|
+
log(
|
|
43
|
+
"sui/preload",
|
|
44
|
+
`loading existing fallback tokens for sui with hash ${latestCALHash || embeddedHash}`,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (!latestCALHash) {
|
|
48
|
+
latestCALHash = embeddedHash;
|
|
49
|
+
return suiTokens;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
log("sui/preload", "failure to retrieve tokens for sui", e);
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
};
|
|
10
59
|
|
|
11
60
|
function fromHydratePreloadData(data: SuiPreloadData): SuiPreloadData {
|
|
12
|
-
return { validators: data?.validators ?? [] };
|
|
61
|
+
return { validators: data?.validators ?? [], tokens: data?.tokens ?? [] };
|
|
13
62
|
}
|
|
14
63
|
|
|
15
64
|
const updates = new Subject<SuiPreloadData>();
|
|
@@ -34,11 +83,24 @@ export const getPreloadStrategy = () => ({
|
|
|
34
83
|
preloadMaxAge: PRELOAD_MAX_AGE,
|
|
35
84
|
});
|
|
36
85
|
|
|
86
|
+
let shouldSkipTokenLoading = false;
|
|
87
|
+
export function setShouldSkipTokenLoading(skip: boolean): void {
|
|
88
|
+
shouldSkipTokenLoading = skip;
|
|
89
|
+
}
|
|
90
|
+
|
|
37
91
|
export const preload = async (): Promise<SuiPreloadData> => {
|
|
38
|
-
const validators = await getValidators();
|
|
39
92
|
log("sui/preload", "preloading sui data...");
|
|
40
93
|
|
|
41
|
-
|
|
94
|
+
const validators = await getValidators();
|
|
95
|
+
|
|
96
|
+
let tokens: SuiToken[] = [];
|
|
97
|
+
if (!shouldSkipTokenLoading) {
|
|
98
|
+
tokens = await fetchSuiTokens();
|
|
99
|
+
log("sui/preload", "preload " + tokens.length + " tokens");
|
|
100
|
+
addTokens(tokens.map(convertSuiTokens));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return { validators, tokens };
|
|
42
104
|
};
|
|
43
105
|
|
|
44
106
|
export const hydrate = (data: SuiPreloadData) => {
|
|
@@ -21,6 +21,7 @@ describe("craftTransaction", () => {
|
|
|
21
21
|
|
|
22
22
|
it("should craft a native SUI send transaction", async () => {
|
|
23
23
|
const transactionIntent: TransactionIntent = {
|
|
24
|
+
intentType: "transaction",
|
|
24
25
|
sender: SENDER,
|
|
25
26
|
recipient: RECIPIENT,
|
|
26
27
|
amount: BigInt(1000),
|
|
@@ -43,6 +44,7 @@ describe("craftTransaction", () => {
|
|
|
43
44
|
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT";
|
|
44
45
|
|
|
45
46
|
const transactionIntent: TransactionIntent = {
|
|
47
|
+
intentType: "transaction",
|
|
46
48
|
sender: SENDER,
|
|
47
49
|
recipient: RECIPIENT,
|
|
48
50
|
amount: BigInt(1000),
|
|
@@ -65,6 +67,7 @@ describe("craftTransaction", () => {
|
|
|
65
67
|
|
|
66
68
|
it("should craft a native SUI send transaction, returning serialized objects when requested", async () => {
|
|
67
69
|
const transactionIntent: TransactionIntent = {
|
|
70
|
+
intentType: "transaction",
|
|
68
71
|
sender: SENDER,
|
|
69
72
|
recipient: RECIPIENT,
|
|
70
73
|
amount: BigInt(1000),
|
|
@@ -88,6 +91,7 @@ describe("craftTransaction", () => {
|
|
|
88
91
|
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT";
|
|
89
92
|
|
|
90
93
|
const transactionIntent: TransactionIntent = {
|
|
94
|
+
intentType: "transaction",
|
|
91
95
|
sender: SENDER,
|
|
92
96
|
recipient: RECIPIENT,
|
|
93
97
|
amount: BigInt(1000),
|
|
@@ -18,8 +18,10 @@ describe("craftTransaction", () => {
|
|
|
18
18
|
const amount = BigInt("1000000000");
|
|
19
19
|
const recipient = "0x456";
|
|
20
20
|
const type = "send";
|
|
21
|
+
const intentType = "transaction";
|
|
21
22
|
|
|
22
23
|
const result = await craftTransaction({
|
|
24
|
+
intentType,
|
|
23
25
|
sender,
|
|
24
26
|
amount,
|
|
25
27
|
recipient,
|
|
@@ -30,6 +32,7 @@ describe("craftTransaction", () => {
|
|
|
30
32
|
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
31
33
|
sender,
|
|
32
34
|
{
|
|
35
|
+
intentType,
|
|
33
36
|
amount: new BigNumber(amount.toString()),
|
|
34
37
|
recipient,
|
|
35
38
|
mode: type,
|
|
@@ -45,8 +48,10 @@ describe("craftTransaction", () => {
|
|
|
45
48
|
const amount = BigInt("500000000");
|
|
46
49
|
const recipient = "0x456";
|
|
47
50
|
const type = "send";
|
|
51
|
+
const intentType = "transaction";
|
|
48
52
|
|
|
49
53
|
const result = await craftTransaction({
|
|
54
|
+
intentType,
|
|
50
55
|
sender,
|
|
51
56
|
amount,
|
|
52
57
|
recipient,
|
|
@@ -57,6 +62,7 @@ describe("craftTransaction", () => {
|
|
|
57
62
|
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
58
63
|
sender,
|
|
59
64
|
{
|
|
65
|
+
intentType,
|
|
60
66
|
amount: new BigNumber(amount.toString()),
|
|
61
67
|
recipient,
|
|
62
68
|
mode: type,
|
|
@@ -72,8 +78,10 @@ describe("craftTransaction", () => {
|
|
|
72
78
|
const amount = BigInt("0");
|
|
73
79
|
const recipient = "0x456";
|
|
74
80
|
const type = "send";
|
|
81
|
+
const intentType = "transaction";
|
|
75
82
|
|
|
76
83
|
const result = await craftTransaction({
|
|
84
|
+
intentType,
|
|
77
85
|
sender,
|
|
78
86
|
amount,
|
|
79
87
|
recipient,
|
|
@@ -84,6 +92,7 @@ describe("craftTransaction", () => {
|
|
|
84
92
|
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
85
93
|
sender,
|
|
86
94
|
{
|
|
95
|
+
intentType,
|
|
87
96
|
amount: new BigNumber(amount.toString()),
|
|
88
97
|
recipient,
|
|
89
98
|
mode: type,
|
|
@@ -99,8 +108,10 @@ describe("craftTransaction", () => {
|
|
|
99
108
|
const amount = BigInt("1000000000000000000"); // 1 SUI (assuming 9 decimals)
|
|
100
109
|
const recipient = "0x456";
|
|
101
110
|
const type = "send";
|
|
111
|
+
const intentType = "transaction";
|
|
102
112
|
|
|
103
113
|
const result = await craftTransaction({
|
|
114
|
+
intentType,
|
|
104
115
|
sender,
|
|
105
116
|
amount,
|
|
106
117
|
recipient,
|
|
@@ -111,6 +122,7 @@ describe("craftTransaction", () => {
|
|
|
111
122
|
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
112
123
|
sender,
|
|
113
124
|
{
|
|
125
|
+
intentType,
|
|
114
126
|
amount: new BigNumber(amount.toString()),
|
|
115
127
|
recipient,
|
|
116
128
|
mode: type,
|
|
@@ -129,9 +141,11 @@ describe("craftTransaction", () => {
|
|
|
129
141
|
const amount = BigInt("1000000000");
|
|
130
142
|
const recipient = "0x456";
|
|
131
143
|
const type = "send";
|
|
144
|
+
const intentType = "transaction";
|
|
132
145
|
|
|
133
146
|
await expect(
|
|
134
147
|
craftTransaction({
|
|
148
|
+
intentType,
|
|
135
149
|
sender,
|
|
136
150
|
amount,
|
|
137
151
|
recipient,
|
|
@@ -20,6 +20,7 @@ describe("estimateFees", () => {
|
|
|
20
20
|
|
|
21
21
|
it("should estimate fees for native SUI transaction", async () => {
|
|
22
22
|
const transactionIntent: TransactionIntent = {
|
|
23
|
+
intentType: "transaction",
|
|
23
24
|
sender: SENDER,
|
|
24
25
|
recipient: RECIPIENT,
|
|
25
26
|
amount: BigInt(1000),
|
|
@@ -39,6 +40,7 @@ describe("estimateFees", () => {
|
|
|
39
40
|
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT";
|
|
40
41
|
|
|
41
42
|
const transactionIntent: TransactionIntent = {
|
|
43
|
+
intentType: "transaction",
|
|
42
44
|
sender: SENDER,
|
|
43
45
|
recipient: RECIPIENT,
|
|
44
46
|
amount: BigInt(1000),
|
|
@@ -58,6 +60,7 @@ describe("estimateFees", () => {
|
|
|
58
60
|
|
|
59
61
|
it("should handle concurrent fee estimations", async () => {
|
|
60
62
|
const transactionIntent: TransactionIntent = {
|
|
63
|
+
intentType: "transaction",
|
|
61
64
|
sender: SENDER,
|
|
62
65
|
recipient: RECIPIENT,
|
|
63
66
|
amount: BigInt(1000),
|
|
@@ -23,6 +23,7 @@ describe("estimateFees", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
const transactionIntent = {
|
|
26
|
+
intentType: "transaction" as const,
|
|
26
27
|
sender: "0x123",
|
|
27
28
|
recipient: "0x456",
|
|
28
29
|
amount: BigInt("1000000000"),
|
|
@@ -50,6 +51,7 @@ describe("estimateFees", () => {
|
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
const transactionIntent = {
|
|
54
|
+
intentType: "transaction" as const,
|
|
53
55
|
sender: "0x123",
|
|
54
56
|
recipient: "0x456",
|
|
55
57
|
amount: BigInt("0"),
|
package/src/types/bridge.ts
CHANGED
|
@@ -72,12 +72,24 @@ export type TransactionRaw = TransactionCommonRaw & {
|
|
|
72
72
|
*/
|
|
73
73
|
export type SuiValidator = SuiValidatorSummary & { apy: number };
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Sui token data from CAL
|
|
77
|
+
*/
|
|
78
|
+
export type SuiToken = [
|
|
79
|
+
string, // parent currency id
|
|
80
|
+
string, // name
|
|
81
|
+
string, // ticker
|
|
82
|
+
string, // contract address
|
|
83
|
+
number, // precision
|
|
84
|
+
string, // ledgerSignature
|
|
85
|
+
];
|
|
86
|
+
|
|
75
87
|
/**
|
|
76
88
|
* Sui currency data that will be preloaded.
|
|
77
89
|
* You can for instance add a list of validators for Proof-of-Stake blockchains,
|
|
78
90
|
* or any volatile data that could not be set as constants in the code (staking progress, fee estimation variables, etc.)
|
|
79
91
|
*/
|
|
80
|
-
export type SuiPreloadData = { validators: SuiValidator[] };
|
|
92
|
+
export type SuiPreloadData = { validators: SuiValidator[]; tokens: SuiToken[] };
|
|
81
93
|
|
|
82
94
|
export type SuiAccount = Account & {
|
|
83
95
|
// On some blockchain, an account can have resources (gained, delegated, ...)
|