thirdweb 5.88.5 → 5.88.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/dist/cjs/adapters/viem.js +110 -0
- package/dist/cjs/adapters/viem.js.map +1 -1
- package/dist/cjs/chains/chain-definitions/arbitrum-nova.js +1 -1
- package/dist/cjs/chains/chain-definitions/arbitrum-nova.js.map +1 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployDeterministic.js +5 -1
- package/dist/cjs/contract/deployment/zksync/zkDeployDeterministic.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +5 -14
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +34 -3
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
- package/dist/cjs/utils/any-evm/compute-deployment-address.js +4 -1
- package/dist/cjs/utils/any-evm/compute-deployment-address.js.map +1 -1
- package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js +1 -0
- package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
- package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js +3 -1
- package/dist/cjs/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
- package/dist/cjs/utils/any-evm/zksync/computeDeploymentAddress.js +6 -1
- package/dist/cjs/utils/any-evm/zksync/computeDeploymentAddress.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/adapters/viem.js +110 -0
- package/dist/esm/adapters/viem.js.map +1 -1
- package/dist/esm/chains/chain-definitions/arbitrum-nova.js +1 -1
- package/dist/esm/chains/chain-definitions/arbitrum-nova.js.map +1 -1
- package/dist/esm/contract/deployment/zksync/zkDeployDeterministic.js +6 -2
- package/dist/esm/contract/deployment/zksync/zkDeployDeterministic.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +5 -14
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +34 -3
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
- package/dist/esm/utils/any-evm/compute-deployment-address.js +4 -1
- package/dist/esm/utils/any-evm/compute-deployment-address.js.map +1 -1
- package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js +1 -0
- package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
- package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js +4 -2
- package/dist/esm/utils/any-evm/get-init-bytecode-with-salt.js.map +1 -1
- package/dist/esm/utils/any-evm/zksync/computeDeploymentAddress.js +6 -1
- package/dist/esm/utils/any-evm/zksync/computeDeploymentAddress.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/adapters/viem.d.ts +65 -1
- package/dist/types/adapters/viem.d.ts.map +1 -1
- package/dist/types/contract/deployment/zksync/zkDeployDeterministic.d.ts.map +1 -1
- package/dist/types/utils/any-evm/compute-deployment-address.d.ts.map +1 -1
- package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts +3 -0
- package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts.map +1 -1
- package/dist/types/utils/any-evm/get-init-bytecode-with-salt.d.ts.map +1 -1
- package/dist/types/utils/any-evm/zksync/computeDeploymentAddress.d.ts +1 -1
- package/dist/types/utils/any-evm/zksync/computeDeploymentAddress.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/adapters/viem-legacy.test.ts +159 -0
- package/src/adapters/viem.test.ts +30 -14
- package/src/adapters/viem.ts +132 -1
- package/src/chains/chain-definitions/arbitrum-nova.ts +1 -1
- package/src/contract/deployment/deploy-deterministic.test.ts +45 -2
- package/src/contract/deployment/zksync/zkDeployDeterministic.ts +10 -2
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +6 -21
- package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx +71 -9
- package/src/utils/any-evm/compute-deployment-address.ts +4 -1
- package/src/utils/any-evm/compute-published-contract-deploy-info.ts +1 -0
- package/src/utils/any-evm/get-init-bytecode-with-salt.ts +5 -2
- package/src/utils/any-evm/zksync/computeDeploymentAddress.ts +6 -2
- package/src/version.ts +1 -1
@@ -7,6 +7,8 @@ import {
|
|
7
7
|
import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
8
8
|
import { TEST_ACCOUNT_A } from "../../../test/src/test-wallets.js";
|
9
9
|
import { simulateTransaction } from "../../transaction/actions/simulate.js";
|
10
|
+
import { computePublishedContractAddress } from "../../utils/any-evm/compute-published-contract-address.js";
|
11
|
+
import { keccakId } from "../../utils/any-evm/keccak-id.js";
|
10
12
|
import { ENTRYPOINT_ADDRESS_v0_6 } from "../../wallets/smart/lib/constants.js";
|
11
13
|
import { prepareDeterministicDeployTransaction } from "./deploy-deterministic.js";
|
12
14
|
|
@@ -51,6 +53,16 @@ describe.runIf(process.env.TW_SECRET_KEY)("deployFromMetadata", () => {
|
|
51
53
|
salt: "some-salt",
|
52
54
|
});
|
53
55
|
const tx2 = prepareDeterministicDeployTransaction({
|
56
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
57
|
+
client: TEST_CLIENT,
|
58
|
+
contractId: "AccountFactory",
|
59
|
+
constructorParams: {
|
60
|
+
defaultAdmin: TEST_ACCOUNT_A.address,
|
61
|
+
entrypoint: ENTRYPOINT_ADDRESS_v0_6,
|
62
|
+
},
|
63
|
+
salt: keccakId("some-salt"),
|
64
|
+
});
|
65
|
+
const tx3 = prepareDeterministicDeployTransaction({
|
54
66
|
chain: FORKED_OPTIMISM_CHAIN,
|
55
67
|
client: TEST_CLIENT,
|
56
68
|
contractId: "AccountFactory",
|
@@ -59,11 +71,42 @@ describe.runIf(process.env.TW_SECRET_KEY)("deployFromMetadata", () => {
|
|
59
71
|
entrypoint: ENTRYPOINT_ADDRESS_v0_6,
|
60
72
|
},
|
61
73
|
});
|
62
|
-
const [tx1Result, tx2Result] = await Promise.all([
|
74
|
+
const [tx1Result, tx2Result, tx3Result] = await Promise.all([
|
63
75
|
simulateTransaction({ transaction: tx1 }),
|
64
76
|
simulateTransaction({ transaction: tx2 }),
|
77
|
+
simulateTransaction({ transaction: tx3 }),
|
78
|
+
]);
|
79
|
+
expect(tx1Result === tx2Result).toBe(true);
|
80
|
+
expect(tx1Result !== tx3Result).toBe(true);
|
81
|
+
});
|
82
|
+
|
83
|
+
it("computed address and deployed address should match", async () => {
|
84
|
+
const computedPromise = computePublishedContractAddress({
|
85
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
86
|
+
client: TEST_CLIENT,
|
87
|
+
contractId: "AccountFactory",
|
88
|
+
constructorParams: {
|
89
|
+
defaultAdmin: TEST_ACCOUNT_A.address,
|
90
|
+
entrypoint: ENTRYPOINT_ADDRESS_v0_6,
|
91
|
+
},
|
92
|
+
salt: keccakId("some-salt"),
|
93
|
+
});
|
94
|
+
const tx = prepareDeterministicDeployTransaction({
|
95
|
+
chain: FORKED_ETHEREUM_CHAIN,
|
96
|
+
client: TEST_CLIENT,
|
97
|
+
contractId: "AccountFactory",
|
98
|
+
constructorParams: {
|
99
|
+
defaultAdmin: TEST_ACCOUNT_A.address,
|
100
|
+
entrypoint: ENTRYPOINT_ADDRESS_v0_6,
|
101
|
+
},
|
102
|
+
salt: keccakId("some-salt"),
|
103
|
+
});
|
104
|
+
|
105
|
+
const [computed, txResult] = await Promise.all([
|
106
|
+
computedPromise,
|
107
|
+
simulateTransaction({ transaction: tx }),
|
65
108
|
]);
|
66
|
-
expect(
|
109
|
+
expect(computed === txResult).toBe(true);
|
67
110
|
});
|
68
111
|
// TODO: Replace these tests' live contracts with mocks
|
69
112
|
it("should deploy a published contract with no constructor", async () => {
|
@@ -13,7 +13,11 @@ import {
|
|
13
13
|
} from "../../../utils/any-evm/zksync/constants.js";
|
14
14
|
import { isContractDeployed } from "../../../utils/bytecode/is-contract-deployed.js";
|
15
15
|
import { ensureBytecodePrefix } from "../../../utils/bytecode/prefix.js";
|
16
|
-
import {
|
16
|
+
import {
|
17
|
+
type Hex,
|
18
|
+
isHex,
|
19
|
+
uint8ArrayToHex,
|
20
|
+
} from "../../../utils/encoding/hex.js";
|
17
21
|
import type { ClientAndChainAndAccount } from "../../../utils/types.js";
|
18
22
|
import { getContract } from "../../contract.js";
|
19
23
|
import { zkDeployContract } from "./zkDeployContract.js";
|
@@ -89,7 +93,11 @@ export async function zkDeployContractDeterministic(
|
|
89
93
|
abi: parseAbi(singletonFactoryAbi),
|
90
94
|
});
|
91
95
|
|
92
|
-
const salt = options?.salt
|
96
|
+
const salt = options?.salt
|
97
|
+
? isHex(options.salt) && options.salt.length === 66
|
98
|
+
? options.salt
|
99
|
+
: keccakId(options.salt)
|
100
|
+
: keccakId("thirdweb");
|
93
101
|
|
94
102
|
await sendAndConfirmTransaction({
|
95
103
|
account: options.account,
|
@@ -635,11 +635,7 @@ function SelectedTokenInfo(props: {
|
|
635
635
|
placeholder="0"
|
636
636
|
type="text"
|
637
637
|
data-placeholder={props.tokenAmount === ""}
|
638
|
-
value={
|
639
|
-
props.tokenAmount
|
640
|
-
? formatNumber(Number(props.tokenAmount), 5)
|
641
|
-
: "0"
|
642
|
-
}
|
638
|
+
value={props.tokenAmount || "0"}
|
643
639
|
disabled={props.disabled}
|
644
640
|
onClick={(e) => {
|
645
641
|
// put cursor at the end of the input
|
@@ -936,13 +932,15 @@ function createSupportedTokens(
|
|
936
932
|
payOptions: PayUIOptions,
|
937
933
|
supportedTokensOverrides?: SupportedTokens,
|
938
934
|
): SupportedTokens {
|
939
|
-
|
935
|
+
// dev override
|
936
|
+
if (supportedTokensOverrides) {
|
937
|
+
return supportedTokensOverrides;
|
938
|
+
}
|
940
939
|
|
940
|
+
const tokens: SupportedTokens = {};
|
941
941
|
const isBuyWithFiatDisabled = payOptions.buyWithFiat === false;
|
942
942
|
const isBuyWithCryptoDisabled = payOptions.buyWithCrypto === false;
|
943
943
|
|
944
|
-
// FIXME (pay) when buywithFiat is disabled, missing a bunch of tokens on base??
|
945
|
-
|
946
944
|
for (const x of data) {
|
947
945
|
tokens[x.chain.id] = x.tokens.filter((t) => {
|
948
946
|
// for source tokens, data is not provided, so we include all of them
|
@@ -970,19 +968,6 @@ function createSupportedTokens(
|
|
970
968
|
return true; // include the token
|
971
969
|
});
|
972
970
|
}
|
973
|
-
|
974
|
-
// override with props.supportedTokens
|
975
|
-
if (supportedTokensOverrides) {
|
976
|
-
for (const k in supportedTokensOverrides) {
|
977
|
-
const key = Number(k);
|
978
|
-
const tokenList = supportedTokensOverrides[key];
|
979
|
-
|
980
|
-
if (tokenList) {
|
981
|
-
tokens[key] = tokenList;
|
982
|
-
}
|
983
|
-
}
|
984
|
-
}
|
985
|
-
|
986
971
|
return tokens;
|
987
972
|
}
|
988
973
|
|
@@ -381,33 +381,90 @@ function TokenBalanceRow(props: {
|
|
381
381
|
<StyledButton
|
382
382
|
onClick={() => onClick(tokenBalance.token, wallet)}
|
383
383
|
variant="secondary"
|
384
|
-
style={
|
384
|
+
style={{
|
385
|
+
...style,
|
386
|
+
display: "flex",
|
387
|
+
justifyContent: "space-between",
|
388
|
+
minWidth: 0, // Needed for text truncation to work
|
389
|
+
}}
|
385
390
|
>
|
386
|
-
<Container
|
391
|
+
<Container
|
392
|
+
flex="row"
|
393
|
+
center="y"
|
394
|
+
gap="sm"
|
395
|
+
style={{
|
396
|
+
flex: "1 1 50%",
|
397
|
+
minWidth: 0,
|
398
|
+
maxWidth: "50%",
|
399
|
+
overflow: "hidden",
|
400
|
+
flexWrap: "nowrap",
|
401
|
+
}}
|
402
|
+
>
|
387
403
|
<TokenIcon
|
388
404
|
token={tokenBalance.token}
|
389
405
|
chain={tokenBalance.chain}
|
390
406
|
size="md"
|
391
407
|
client={client}
|
392
408
|
/>
|
393
|
-
<Container flex="column" gap="4xs">
|
394
|
-
<Text
|
409
|
+
<Container flex="column" gap="4xs" style={{ minWidth: 0 }}>
|
410
|
+
<Text
|
411
|
+
size="xs"
|
412
|
+
color="primaryText"
|
413
|
+
style={{
|
414
|
+
overflow: "hidden",
|
415
|
+
textOverflow: "ellipsis",
|
416
|
+
whiteSpace: "nowrap",
|
417
|
+
}}
|
418
|
+
>
|
395
419
|
{tokenBalance.token.symbol}
|
396
420
|
</Text>
|
397
|
-
{chainInfo &&
|
421
|
+
{chainInfo && (
|
422
|
+
<Text
|
423
|
+
size="xs"
|
424
|
+
style={{
|
425
|
+
overflow: "hidden",
|
426
|
+
textOverflow: "ellipsis",
|
427
|
+
whiteSpace: "nowrap",
|
428
|
+
}}
|
429
|
+
>
|
430
|
+
{chainInfo.name}
|
431
|
+
</Text>
|
432
|
+
)}
|
398
433
|
</Container>
|
399
434
|
</Container>
|
400
|
-
|
435
|
+
|
436
|
+
<Container
|
437
|
+
flex="row"
|
438
|
+
center="y"
|
439
|
+
gap="4xs"
|
440
|
+
color="secondaryText"
|
441
|
+
style={{
|
442
|
+
flex: "1 1 50%",
|
443
|
+
maxWidth: "50%",
|
444
|
+
minWidth: 0,
|
445
|
+
justifyContent: "flex-end",
|
446
|
+
flexWrap: "nowrap",
|
447
|
+
}}
|
448
|
+
>
|
401
449
|
<Container
|
402
450
|
flex="column"
|
403
451
|
color="secondaryText"
|
404
452
|
gap="4xs"
|
405
453
|
style={{
|
406
|
-
justifyContent: "flex-end",
|
407
454
|
alignItems: "flex-end",
|
455
|
+
minWidth: 0,
|
456
|
+
overflow: "hidden",
|
408
457
|
}}
|
409
458
|
>
|
410
|
-
<Text
|
459
|
+
<Text
|
460
|
+
size="xs"
|
461
|
+
color="primaryText"
|
462
|
+
style={{
|
463
|
+
overflow: "hidden",
|
464
|
+
textOverflow: "ellipsis",
|
465
|
+
whiteSpace: "nowrap",
|
466
|
+
}}
|
467
|
+
>
|
411
468
|
{formatTokenBalance(tokenBalance.balance, true, 2)}
|
412
469
|
</Text>
|
413
470
|
<FiatValue
|
@@ -418,7 +475,11 @@ function TokenBalanceRow(props: {
|
|
418
475
|
size="xs"
|
419
476
|
/>
|
420
477
|
</Container>
|
421
|
-
<ChevronRightIcon
|
478
|
+
<ChevronRightIcon
|
479
|
+
width={iconSize.md}
|
480
|
+
height={iconSize.md}
|
481
|
+
style={{ flexShrink: 0 }}
|
482
|
+
/>
|
422
483
|
</Container>
|
423
484
|
</StyledButton>
|
424
485
|
);
|
@@ -429,6 +490,7 @@ const StyledButton = /* @__PURE__ */ styled(Button)((props) => {
|
|
429
490
|
return {
|
430
491
|
background: "transparent",
|
431
492
|
justifyContent: "space-between",
|
493
|
+
flexWrap: "nowrap",
|
432
494
|
flexDirection: "row",
|
433
495
|
padding: spacing.sm,
|
434
496
|
paddingRight: spacing.xs,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { type Hex, encodePacked } from "viem";
|
2
2
|
import { getAddress } from "../address.js";
|
3
3
|
import { ensureBytecodePrefix } from "../bytecode/prefix.js";
|
4
|
+
import { isHex } from "../encoding/hex.js";
|
4
5
|
import { keccak256 } from "../hashing/keccak256.js";
|
5
6
|
import { getSaltHash } from "./get-salt-hash.js";
|
6
7
|
import { keccakId } from "./keccak-id.js";
|
@@ -33,7 +34,9 @@ export function computeDeploymentAddress(
|
|
33
34
|
) {
|
34
35
|
const bytecode = ensureBytecodePrefix(options.bytecode);
|
35
36
|
const saltHash = options.salt
|
36
|
-
?
|
37
|
+
? isHex(options.salt) && options.salt.length === 66
|
38
|
+
? options.salt
|
39
|
+
: keccakId(options.salt)
|
37
40
|
: getSaltHash(bytecode);
|
38
41
|
|
39
42
|
// 1. create init bytecode hash with contract's bytecode and encoded args
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { encodePacked } from "viem/utils";
|
2
2
|
import { ensureBytecodePrefix } from "../bytecode/prefix.js";
|
3
|
-
import { type Hex, uint8ArrayToHex } from "../encoding/hex.js";
|
3
|
+
import { type Hex, isHex, uint8ArrayToHex } from "../encoding/hex.js";
|
4
4
|
import { getSaltHash } from "./get-salt-hash.js";
|
5
5
|
import { keccakId } from "./keccak-id.js";
|
6
6
|
|
@@ -29,8 +29,11 @@ export function getInitBytecodeWithSalt(
|
|
29
29
|
options: GetInitiBytecodeWithSaltOptions,
|
30
30
|
): Hex {
|
31
31
|
const bytecode = ensureBytecodePrefix(options.bytecode);
|
32
|
+
|
32
33
|
const saltHash = options.salt
|
33
|
-
?
|
34
|
+
? isHex(options.salt) && options.salt.length === 66
|
35
|
+
? options.salt
|
36
|
+
: keccakId(options.salt)
|
34
37
|
: getSaltHash(bytecode);
|
35
38
|
|
36
39
|
const encodedArgs =
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Address } from "../../address.js";
|
2
|
-
import type
|
2
|
+
import { type Hex, isHex } from "../../encoding/hex.js";
|
3
3
|
import { keccakId } from "../keccak-id.js";
|
4
4
|
import { create2Address } from "./create2Address.js";
|
5
5
|
|
@@ -13,7 +13,11 @@ type ComputeDeploymentAddressOptions = {
|
|
13
13
|
export function computeDeploymentAddress(
|
14
14
|
options: ComputeDeploymentAddressOptions,
|
15
15
|
) {
|
16
|
-
const saltHash = options.salt
|
16
|
+
const saltHash = options.salt
|
17
|
+
? isHex(options.salt) && options.salt.length === 66
|
18
|
+
? options.salt
|
19
|
+
: keccakId(options.salt)
|
20
|
+
: keccakId("thirdweb");
|
17
21
|
|
18
22
|
return create2Address({
|
19
23
|
sender: options.create2FactoryAddress,
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.88.
|
1
|
+
export const version = "5.88.6";
|