Skip to content

Commit eb873ba

Browse files
authored
Merge branch 'main' into update-sui-package
2 parents 38b90ad + 1249937 commit eb873ba

File tree

36 files changed

+155
-116
lines changed

36 files changed

+155
-116
lines changed

connect/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-connect",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -98,8 +98,8 @@
9898
},
9999
"dependencies": {
100100
"axios": "^1.4.0",
101-
"@wormhole-foundation/sdk-base": "0.10.5",
102-
"@wormhole-foundation/sdk-definitions": "0.10.5"
101+
"@wormhole-foundation/sdk-base": "0.10.8",
102+
"@wormhole-foundation/sdk-definitions": "0.10.8"
103103
},
104104
"type": "module"
105105
}

connect/src/protocols/tokenBridge/tokenTransfer.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,20 @@ export class TokenTransfer<N extends Network = Network>
173173
let from = { chain: vaa.emitterChain, address: vaa.emitterAddress };
174174
let { token, to } = vaa.payload;
175175

176+
let nativeAddress: NativeAddress<Chain>;
177+
if (token.chain === from.chain) {
178+
nativeAddress = await wh.getTokenNativeAddress(from.chain, token.chain, token.address);
179+
} else {
180+
const fromChain = await wh.getChain(from.chain);
181+
const tb = await fromChain.getTokenBridge();
182+
const wrapped = await tb.getWrappedAsset(token);
183+
nativeAddress = toNative(from.chain, wrapped.toString());
184+
}
185+
186+
const decimals = await wh.getDecimals(from.chain, nativeAddress);
176187
const scaledAmount = amount.scale(
177-
amount.fromBaseUnits(token.amount, TokenTransfer.MAX_DECIMALS),
178-
await wh.getDecimals(token.chain, token.address),
188+
amount.fromBaseUnits(token.amount, Math.min(decimals, TokenTransfer.MAX_DECIMALS)),
189+
decimals,
179190
);
180191

181192
let nativeGasAmount: bigint = 0n;

connect/src/routes/tokenBridge/automatic.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { TransferState } from "../../types.js";
1414
import { Wormhole } from "../../wormhole.js";
1515
import type { StaticRouteMethods } from "../route.js";
1616
import { AutomaticRoute } from "../route.js";
17+
import {
18+
MinAmountError,
19+
} from '../types.js';
1720
import type {
1821
Quote,
1922
QuoteResult,
@@ -167,12 +170,7 @@ export class AutomaticTokenBridgeRoute<N extends Network>
167170
// Min amount is fee + 5%
168171
const minAmount = (fee * 105n) / 100n;
169172
if (amount.units(amt) < minAmount) {
170-
throw new Error(
171-
`Minimum amount is ${amount.display({
172-
amount: minAmount.toString(),
173-
decimals: amt.decimals,
174-
})}`,
175-
);
173+
throw new MinAmountError(amount.fromBaseUnits(minAmount, amt.decimals));
176174
}
177175

178176
const redeemableAmount = amount.units(amt) - fee;

connect/src/routes/types.ts

+28-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { TokenId } from "@wormhole-foundation/sdk-definitions";
22
import type { AttestationReceipt, TransferReceipt } from "../types.js";
3-
import type { amount } from "@wormhole-foundation/sdk-base";
3+
import { amount } from "@wormhole-foundation/sdk-base";
44
import type { QuoteWarning } from "../warnings.js";
55

66
// Extend Options to provide custom options
@@ -84,3 +84,30 @@ export type QuoteError = {
8484
success: false;
8585
error: Error;
8686
};
87+
88+
// Special error to return from quote() or validate() when the
89+
// given transfer amount is too small. Used to helpfully
90+
// show a minimum amount in the interface.
91+
export class MinAmountError extends Error {
92+
min: amount.Amount;
93+
94+
constructor(min: amount.Amount) {
95+
super(`Minimum transfer amount is ${amount.display(min)}`);
96+
this.min = min;
97+
}
98+
99+
minAmount(): amount.Amount {
100+
return this.min;
101+
}
102+
}
103+
104+
// Special error to return from quote() or validate() when the
105+
// protocol can't provide a quote.
106+
export class UnavailableError extends Error {
107+
internalError: Error;
108+
109+
constructor(internalErr: Error) {
110+
super(`Unable to fetch a quote`);
111+
this.internalError = internalErr;
112+
}
113+
}

core/base/__tests__/amount.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe("Amount Tests", function () {
7979
[{ amount: "1", decimals: 18 }, 20, "0.00000000000000000100"],
8080
[{ amount: "5020", decimals: 2 }, 0, "50.2"],
8181
[{ amount: "5020", decimals: 2 }, 4, "50.2000"],
82-
[{ amount: "5020", decimals: 2 }, undefined, "50.20"],
82+
[{ amount: "5020", decimals: 2 }, undefined, "50.2"],
8383
[{ amount: "1", decimals: 0 }, 0, "1"],
8484
];
8585

core/base/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-base",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"

core/base/src/constants/finality.ts

-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ const blockTimeMilliseconds = [
123123
["Sepolia", 15_000],
124124
["Solana", 400],
125125
["Sui", 3_000],
126-
["Scroll", 4_000],
127-
["Mantle", 2_000],
128126
["Terra", 6_000],
129127
["Terra2", 6_000],
130128
["Xpla", 5_000],

core/base/src/constants/rpc.ts

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const rpcConfig = [[
4545
["Rootstock", "https://public-node.rsk.co"],
4646
["Mantle", "https://rpc.mantle.xyz"],
4747
["Klaytn", "https://rpc.ankr.com/klaytn"],
48+
["Snaxchain", "https://mainnet.snaxchain.io"],
4849
]], [
4950
"Testnet", [
5051
["Ethereum", "https://eth-goerli.public.blastapi.io"],

core/base/src/utils/amount.ts

+4
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ export function display(amount: Amount, precision?: number): string {
157157
partial = partial.substring(0, partial.length - 1);
158158
}
159159
partial = partial.padEnd(precision, "0");
160+
} else {
161+
// If no specific precision is given, just trim trailing zeroes
162+
// and return all significant digits.
163+
partial = partial.replace(/0+$/, '');
160164
}
161165

162166
return partial.length > 0 ? `${whole}.${partial}` : whole;

core/definitions/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-definitions",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -86,7 +86,7 @@
8686
"dependencies": {
8787
"@noble/hashes": "^1.3.1",
8888
"@noble/curves": "^1.4.0",
89-
"@wormhole-foundation/sdk-base": "0.10.5"
89+
"@wormhole-foundation/sdk-base": "0.10.8"
9090
},
9191
"type": "module"
9292
}

core/icons/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-icons",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -50,7 +50,7 @@
5050
"dist/cjs"
5151
],
5252
"dependencies": {
53-
"@wormhole-foundation/sdk-base": "0.10.5"
53+
"@wormhole-foundation/sdk-base": "0.10.8"
5454
},
5555
"sideEffects": false,
5656
"scripts": {

examples/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/connect-sdk-examples",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -51,6 +51,6 @@
5151
"tsx": "^4.7.0"
5252
},
5353
"dependencies": {
54-
"@wormhole-foundation/sdk": "0.10.5"
54+
"@wormhole-foundation/sdk": "0.10.8"
5555
}
5656
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-sdk",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"license": "Apache-2.0",
55
"directories": {
66
"test": "__tests__"

platforms/algorand/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-algorand",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -96,7 +96,7 @@
9696
"test": "jest --config ./jest.config.ts"
9797
},
9898
"dependencies": {
99-
"@wormhole-foundation/sdk-connect": "0.10.5",
99+
"@wormhole-foundation/sdk-connect": "0.10.8",
100100
"algosdk": "2.7.0"
101101
},
102102
"type": "module"

platforms/algorand/protocols/core/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-algorand-core",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -45,8 +45,8 @@
4545
"prettier": "prettier --write ./src"
4646
},
4747
"dependencies": {
48-
"@wormhole-foundation/sdk-connect": "0.10.5",
49-
"@wormhole-foundation/sdk-algorand": "0.10.5"
48+
"@wormhole-foundation/sdk-connect": "0.10.8",
49+
"@wormhole-foundation/sdk-algorand": "0.10.8"
5050
},
5151
"type": "module",
5252
"exports": {

platforms/algorand/protocols/tokenBridge/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-algorand-tokenbridge",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -45,9 +45,9 @@
4545
"prettier": "prettier --write ./src"
4646
},
4747
"dependencies": {
48-
"@wormhole-foundation/sdk-connect": "0.10.5",
49-
"@wormhole-foundation/sdk-algorand": "0.10.5",
50-
"@wormhole-foundation/sdk-algorand-core": "0.10.5"
48+
"@wormhole-foundation/sdk-connect": "0.10.8",
49+
"@wormhole-foundation/sdk-algorand": "0.10.8",
50+
"@wormhole-foundation/sdk-algorand-core": "0.10.8"
5151
},
5252
"type": "module",
5353
"exports": {

platforms/aptos/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-aptos",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -46,7 +46,7 @@
4646
"prettier": "prettier --write ./src"
4747
},
4848
"dependencies": {
49-
"@wormhole-foundation/sdk-connect": "0.10.5",
49+
"@wormhole-foundation/sdk-connect": "0.10.8",
5050
"aptos": "1.21.0"
5151
},
5252
"type": "module",

platforms/aptos/protocols/core/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-aptos-core",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -45,8 +45,8 @@
4545
"prettier": "prettier --write ./src"
4646
},
4747
"dependencies": {
48-
"@wormhole-foundation/sdk-connect": "0.10.5",
49-
"@wormhole-foundation/sdk-aptos": "0.10.5"
48+
"@wormhole-foundation/sdk-connect": "0.10.8",
49+
"@wormhole-foundation/sdk-aptos": "0.10.8"
5050
},
5151
"type": "module",
5252
"exports": {

platforms/aptos/protocols/tokenBridge/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-aptos-tokenbridge",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -45,8 +45,8 @@
4545
"prettier": "prettier --write ./src"
4646
},
4747
"dependencies": {
48-
"@wormhole-foundation/sdk-connect": "0.10.5",
49-
"@wormhole-foundation/sdk-aptos": "0.10.5"
48+
"@wormhole-foundation/sdk-connect": "0.10.8",
49+
"@wormhole-foundation/sdk-aptos": "0.10.8"
5050
},
5151
"type": "module",
5252
"exports": {

platforms/cosmwasm/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-cosmwasm",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -53,7 +53,7 @@
5353
"test": "jest --config ./jest.config.ts"
5454
},
5555
"dependencies": {
56-
"@wormhole-foundation/sdk-connect": "0.10.5",
56+
"@wormhole-foundation/sdk-connect": "0.10.8",
5757
"@cosmjs/cosmwasm-stargate": "^0.32.0",
5858
"@cosmjs/proto-signing": "^0.32.0",
5959
"@cosmjs/stargate": "^0.32.0",

platforms/cosmwasm/protocols/core/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-cosmwasm-core",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -52,8 +52,8 @@
5252
"prettier": "prettier --write ./src"
5353
},
5454
"dependencies": {
55-
"@wormhole-foundation/sdk-connect": "0.10.5",
56-
"@wormhole-foundation/sdk-cosmwasm": "0.10.5",
55+
"@wormhole-foundation/sdk-connect": "0.10.8",
56+
"@wormhole-foundation/sdk-cosmwasm": "0.10.8",
5757
"@cosmjs/cosmwasm-stargate": "^0.32.0",
5858
"@cosmjs/stargate": "^0.32.0",
5959
"@injectivelabs/sdk-ts": "^1.14.13-beta.2"

platforms/cosmwasm/protocols/ibc/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-cosmwasm-ibc",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -57,9 +57,9 @@
5757
"@cosmjs/stargate": "^0.32.0",
5858
"cosmjs-types": "^0.9.0",
5959
"@injectivelabs/sdk-ts": "^1.14.13-beta.2",
60-
"@wormhole-foundation/sdk-connect": "0.10.5",
61-
"@wormhole-foundation/sdk-cosmwasm": "0.10.5",
62-
"@wormhole-foundation/sdk-cosmwasm-core": "0.10.5"
60+
"@wormhole-foundation/sdk-connect": "0.10.8",
61+
"@wormhole-foundation/sdk-cosmwasm": "0.10.8",
62+
"@wormhole-foundation/sdk-cosmwasm-core": "0.10.8"
6363
},
6464
"type": "module",
6565
"exports": {

platforms/cosmwasm/protocols/tokenBridge/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wormhole-foundation/sdk-cosmwasm-tokenbridge",
3-
"version": "0.10.5",
3+
"version": "0.10.8",
44
"repository": {
55
"type": "git",
66
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -54,8 +54,8 @@
5454
"dependencies": {
5555
"@injectivelabs/sdk-ts": "^1.14.13-beta.2",
5656
"@cosmjs/cosmwasm-stargate": "^0.32.0",
57-
"@wormhole-foundation/sdk-connect": "0.10.5",
58-
"@wormhole-foundation/sdk-cosmwasm": "0.10.5"
57+
"@wormhole-foundation/sdk-connect": "0.10.8",
58+
"@wormhole-foundation/sdk-cosmwasm": "0.10.8"
5959
},
6060
"type": "module",
6161
"exports": {

0 commit comments

Comments
 (0)