@defuse-protocol/intents-sdk 0.29.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/bridges/omni-bridge/omni-bridge.cjs +3 -1
- package/dist/src/bridges/omni-bridge/omni-bridge.js +3 -1
- package/dist/src/intents/intent-hash.cjs +1 -1
- package/dist/src/intents/intent-hash.js +1 -1
- package/dist/src/lib/validateAddress.cjs +6 -0
- package/dist/src/lib/validateAddress.js +6 -0
- package/package.json +1 -1
|
@@ -114,13 +114,15 @@ var OmniBridge = class {
|
|
|
114
114
|
},
|
|
115
115
|
referral: args.referral
|
|
116
116
|
});
|
|
117
|
+
const nativeFee = (args.feeEstimation.quote === null ? args.feeEstimation.amount : BigInt(args.feeEstimation.quote.amount_out)) - storageDepositAmount;
|
|
118
|
+
(0, __defuse_protocol_internal_utils.assert)(nativeFee >= 0n, `Native fee cannot be negative. Storage deposit amount (${storageDepositAmount}) exceeds fee estimation (${args.feeEstimation.quote === null ? args.feeEstimation.amount : BigInt(args.feeEstimation.quote.amount_out)}). This may indicate a race condition where storage balance changed between fee estimation and intent creation.`);
|
|
117
119
|
intents.push(...require_omni_bridge_utils.createWithdrawIntentsPrimitive({
|
|
118
120
|
assetId: args.withdrawalParams.assetId,
|
|
119
121
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
120
122
|
amount: args.withdrawalParams.amount,
|
|
121
123
|
omniChainKind,
|
|
122
124
|
intentsContract: __defuse_protocol_internal_utils.configsByEnvironment[this.env].contractID,
|
|
123
|
-
nativeFee
|
|
125
|
+
nativeFee,
|
|
124
126
|
storageDepositAmount
|
|
125
127
|
}));
|
|
126
128
|
return Promise.resolve(intents);
|
|
@@ -108,13 +108,15 @@ var OmniBridge = class {
|
|
|
108
108
|
},
|
|
109
109
|
referral: args.referral
|
|
110
110
|
});
|
|
111
|
+
const nativeFee = (args.feeEstimation.quote === null ? args.feeEstimation.amount : BigInt(args.feeEstimation.quote.amount_out)) - storageDepositAmount;
|
|
112
|
+
assert(nativeFee >= 0n, `Native fee cannot be negative. Storage deposit amount (${storageDepositAmount}) exceeds fee estimation (${args.feeEstimation.quote === null ? args.feeEstimation.amount : BigInt(args.feeEstimation.quote.amount_out)}). This may indicate a race condition where storage balance changed between fee estimation and intent creation.`);
|
|
111
113
|
intents.push(...createWithdrawIntentsPrimitive({
|
|
112
114
|
assetId: args.withdrawalParams.assetId,
|
|
113
115
|
destinationAddress: args.withdrawalParams.destinationAddress,
|
|
114
116
|
amount: args.withdrawalParams.amount,
|
|
115
117
|
omniChainKind,
|
|
116
118
|
intentsContract: configsByEnvironment[this.env].contractID,
|
|
117
|
-
nativeFee
|
|
119
|
+
nativeFee,
|
|
118
120
|
storageDepositAmount
|
|
119
121
|
}));
|
|
120
122
|
return Promise.resolve(intents);
|
|
@@ -44,7 +44,7 @@ async function computeNep413Hash(multiPayload) {
|
|
|
44
44
|
}
|
|
45
45
|
function computeErc191Hash(multiPayload) {
|
|
46
46
|
const message = multiPayload.payload;
|
|
47
|
-
const messageWithPrefix = "Ethereum Signed Message:\n" + message.length.toString() + message;
|
|
47
|
+
const messageWithPrefix = "Ethereum Signed Message:\n" + new TextEncoder().encode(message).length.toString() + message;
|
|
48
48
|
return (0, __noble_hashes_sha3.keccak_256)(new TextEncoder().encode(messageWithPrefix));
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -41,7 +41,7 @@ async function computeNep413Hash(multiPayload) {
|
|
|
41
41
|
}
|
|
42
42
|
function computeErc191Hash(multiPayload) {
|
|
43
43
|
const message = multiPayload.payload;
|
|
44
|
-
const messageWithPrefix = "Ethereum Signed Message:\n" + message.length.toString() + message;
|
|
44
|
+
const messageWithPrefix = "Ethereum Signed Message:\n" + new TextEncoder().encode(message).length.toString() + message;
|
|
45
45
|
return keccak_256(new TextEncoder().encode(messageWithPrefix));
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -67,6 +67,12 @@ function validateZcashAddress(address) {
|
|
|
67
67
|
} catch {
|
|
68
68
|
return false;
|
|
69
69
|
}
|
|
70
|
+
const uaHrp = "u";
|
|
71
|
+
if (address.startsWith(`${uaHrp}1`)) try {
|
|
72
|
+
return __scure_base.bech32m.decodeToBytes(address).prefix === uaHrp;
|
|
73
|
+
} catch {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
70
76
|
return false;
|
|
71
77
|
}
|
|
72
78
|
/**
|
|
@@ -60,6 +60,12 @@ function validateZcashAddress(address) {
|
|
|
60
60
|
} catch {
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
|
+
const uaHrp = "u";
|
|
64
|
+
if (address.startsWith(`${uaHrp}1`)) try {
|
|
65
|
+
return bech32m.decodeToBytes(address).prefix === uaHrp;
|
|
66
|
+
} catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
63
69
|
return false;
|
|
64
70
|
}
|
|
65
71
|
/**
|