@defuse-protocol/intents-sdk 0.43.3 → 0.45.0
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 +143 -21
- package/dist/index.cjs +19 -18
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +7 -5
- package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge-utils.cjs +5 -5
- package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.cjs +24 -12
- package/dist/src/bridges/aurora-engine-bridge/aurora-engine-bridge.js +19 -7
- package/dist/src/bridges/direct-bridge/direct-bridge-utils.cjs +5 -5
- package/dist/src/bridges/direct-bridge/direct-bridge.cjs +22 -10
- package/dist/src/bridges/direct-bridge/direct-bridge.js +16 -4
- package/dist/src/bridges/direct-bridge/error.cjs +2 -2
- package/dist/src/bridges/hot-bridge/error.cjs +4 -26
- package/dist/src/bridges/hot-bridge/error.d.cts +1 -17
- package/dist/src/bridges/hot-bridge/error.d.ts +1 -17
- package/dist/src/bridges/hot-bridge/error.js +1 -21
- package/dist/src/bridges/hot-bridge/hot-bridge-chains.cjs +3 -1
- package/dist/src/bridges/hot-bridge/hot-bridge-chains.d.cts +1 -1
- package/dist/src/bridges/hot-bridge/hot-bridge-chains.d.ts +1 -1
- package/dist/src/bridges/hot-bridge/hot-bridge-chains.js +3 -1
- package/dist/src/bridges/hot-bridge/hot-bridge-utils.cjs +17 -12
- package/dist/src/bridges/hot-bridge/hot-bridge-utils.js +7 -2
- package/dist/src/bridges/hot-bridge/hot-bridge.cjs +46 -32
- package/dist/src/bridges/hot-bridge/hot-bridge.js +38 -24
- package/dist/src/bridges/intents-bridge/intents-bridge.cjs +18 -4
- package/dist/src/bridges/intents-bridge/intents-bridge.js +18 -4
- package/dist/src/bridges/omni-bridge/error.cjs +6 -27
- package/dist/src/bridges/omni-bridge/error.d.cts +1 -16
- package/dist/src/bridges/omni-bridge/error.d.ts +1 -16
- package/dist/src/bridges/omni-bridge/error.js +1 -20
- package/dist/src/bridges/omni-bridge/omni-bridge-utils.cjs +12 -7
- package/dist/src/bridges/omni-bridge/omni-bridge-utils.js +5 -1
- package/dist/src/bridges/omni-bridge/omni-bridge.cjs +72 -54
- package/dist/src/bridges/omni-bridge/omni-bridge.js +47 -29
- package/dist/src/bridges/poa-bridge/poa-bridge-utils.cjs +2 -2
- package/dist/src/bridges/poa-bridge/poa-bridge.cjs +79 -26
- package/dist/src/bridges/poa-bridge/poa-bridge.js +66 -13
- package/dist/src/classes/errors.cjs +7 -7
- package/dist/src/constants/poa-tokens-routable-through-omni-bridge.cjs +17 -0
- package/dist/src/constants/poa-tokens-routable-through-omni-bridge.d.cts +12 -0
- package/dist/src/constants/poa-tokens-routable-through-omni-bridge.d.ts +12 -0
- package/dist/src/constants/poa-tokens-routable-through-omni-bridge.js +16 -0
- package/dist/src/constants/public-rpc-urls.cjs +3 -1
- package/dist/src/constants/public-rpc-urls.js +3 -1
- package/dist/src/constants/withdrawal-timing.cjs +57 -0
- package/dist/src/constants/withdrawal-timing.js +56 -0
- package/dist/src/core/withdrawal-watcher.cjs +83 -0
- package/dist/src/core/withdrawal-watcher.d.cts +18 -0
- package/dist/src/core/withdrawal-watcher.d.ts +18 -0
- package/dist/src/core/withdrawal-watcher.js +79 -0
- package/dist/src/intents/expirable-nonce.cjs +3 -3
- package/dist/src/intents/intent-executer-impl/intent-executer.cjs +7 -4
- package/dist/src/intents/intent-executer-impl/intent-executer.js +5 -2
- package/dist/src/intents/intent-hash.cjs +2 -2
- package/dist/src/intents/intent-hashes/erc191.cjs +2 -2
- package/dist/src/intents/intent-hashes/nep413.cjs +2 -2
- package/dist/src/intents/intent-hashes/raw-ed25519.cjs +2 -2
- package/dist/src/intents/intent-hashes/sep53.cjs +4 -4
- package/dist/src/intents/intent-hashes/tip191.cjs +2 -2
- package/dist/src/intents/intent-hashes/ton-connect.cjs +2 -2
- package/dist/src/intents/intent-hashes/webauthn.cjs +2 -2
- package/dist/src/intents/intent-payload-builder.cjs +4 -4
- package/dist/src/intents/intent-relayer-impl/intent-relayer-public.cjs +7 -7
- package/dist/src/intents/intent-relayer-impl/intent-relayer-public.js +1 -1
- package/dist/src/intents/intent-signer-impl/intent-signer-near-keypair.cjs +2 -2
- package/dist/src/intents/intent-signer-impl/intent-signer-nep413.cjs +3 -3
- package/dist/src/intents/intent-signer-impl/intent-signer-viem.cjs +3 -3
- package/dist/src/intents/interfaces/intent-relayer.d.cts +2 -1
- package/dist/src/intents/interfaces/intent-relayer.d.ts +2 -1
- package/dist/src/intents/salt-manager.cjs +5 -5
- package/dist/src/lib/array.cjs +2 -2
- package/dist/src/lib/caip2.cjs +7 -5
- package/dist/src/lib/caip2.d.cts +2 -0
- package/dist/src/lib/caip2.d.ts +2 -0
- package/dist/src/lib/caip2.js +3 -1
- package/dist/src/lib/configure-rpc-config.cjs +3 -3
- package/dist/src/lib/estimate-fee.cjs +6 -6
- package/dist/src/lib/parse-defuse-asset-id.cjs +2 -2
- package/dist/src/lib/route-config-factory.cjs +2 -5
- package/dist/src/lib/route-config-factory.d.cts +1 -1
- package/dist/src/lib/route-config-factory.d.ts +1 -1
- package/dist/src/lib/route-config-factory.js +2 -5
- package/dist/src/lib/tokensUsdPricesHttpClient/apis.cjs +3 -3
- package/dist/src/lib/validateAddress.cjs +21 -19
- package/dist/src/lib/validateAddress.js +3 -1
- package/dist/src/sdk.cjs +96 -47
- package/dist/src/sdk.d.cts +72 -11
- package/dist/src/sdk.d.ts +72 -11
- package/dist/src/sdk.js +85 -36
- package/dist/src/shared-types.d.cts +49 -15
- package/dist/src/shared-types.d.ts +49 -15
- package/package.json +3 -5
- package/dist/src/lib/route-config.cjs +0 -19
- package/dist/src/lib/route-config.js +0 -19
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _noble_hashes_sha3 = require("@noble/hashes/sha3");
|
|
3
3
|
|
|
4
4
|
//#region src/intents/intent-hashes/erc191.ts
|
|
5
5
|
/**
|
|
@@ -22,7 +22,7 @@ function computeErc191Prehash(payload) {
|
|
|
22
22
|
* @returns 32-byte hash as Uint8Array
|
|
23
23
|
*/
|
|
24
24
|
function computeErc191Hash(payload) {
|
|
25
|
-
return (0,
|
|
25
|
+
return (0, _noble_hashes_sha3.keccak_256)(computeErc191Prehash(payload));
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Compute hash from a signed ERC-191 payload
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_nep413 = require('../../lib/nep413.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _scure_base = require("@scure/base");
|
|
4
4
|
|
|
5
5
|
//#region src/intents/intent-hashes/nep413.ts
|
|
6
6
|
/**
|
|
@@ -14,7 +14,7 @@ async function computeSignedNep413Hash(signed) {
|
|
|
14
14
|
return require_nep413.hashNEP413Message({
|
|
15
15
|
message: payload.message,
|
|
16
16
|
recipient: payload.recipient,
|
|
17
|
-
nonce: Array.from(
|
|
17
|
+
nonce: Array.from(_scure_base.base64.decode(payload.nonce)),
|
|
18
18
|
callback_url: payload.callbackUrl
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _noble_hashes_sha2 = require("@noble/hashes/sha2");
|
|
3
3
|
|
|
4
4
|
//#region src/intents/intent-hashes/raw-ed25519.ts
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ let __noble_hashes_sha2 = require("@noble/hashes/sha2");
|
|
|
10
10
|
* @returns 32-byte hash as Uint8Array
|
|
11
11
|
*/
|
|
12
12
|
function computeRawEd25519Hash(payload) {
|
|
13
|
-
return (0,
|
|
13
|
+
return (0, _noble_hashes_sha2.sha256)(new TextEncoder().encode(payload));
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Compute hash from a signed Raw Ed25519 payload
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
2
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
3
|
+
let _noble_hashes_sha2 = require("@noble/hashes/sha2");
|
|
4
4
|
|
|
5
5
|
//#region src/intents/intent-hashes/sep53.ts
|
|
6
6
|
/**
|
|
@@ -10,7 +10,7 @@ let __noble_hashes_sha2 = require("@noble/hashes/sha2");
|
|
|
10
10
|
function computeSep53Prehash(payload) {
|
|
11
11
|
const prefix = new TextEncoder().encode("Stellar Signed Message:\n");
|
|
12
12
|
const data = new TextEncoder().encode(payload);
|
|
13
|
-
return
|
|
13
|
+
return _defuse_protocol_internal_utils.utils.concatUint8Arrays([prefix, data]);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Compute the SHA-256 hash of a SEP-53 payload
|
|
@@ -20,7 +20,7 @@ function computeSep53Prehash(payload) {
|
|
|
20
20
|
* @returns 32-byte hash as Uint8Array
|
|
21
21
|
*/
|
|
22
22
|
function computeSep53Hash(payload) {
|
|
23
|
-
return (0,
|
|
23
|
+
return (0, _noble_hashes_sha2.sha256)(computeSep53Prehash(payload));
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Compute hash from a signed SEP-53 payload
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _noble_hashes_sha3 = require("@noble/hashes/sha3");
|
|
3
3
|
|
|
4
4
|
//#region src/intents/intent-hashes/tip191.ts
|
|
5
5
|
/**
|
|
@@ -23,7 +23,7 @@ function computeTip191Prehash(payload) {
|
|
|
23
23
|
* @returns 32-byte hash as Uint8Array
|
|
24
24
|
*/
|
|
25
25
|
function computeTip191Hash(payload) {
|
|
26
|
-
return (0,
|
|
26
|
+
return (0, _noble_hashes_sha3.keccak_256)(computeTip191Prehash(payload));
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Compute hash from a signed TIP-191 payload
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _noble_hashes_sha2 = require("@noble/hashes/sha2");
|
|
3
3
|
|
|
4
4
|
//#region src/intents/intent-hashes/ton-connect.ts
|
|
5
5
|
/**
|
|
@@ -84,7 +84,7 @@ function computeTonConnectHash(payload) {
|
|
|
84
84
|
message.set(part, offset);
|
|
85
85
|
offset += part.length;
|
|
86
86
|
}
|
|
87
|
-
return (0,
|
|
87
|
+
return (0, _noble_hashes_sha2.sha256)(message);
|
|
88
88
|
}
|
|
89
89
|
case "binary": throw new Error("Binary payload hashing is not yet supported");
|
|
90
90
|
case "cell": throw new Error("Cell payload hashing is not yet supported.");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _noble_hashes_sha2 = require("@noble/hashes/sha2");
|
|
3
3
|
|
|
4
4
|
//#region src/intents/intent-hashes/webauthn.ts
|
|
5
5
|
/**
|
|
@@ -10,7 +10,7 @@ let __noble_hashes_sha2 = require("@noble/hashes/sha2");
|
|
|
10
10
|
* @returns 32-byte hash as Uint8Array
|
|
11
11
|
*/
|
|
12
12
|
function computeWebAuthnHash(payload) {
|
|
13
|
-
return (0,
|
|
13
|
+
return (0, _noble_hashes_sha2.sha256)(new TextEncoder().encode(payload));
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Compute hash from a signed WebAuthn payload
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_expirable_nonce = require('./expirable-nonce.cjs');
|
|
3
3
|
const require_intent_payload_factory = require('./intent-payload-factory.cjs');
|
|
4
|
-
let
|
|
4
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
5
5
|
|
|
6
6
|
//#region src/intents/intent-payload-builder.ts
|
|
7
7
|
/**
|
|
@@ -33,7 +33,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
|
|
|
33
33
|
this.intents = [];
|
|
34
34
|
this.env = config.env;
|
|
35
35
|
this.saltManager = config.saltManager;
|
|
36
|
-
this.verifyingContract =
|
|
36
|
+
this.verifyingContract = _defuse_protocol_internal_utils.configsByEnvironment[this.env].contractID;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Set the signer ID (address or account that will sign the intent).
|
|
@@ -44,7 +44,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
|
|
|
44
44
|
* @throws Error if signerId is not a valid NEAR account ID
|
|
45
45
|
*/
|
|
46
46
|
setSigner(signerId) {
|
|
47
|
-
if (!
|
|
47
|
+
if (!_defuse_protocol_internal_utils.utils.validateNearAddress(signerId)) throw new Error(`Invalid signer_id: "${signerId}" is not a valid NEAR account ID`);
|
|
48
48
|
this.signerId = signerId;
|
|
49
49
|
return this;
|
|
50
50
|
}
|
|
@@ -122,7 +122,7 @@ var IntentPayloadBuilder = class IntentPayloadBuilder {
|
|
|
122
122
|
this.deadline = void 0;
|
|
123
123
|
this.intents = [];
|
|
124
124
|
this.customNonce = void 0;
|
|
125
|
-
this.verifyingContract =
|
|
125
|
+
this.verifyingContract = _defuse_protocol_internal_utils.configsByEnvironment[this.env].contractID;
|
|
126
126
|
return this;
|
|
127
127
|
}
|
|
128
128
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
3
3
|
|
|
4
4
|
//#region src/intents/intent-relayer-impl/intent-relayer-public.ts
|
|
5
5
|
var IntentRelayerPublic = class {
|
|
@@ -14,11 +14,11 @@ var IntentRelayerPublic = class {
|
|
|
14
14
|
}, ctx))[0];
|
|
15
15
|
}
|
|
16
16
|
async publishIntents({ multiPayloads, quoteHashes }, ctx = {}) {
|
|
17
|
-
const result = await
|
|
17
|
+
const result = await _defuse_protocol_internal_utils.solverRelay.publishIntents({
|
|
18
18
|
quote_hashes: quoteHashes,
|
|
19
19
|
signed_datas: multiPayloads
|
|
20
20
|
}, {
|
|
21
|
-
baseURL:
|
|
21
|
+
baseURL: _defuse_protocol_internal_utils.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
22
22
|
logger: ctx.logger,
|
|
23
23
|
solverRelayApiKey: this.solverRelayApiKey
|
|
24
24
|
});
|
|
@@ -27,14 +27,14 @@ var IntentRelayerPublic = class {
|
|
|
27
27
|
}
|
|
28
28
|
async waitForSettlement(ticket, ctx = {}) {
|
|
29
29
|
return { tx: {
|
|
30
|
-
hash: (await
|
|
30
|
+
hash: (await _defuse_protocol_internal_utils.solverRelay.waitForIntentSettlement({
|
|
31
31
|
intentHash: ticket,
|
|
32
|
-
signal:
|
|
33
|
-
baseURL:
|
|
32
|
+
signal: ctx.signal,
|
|
33
|
+
baseURL: _defuse_protocol_internal_utils.configsByEnvironment[this.env].solverRelayBaseURL,
|
|
34
34
|
logger: ctx.logger,
|
|
35
35
|
solverRelayApiKey: this.solverRelayApiKey
|
|
36
36
|
})).txHash,
|
|
37
|
-
accountId:
|
|
37
|
+
accountId: _defuse_protocol_internal_utils.configsByEnvironment[this.env].contractID
|
|
38
38
|
} };
|
|
39
39
|
}
|
|
40
40
|
};
|
|
@@ -28,7 +28,7 @@ var IntentRelayerPublic = class {
|
|
|
28
28
|
return { tx: {
|
|
29
29
|
hash: (await solverRelay.waitForIntentSettlement({
|
|
30
30
|
intentHash: ticket,
|
|
31
|
-
signal:
|
|
31
|
+
signal: ctx.signal,
|
|
32
32
|
baseURL: configsByEnvironment[this.env].solverRelayBaseURL,
|
|
33
33
|
logger: ctx.logger,
|
|
34
34
|
solverRelayApiKey: this.solverRelayApiKey
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_intent_signer_nep413 = require('./intent-signer-nep413.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _scure_base = require("@scure/base");
|
|
4
4
|
|
|
5
5
|
//#region src/intents/intent-signer-impl/intent-signer-near-keypair.ts
|
|
6
6
|
var IntentSignerNearKeypair = class extends require_intent_signer_nep413.IntentSignerNEP413 {
|
|
@@ -10,7 +10,7 @@ var IntentSignerNearKeypair = class extends require_intent_signer_nep413.IntentS
|
|
|
10
10
|
const { publicKey, signature } = signer.sign(nep413Hash);
|
|
11
11
|
return {
|
|
12
12
|
publicKey: publicKey.toString(),
|
|
13
|
-
signature:
|
|
13
|
+
signature: _scure_base.base64.encode(signature)
|
|
14
14
|
};
|
|
15
15
|
},
|
|
16
16
|
accountId
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_nep413 = require('../../lib/nep413.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _scure_base = require("@scure/base");
|
|
4
4
|
|
|
5
5
|
//#region src/intents/intent-signer-impl/intent-signer-nep413.ts
|
|
6
6
|
var IntentSignerNEP413 = class {
|
|
@@ -11,7 +11,7 @@ var IntentSignerNEP413 = class {
|
|
|
11
11
|
async signIntent(intent) {
|
|
12
12
|
const nep413Payload = {
|
|
13
13
|
recipient: intent.verifying_contract,
|
|
14
|
-
nonce: Array.from(
|
|
14
|
+
nonce: Array.from(_scure_base.base64.decode(intent.nonce)),
|
|
15
15
|
message: JSON.stringify({
|
|
16
16
|
deadline: intent.deadline,
|
|
17
17
|
intents: intent.intents,
|
|
@@ -20,7 +20,7 @@ var IntentSignerNEP413 = class {
|
|
|
20
20
|
};
|
|
21
21
|
const nep413Hash = await require_nep413.hashNEP413Message(nep413Payload);
|
|
22
22
|
const { publicKey, signature } = await this.signMessage(nep413Payload, nep413Hash);
|
|
23
|
-
const signatureFormatted = signature.startsWith("ed25519:") ? signature : `ed25519:${
|
|
23
|
+
const signatureFormatted = signature.startsWith("ed25519:") ? signature : `ed25519:${_scure_base.base58.encode(_scure_base.base64.decode(signature))}`;
|
|
24
24
|
return {
|
|
25
25
|
standard: "nep413",
|
|
26
26
|
payload: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
3
3
|
|
|
4
4
|
//#region src/intents/intent-signer-impl/intent-signer-viem.ts
|
|
5
5
|
var IntentSignerViem = class {
|
|
@@ -8,7 +8,7 @@ var IntentSignerViem = class {
|
|
|
8
8
|
}
|
|
9
9
|
async signIntent(intent) {
|
|
10
10
|
const payload = JSON.stringify({
|
|
11
|
-
signer_id: intent.signer_id ?? this.config.accountId ??
|
|
11
|
+
signer_id: intent.signer_id ?? this.config.accountId ?? _defuse_protocol_internal_utils.utils.authHandleToIntentsUserId({
|
|
12
12
|
identifier: this.config.signer.address,
|
|
13
13
|
method: "evm"
|
|
14
14
|
}),
|
|
@@ -22,7 +22,7 @@ var IntentSignerViem = class {
|
|
|
22
22
|
return {
|
|
23
23
|
standard: "erc191",
|
|
24
24
|
payload,
|
|
25
|
-
signature:
|
|
25
|
+
signature: _defuse_protocol_internal_utils.utils.transformERC191Signature(signature)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
};
|
|
@@ -29,11 +29,12 @@ interface IIntentRelayer<Ticket, RelayParams = RelayParamsDefault> {
|
|
|
29
29
|
/**
|
|
30
30
|
* Waits for an intent to be settled on-chain.
|
|
31
31
|
* @param ticket - The ticket returned from publishIntent
|
|
32
|
-
* @param ctx - Optional context with logger
|
|
32
|
+
* @param ctx - Optional context with logger and signal
|
|
33
33
|
* @returns Transaction information once settled
|
|
34
34
|
*/
|
|
35
35
|
waitForSettlement(ticket: Ticket, ctx?: {
|
|
36
36
|
logger?: ILogger;
|
|
37
|
+
signal?: AbortSignal;
|
|
37
38
|
}): Promise<{
|
|
38
39
|
tx: NearTxInfo;
|
|
39
40
|
}>;
|
|
@@ -29,11 +29,12 @@ interface IIntentRelayer<Ticket, RelayParams = RelayParamsDefault> {
|
|
|
29
29
|
/**
|
|
30
30
|
* Waits for an intent to be settled on-chain.
|
|
31
31
|
* @param ticket - The ticket returned from publishIntent
|
|
32
|
-
* @param ctx - Optional context with logger
|
|
32
|
+
* @param ctx - Optional context with logger and signal
|
|
33
33
|
* @returns Transaction information once settled
|
|
34
34
|
*/
|
|
35
35
|
waitForSettlement(ticket: Ticket, ctx?: {
|
|
36
36
|
logger?: ILogger;
|
|
37
|
+
signal?: AbortSignal;
|
|
37
38
|
}): Promise<{
|
|
38
39
|
tx: NearTxInfo;
|
|
39
40
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
3
|
-
let
|
|
2
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
3
|
+
let _scure_base = require("@scure/base");
|
|
4
4
|
let valibot = require("valibot");
|
|
5
5
|
valibot = require_rolldown_runtime.__toESM(valibot);
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ var SaltManager = class {
|
|
|
11
11
|
this.currentSalt = null;
|
|
12
12
|
this.fetchPromise = null;
|
|
13
13
|
this.lastFetchTime = 0;
|
|
14
|
-
this.intentsContract =
|
|
14
|
+
this.intentsContract = _defuse_protocol_internal_utils.configsByEnvironment[env].contractID;
|
|
15
15
|
this.nearProvider = nearProvider;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -59,7 +59,7 @@ var SaltManager = class {
|
|
|
59
59
|
* @returns Promise resolving to the salt
|
|
60
60
|
*/
|
|
61
61
|
async function fetchSalt(nearProvider, contractId) {
|
|
62
|
-
const value = await
|
|
62
|
+
const value = await _defuse_protocol_internal_utils.utils.queryContract({
|
|
63
63
|
contractId,
|
|
64
64
|
methodName: "current_salt",
|
|
65
65
|
args: {},
|
|
@@ -67,7 +67,7 @@ async function fetchSalt(nearProvider, contractId) {
|
|
|
67
67
|
nearClient: nearProvider,
|
|
68
68
|
schema: valibot.string()
|
|
69
69
|
});
|
|
70
|
-
return
|
|
70
|
+
return _scure_base.hex.decode(value);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
//#endregion
|
package/dist/src/lib/array.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
3
3
|
|
|
4
4
|
//#region src/lib/array.ts
|
|
5
5
|
function zip(arr1, arr2) {
|
|
6
|
-
(0,
|
|
6
|
+
(0, _defuse_protocol_internal_utils.assert)(arr1.length === arr2.length, "Arrays must have the same length");
|
|
7
7
|
return arr1.map((v, i) => [v, arr2[i]]);
|
|
8
8
|
}
|
|
9
9
|
|
package/dist/src/lib/caip2.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
3
3
|
|
|
4
4
|
//#region src/lib/caip2.ts
|
|
5
5
|
/**
|
|
@@ -32,14 +32,16 @@ const Chains = {
|
|
|
32
32
|
Aptos: "aptos:mainnet",
|
|
33
33
|
Stellar: "stellar:pubnet",
|
|
34
34
|
Cardano: "cip34:1-764824073",
|
|
35
|
-
Starknet: "starknet:SN_MAIN"
|
|
35
|
+
Starknet: "starknet:SN_MAIN",
|
|
36
|
+
Plasma: "eip155:9745",
|
|
37
|
+
Scroll: "eip155:534352"
|
|
36
38
|
};
|
|
37
39
|
function getEIP155ChainId(chain) {
|
|
38
|
-
(0,
|
|
40
|
+
(0, _defuse_protocol_internal_utils.assert)(chain.startsWith("eip155:"), "Chain is not an EIP-155 chain");
|
|
39
41
|
const chainIdStr = chain.slice(7);
|
|
40
|
-
(0,
|
|
42
|
+
(0, _defuse_protocol_internal_utils.assert)(chainIdStr.length > 0, "Chain is not an EIP-155 chain");
|
|
41
43
|
const chainId = Number(chainIdStr);
|
|
42
|
-
(0,
|
|
44
|
+
(0, _defuse_protocol_internal_utils.assert)(!Number.isNaN(chainId), "Chain is not an EIP-155 chain");
|
|
43
45
|
return chainId;
|
|
44
46
|
}
|
|
45
47
|
|
package/dist/src/lib/caip2.d.cts
CHANGED
|
@@ -30,6 +30,8 @@ declare const Chains: {
|
|
|
30
30
|
readonly Stellar: "stellar:pubnet";
|
|
31
31
|
readonly Cardano: "cip34:1-764824073";
|
|
32
32
|
readonly Starknet: "starknet:SN_MAIN";
|
|
33
|
+
readonly Plasma: "eip155:9745";
|
|
34
|
+
readonly Scroll: "eip155:534352";
|
|
33
35
|
};
|
|
34
36
|
type Chain = (typeof Chains)[keyof typeof Chains];
|
|
35
37
|
//#endregion
|
package/dist/src/lib/caip2.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ declare const Chains: {
|
|
|
30
30
|
readonly Stellar: "stellar:pubnet";
|
|
31
31
|
readonly Cardano: "cip34:1-764824073";
|
|
32
32
|
readonly Starknet: "starknet:SN_MAIN";
|
|
33
|
+
readonly Plasma: "eip155:9745";
|
|
34
|
+
readonly Scroll: "eip155:534352";
|
|
33
35
|
};
|
|
34
36
|
type Chain = (typeof Chains)[keyof typeof Chains];
|
|
35
37
|
//#endregion
|
package/dist/src/lib/caip2.js
CHANGED
|
@@ -31,7 +31,9 @@ const Chains = {
|
|
|
31
31
|
Aptos: "aptos:mainnet",
|
|
32
32
|
Stellar: "stellar:pubnet",
|
|
33
33
|
Cardano: "cip34:1-764824073",
|
|
34
|
-
Starknet: "starknet:SN_MAIN"
|
|
34
|
+
Starknet: "starknet:SN_MAIN",
|
|
35
|
+
Plasma: "eip155:9745",
|
|
36
|
+
Scroll: "eip155:534352"
|
|
35
37
|
};
|
|
36
38
|
function getEIP155ChainId(chain) {
|
|
37
39
|
assert(chain.startsWith("eip155:"), "Chain is not an EIP-155 chain");
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_caip2 = require('./caip2.cjs');
|
|
3
3
|
const require_object = require('./object.cjs');
|
|
4
|
-
let
|
|
4
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
5
5
|
|
|
6
6
|
//#region src/lib/configure-rpc-config.ts
|
|
7
7
|
function configureEvmRpcUrls(defaultRpcUrls, userRpcUrls, supportedChains) {
|
|
8
8
|
const evmRpcUrls = Object.fromEntries(Object.entries(require_object.pick(Object.assign({}, defaultRpcUrls, userRpcUrls ?? {}), supportedChains)).map(([caip2, urls]) => [require_caip2.getEIP155ChainId(caip2), urls]));
|
|
9
|
-
for (const [chainId, urls] of Object.entries(evmRpcUrls)) (0,
|
|
9
|
+
for (const [chainId, urls] of Object.entries(evmRpcUrls)) (0, _defuse_protocol_internal_utils.assert)(urls.length > 0, `EVM RPC URLs for chain ${chainId} are not provided`);
|
|
10
10
|
return evmRpcUrls;
|
|
11
11
|
}
|
|
12
12
|
function configureStellarRpcUrls(defaultRpcUrls, userRpcUrls) {
|
|
13
13
|
const stellarRpcUrls = Object.assign({}, defaultRpcUrls, userRpcUrls?.[require_caip2.Chains.Stellar] ?? {});
|
|
14
|
-
for (const [key, value] of Object.entries(stellarRpcUrls)) (0,
|
|
14
|
+
for (const [key, value] of Object.entries(stellarRpcUrls)) (0, _defuse_protocol_internal_utils.assert)(value.length > 0, `Stellar RPC URL for ${key} is not provided`);
|
|
15
15
|
return stellarRpcUrls;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_apis = require('./tokensUsdPricesHttpClient/apis.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
4
4
|
|
|
5
5
|
//#region src/lib/estimate-fee.ts
|
|
6
6
|
/**
|
|
@@ -25,7 +25,7 @@ function getUnderlyingFee(feeEstimation, route, feeKey) {
|
|
|
25
25
|
*/
|
|
26
26
|
async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions, env, logger, solverRelayApiKey }) {
|
|
27
27
|
try {
|
|
28
|
-
return await
|
|
28
|
+
return await _defuse_protocol_internal_utils.solverRelay.getQuote({
|
|
29
29
|
quoteParams: {
|
|
30
30
|
defuse_asset_identifier_in: tokenAssetId,
|
|
31
31
|
defuse_asset_identifier_out: feeAssetId,
|
|
@@ -36,14 +36,14 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
|
|
|
36
36
|
trusted_metadata: quoteOptions?.trustedMetadata
|
|
37
37
|
},
|
|
38
38
|
config: {
|
|
39
|
-
baseURL:
|
|
39
|
+
baseURL: _defuse_protocol_internal_utils.configsByEnvironment[env].solverRelayBaseURL,
|
|
40
40
|
logBalanceSufficient: false,
|
|
41
41
|
logger,
|
|
42
42
|
solverRelayApiKey
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
} catch (err) {
|
|
46
|
-
if (!(err instanceof
|
|
46
|
+
if (!(err instanceof _defuse_protocol_internal_utils.QuoteError)) throw err;
|
|
47
47
|
logger?.info("Can't get exact out quote, trying to get exact in quote with x1.2");
|
|
48
48
|
const prices = await require_apis.tokens({ env });
|
|
49
49
|
const feeAssetPrice = prices.items.find((t) => t.defuse_asset_id === feeAssetId);
|
|
@@ -59,7 +59,7 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
|
|
|
59
59
|
let exactAmountIn = num / den;
|
|
60
60
|
if (num % den !== 0n) exactAmountIn += 1n;
|
|
61
61
|
if (exactAmountIn === 0n) exactAmountIn = 1n;
|
|
62
|
-
const quote = await
|
|
62
|
+
const quote = await _defuse_protocol_internal_utils.solverRelay.getQuote({
|
|
63
63
|
quoteParams: {
|
|
64
64
|
defuse_asset_identifier_in: tokenAssetId,
|
|
65
65
|
defuse_asset_identifier_out: feeAssetId,
|
|
@@ -70,7 +70,7 @@ async function getFeeQuote({ feeAmount, feeAssetId, tokenAssetId, quoteOptions,
|
|
|
70
70
|
trusted_metadata: quoteOptions?.trustedMetadata
|
|
71
71
|
},
|
|
72
72
|
config: {
|
|
73
|
-
baseURL:
|
|
73
|
+
baseURL: _defuse_protocol_internal_utils.configsByEnvironment[env].solverRelayBaseURL,
|
|
74
74
|
logBalanceSufficient: false,
|
|
75
75
|
logger,
|
|
76
76
|
solverRelayApiKey
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_errors = require('../classes/errors.cjs');
|
|
3
|
-
let
|
|
3
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
4
4
|
|
|
5
5
|
//#region src/lib/parse-defuse-asset-id.ts
|
|
6
6
|
function parseDefuseAssetId(assetId) {
|
|
7
7
|
try {
|
|
8
|
-
return
|
|
8
|
+
return _defuse_protocol_internal_utils.utils.parseDefuseAssetId(assetId);
|
|
9
9
|
} catch {
|
|
10
10
|
throw new require_errors.UnsupportedAssetIdError(assetId, "Invalid asset id format.");
|
|
11
11
|
}
|
|
@@ -22,11 +22,8 @@ function createVirtualChainRoute(auroraEngineContractId, proxyTokenContractId) {
|
|
|
22
22
|
proxyTokenContractId
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function createPoaBridgeRoute(
|
|
26
|
-
return {
|
|
27
|
-
route: require_route_enum.RouteEnum.PoaBridge,
|
|
28
|
-
chain
|
|
29
|
-
};
|
|
25
|
+
function createPoaBridgeRoute() {
|
|
26
|
+
return { route: require_route_enum.RouteEnum.PoaBridge };
|
|
30
27
|
}
|
|
31
28
|
function createHotBridgeRoute(chain) {
|
|
32
29
|
return {
|
|
@@ -6,7 +6,7 @@ declare function createInternalTransferRoute(): InternalTransferRouteConfig;
|
|
|
6
6
|
declare function createNearWithdrawalRoute(msg?: string): NearWithdrawalRouteConfig;
|
|
7
7
|
declare function createOmniBridgeRoute(chain?: Chain): OmniBridgeRouteConfig;
|
|
8
8
|
declare function createVirtualChainRoute(auroraEngineContractId: string, proxyTokenContractId: string | null): VirtualChainRouteConfig;
|
|
9
|
-
declare function createPoaBridgeRoute(
|
|
9
|
+
declare function createPoaBridgeRoute(): PoaBridgeRouteConfig;
|
|
10
10
|
declare function createHotBridgeRoute(chain: Chain): HotBridgeRouteConfig;
|
|
11
11
|
declare function createDefaultRoute(): undefined;
|
|
12
12
|
//#endregion
|
|
@@ -6,7 +6,7 @@ declare function createInternalTransferRoute(): InternalTransferRouteConfig;
|
|
|
6
6
|
declare function createNearWithdrawalRoute(msg?: string): NearWithdrawalRouteConfig;
|
|
7
7
|
declare function createOmniBridgeRoute(chain?: Chain): OmniBridgeRouteConfig;
|
|
8
8
|
declare function createVirtualChainRoute(auroraEngineContractId: string, proxyTokenContractId: string | null): VirtualChainRouteConfig;
|
|
9
|
-
declare function createPoaBridgeRoute(
|
|
9
|
+
declare function createPoaBridgeRoute(): PoaBridgeRouteConfig;
|
|
10
10
|
declare function createHotBridgeRoute(chain: Chain): HotBridgeRouteConfig;
|
|
11
11
|
declare function createDefaultRoute(): undefined;
|
|
12
12
|
//#endregion
|
|
@@ -22,11 +22,8 @@ function createVirtualChainRoute(auroraEngineContractId, proxyTokenContractId) {
|
|
|
22
22
|
proxyTokenContractId
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
function createPoaBridgeRoute(
|
|
26
|
-
return {
|
|
27
|
-
route: RouteEnum.PoaBridge,
|
|
28
|
-
chain
|
|
29
|
-
};
|
|
25
|
+
function createPoaBridgeRoute() {
|
|
26
|
+
return { route: RouteEnum.PoaBridge };
|
|
30
27
|
}
|
|
31
28
|
function createHotBridgeRoute(chain) {
|
|
32
29
|
return {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let
|
|
2
|
+
let _defuse_protocol_internal_utils = require("@defuse-protocol/internal-utils");
|
|
3
3
|
|
|
4
4
|
//#region src/lib/tokensUsdPricesHttpClient/apis.ts
|
|
5
5
|
async function tokens(config) {
|
|
6
|
-
return (await (0,
|
|
7
|
-
url: new URL("tokens",
|
|
6
|
+
return (await (0, _defuse_protocol_internal_utils.request)({
|
|
7
|
+
url: new URL("tokens", _defuse_protocol_internal_utils.configsByEnvironment[config.env].managerConsoleBaseURL),
|
|
8
8
|
...config,
|
|
9
9
|
fetchOptions: {
|
|
10
10
|
...config.fetchOptions,
|