thirdweb 5.93.6 → 5.93.7
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/cli/bin.js +20 -0
- package/dist/cjs/cli/bin.js.map +1 -1
- package/dist/cjs/cli/commands/stylus/builder.js +179 -0
- package/dist/cjs/cli/commands/stylus/builder.js.map +1 -0
- package/dist/cjs/cli/commands/stylus/create.js +49 -0
- package/dist/cjs/cli/commands/stylus/create.js.map +1 -0
- package/dist/cjs/contract/deployment/deploy-deterministic.js +1 -1
- package/dist/cjs/contract/deployment/deploy-deterministic.js.map +1 -1
- package/dist/cjs/contract/deployment/deploy-with-abi.js +34 -11
- package/dist/cjs/contract/deployment/deploy-with-abi.js.map +1 -1
- package/dist/cjs/contract/deployment/utils/bootstrap.js +19 -0
- package/dist/cjs/contract/deployment/utils/bootstrap.js.map +1 -1
- package/dist/cjs/contract/deployment/utils/infra.js +1 -1
- package/dist/cjs/contract/deployment/utils/infra.js.map +1 -1
- package/dist/cjs/exports/extensions/stylus.js +9 -0
- package/dist/cjs/exports/extensions/stylus.js.map +1 -0
- package/dist/cjs/extensions/prebuilts/deploy-published.js +10 -0
- package/dist/cjs/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/cjs/extensions/stylus/__generated__/IArbWasm/write/activateProgram.js +124 -0
- package/dist/cjs/extensions/stylus/__generated__/IArbWasm/write/activateProgram.js.map +1 -0
- package/dist/cjs/extensions/stylus/write/activateStylusContract.js +71 -0
- package/dist/cjs/extensions/stylus/write/activateStylusContract.js.map +1 -0
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +12 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/cjs/utils/any-evm/compute-deployment-address.js +3 -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 +14 -2
- package/dist/cjs/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
- package/dist/cjs/utils/any-evm/encode-extra-data-with-uri.js +13 -0
- package/dist/cjs/utils/any-evm/encode-extra-data-with-uri.js.map +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/cli/bin.js +20 -0
- package/dist/esm/cli/bin.js.map +1 -1
- package/dist/esm/cli/commands/stylus/builder.js +175 -0
- package/dist/esm/cli/commands/stylus/builder.js.map +1 -0
- package/dist/esm/cli/commands/stylus/create.js +46 -0
- package/dist/esm/cli/commands/stylus/create.js.map +1 -0
- package/dist/esm/contract/deployment/deploy-deterministic.js +1 -1
- package/dist/esm/contract/deployment/deploy-deterministic.js.map +1 -1
- package/dist/esm/contract/deployment/deploy-with-abi.js +34 -11
- package/dist/esm/contract/deployment/deploy-with-abi.js.map +1 -1
- package/dist/esm/contract/deployment/utils/bootstrap.js +19 -0
- package/dist/esm/contract/deployment/utils/bootstrap.js.map +1 -1
- package/dist/esm/contract/deployment/utils/infra.js +1 -1
- package/dist/esm/contract/deployment/utils/infra.js.map +1 -1
- package/dist/esm/exports/extensions/stylus.js +5 -0
- package/dist/esm/exports/extensions/stylus.js.map +1 -0
- package/dist/esm/extensions/prebuilts/deploy-published.js +10 -0
- package/dist/esm/extensions/prebuilts/deploy-published.js.map +1 -1
- package/dist/esm/extensions/stylus/__generated__/IArbWasm/write/activateProgram.js +117 -0
- package/dist/esm/extensions/stylus/__generated__/IArbWasm/write/activateProgram.js.map +1 -0
- package/dist/esm/extensions/stylus/write/activateStylusContract.js +68 -0
- package/dist/esm/extensions/stylus/write/activateStylusContract.js.map +1 -0
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +12 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/esm/utils/any-evm/compute-deployment-address.js +3 -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 +14 -2
- package/dist/esm/utils/any-evm/compute-published-contract-deploy-info.js.map +1 -1
- package/dist/esm/utils/any-evm/encode-extra-data-with-uri.js +10 -0
- package/dist/esm/utils/any-evm/encode-extra-data-with-uri.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/cli/commands/stylus/builder.d.ts +3 -0
- package/dist/types/cli/commands/stylus/builder.d.ts.map +1 -0
- package/dist/types/cli/commands/stylus/create.d.ts +2 -0
- package/dist/types/cli/commands/stylus/create.d.ts.map +1 -0
- package/dist/types/contract/deployment/deploy-with-abi.d.ts +3 -0
- package/dist/types/contract/deployment/deploy-with-abi.d.ts.map +1 -1
- package/dist/types/contract/deployment/utils/bootstrap.d.ts.map +1 -1
- package/dist/types/exports/extensions/stylus.d.ts +5 -0
- package/dist/types/exports/extensions/stylus.d.ts.map +1 -0
- package/dist/types/extensions/prebuilts/deploy-published.d.ts.map +1 -1
- package/dist/types/extensions/stylus/__generated__/IArbWasm/write/activateProgram.d.ts +79 -0
- package/dist/types/extensions/stylus/__generated__/IArbWasm/write/activateProgram.d.ts.map +1 -0
- package/dist/types/extensions/stylus/write/activateStylusContract.d.ts +25 -0
- package/dist/types/extensions/stylus/write/activateStylusContract.d.ts.map +1 -0
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/MediaRenderer/MediaRenderer.d.ts +1 -1
- package/dist/types/utils/any-evm/compute-deployment-address.d.ts +1 -0
- 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 +7 -3
- package/dist/types/utils/any-evm/compute-published-contract-deploy-info.d.ts.map +1 -1
- package/dist/types/utils/any-evm/deploy-metadata.d.ts +1 -1
- package/dist/types/utils/any-evm/deploy-metadata.d.ts.map +1 -1
- package/dist/types/utils/any-evm/encode-extra-data-with-uri.d.ts +4 -0
- package/dist/types/utils/any-evm/encode-extra-data-with-uri.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +6 -1
- package/src/cli/bin.ts +25 -0
- package/src/cli/commands/stylus/builder.ts +201 -0
- package/src/cli/commands/stylus/create.ts +51 -0
- package/src/contract/deployment/deploy-deterministic.ts +1 -1
- package/src/contract/deployment/deploy-with-abi.ts +39 -13
- package/src/contract/deployment/utils/bootstrap.ts +21 -0
- package/src/contract/deployment/utils/infra.ts +1 -1
- package/src/exports/extensions/stylus.ts +7 -0
- package/src/extensions/prebuilts/deploy-published.ts +12 -0
- package/src/extensions/stylus/__generated__/IArbWasm/write/activateProgram.ts +144 -0
- package/src/extensions/stylus/write/activateStylusContract.ts +95 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +13 -1
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +1 -1
- package/src/utils/any-evm/compute-deployment-address.ts +7 -4
- package/src/utils/any-evm/compute-published-contract-deploy-info.ts +16 -2
- package/src/utils/any-evm/deploy-metadata.ts +1 -1
- package/src/utils/any-evm/encode-extra-data-with-uri.ts +13 -0
- package/src/version.ts +1 -1
@@ -16,6 +16,7 @@ import {
|
|
16
16
|
fetchBytecodeFromCompilerMetadata,
|
17
17
|
} from "../../utils/any-evm/deploy-metadata.js";
|
18
18
|
import type { FetchDeployMetadataResult } from "../../utils/any-evm/deploy-metadata.js";
|
19
|
+
import { encodeExtraDataWithUri } from "../../utils/any-evm/encode-extra-data-with-uri.js";
|
19
20
|
import type { Hex } from "../../utils/encoding/hex.js";
|
20
21
|
import type { Account } from "../../wallets/interfaces/wallet.js";
|
21
22
|
import { getAllDefaultConstructorParamsForImplementation } from "./get-required-transactions.js";
|
@@ -194,6 +195,7 @@ export async function deployContractfromDeployMetadata(
|
|
194
195
|
compilerMetadata: deployMetadata,
|
195
196
|
contractParams: processedInitializeParams,
|
196
197
|
salt,
|
198
|
+
metadataUri: deployMetadata.metadataUri,
|
197
199
|
});
|
198
200
|
}
|
199
201
|
case "autoFactory": {
|
@@ -320,6 +322,7 @@ export async function deployContractfromDeployMetadata(
|
|
320
322
|
compilerMetadata: deployMetadata,
|
321
323
|
contractParams: processedInitializeParams,
|
322
324
|
salt,
|
325
|
+
metadataUri: deployMetadata.metadataUri,
|
323
326
|
});
|
324
327
|
}
|
325
328
|
default:
|
@@ -335,6 +338,7 @@ async function directDeploy(options: {
|
|
335
338
|
compilerMetadata: CompilerMetadata;
|
336
339
|
contractParams?: Record<string, unknown>;
|
337
340
|
salt?: string;
|
341
|
+
metadataUri?: string;
|
338
342
|
}): Promise<string> {
|
339
343
|
const { account, client, chain, compilerMetadata, contractParams, salt } =
|
340
344
|
options;
|
@@ -342,6 +346,7 @@ async function directDeploy(options: {
|
|
342
346
|
const { deployContract } = await import(
|
343
347
|
"../../contract/deployment/deploy-with-abi.js"
|
344
348
|
);
|
349
|
+
const isStylus = options.compilerMetadata.metadata.language === "rust";
|
345
350
|
return deployContract({
|
346
351
|
account,
|
347
352
|
client,
|
@@ -354,6 +359,13 @@ async function directDeploy(options: {
|
|
354
359
|
abi: compilerMetadata.abi,
|
355
360
|
constructorParams: contractParams,
|
356
361
|
salt,
|
362
|
+
extraDataWithUri:
|
363
|
+
isStylus && options.metadataUri
|
364
|
+
? encodeExtraDataWithUri({
|
365
|
+
metadataUri: options.metadataUri,
|
366
|
+
})
|
367
|
+
: undefined,
|
368
|
+
isStylus,
|
357
369
|
});
|
358
370
|
}
|
359
371
|
|
@@ -0,0 +1,144 @@
|
|
1
|
+
import type { AbiParameterToPrimitiveType } from "abitype";
|
2
|
+
import type {
|
3
|
+
BaseTransactionOptions,
|
4
|
+
WithOverrides,
|
5
|
+
} from "../../../../../transaction/types.js";
|
6
|
+
import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
|
7
|
+
import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
|
8
|
+
import { once } from "../../../../../utils/promise/once.js";
|
9
|
+
import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Represents the parameters for the "activateProgram" function.
|
13
|
+
*/
|
14
|
+
export type ActivateProgramParams = WithOverrides<{
|
15
|
+
program: AbiParameterToPrimitiveType<{ type: "address"; name: "program" }>;
|
16
|
+
}>;
|
17
|
+
|
18
|
+
export const FN_SELECTOR = "0x58c780c2" as const;
|
19
|
+
const FN_INPUTS = [
|
20
|
+
{
|
21
|
+
type: "address",
|
22
|
+
name: "program",
|
23
|
+
},
|
24
|
+
] as const;
|
25
|
+
const FN_OUTPUTS = [
|
26
|
+
{
|
27
|
+
type: "uint16",
|
28
|
+
},
|
29
|
+
{
|
30
|
+
type: "uint256",
|
31
|
+
},
|
32
|
+
] as const;
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Checks if the `activateProgram` method is supported by the given contract.
|
36
|
+
* @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
|
37
|
+
* @returns A boolean indicating if the `activateProgram` method is supported.
|
38
|
+
* @extension STYLUS
|
39
|
+
* @example
|
40
|
+
* ```ts
|
41
|
+
* import { isActivateProgramSupported } from "thirdweb/extensions/stylus";
|
42
|
+
*
|
43
|
+
* const supported = isActivateProgramSupported(["0x..."]);
|
44
|
+
* ```
|
45
|
+
*/
|
46
|
+
export function isActivateProgramSupported(availableSelectors: string[]) {
|
47
|
+
return detectMethod({
|
48
|
+
availableSelectors,
|
49
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Encodes the parameters for the "activateProgram" function.
|
55
|
+
* @param options - The options for the activateProgram function.
|
56
|
+
* @returns The encoded ABI parameters.
|
57
|
+
* @extension STYLUS
|
58
|
+
* @example
|
59
|
+
* ```ts
|
60
|
+
* import { encodeActivateProgramParams } from "thirdweb/extensions/stylus";
|
61
|
+
* const result = encodeActivateProgramParams({
|
62
|
+
* program: ...,
|
63
|
+
* });
|
64
|
+
* ```
|
65
|
+
*/
|
66
|
+
export function encodeActivateProgramParams(options: ActivateProgramParams) {
|
67
|
+
return encodeAbiParameters(FN_INPUTS, [options.program]);
|
68
|
+
}
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Encodes the "activateProgram" function into a Hex string with its parameters.
|
72
|
+
* @param options - The options for the activateProgram function.
|
73
|
+
* @returns The encoded hexadecimal string.
|
74
|
+
* @extension STYLUS
|
75
|
+
* @example
|
76
|
+
* ```ts
|
77
|
+
* import { encodeActivateProgram } from "thirdweb/extensions/stylus";
|
78
|
+
* const result = encodeActivateProgram({
|
79
|
+
* program: ...,
|
80
|
+
* });
|
81
|
+
* ```
|
82
|
+
*/
|
83
|
+
export function encodeActivateProgram(options: ActivateProgramParams) {
|
84
|
+
// we do a "manual" concat here to avoid the overhead of the "concatHex" function
|
85
|
+
// we can do this because we know the specific formats of the values
|
86
|
+
return (FN_SELECTOR +
|
87
|
+
encodeActivateProgramParams(options).slice(
|
88
|
+
2,
|
89
|
+
)) as `${typeof FN_SELECTOR}${string}`;
|
90
|
+
}
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Prepares a transaction to call the "activateProgram" function on the contract.
|
94
|
+
* @param options - The options for the "activateProgram" function.
|
95
|
+
* @returns A prepared transaction object.
|
96
|
+
* @extension STYLUS
|
97
|
+
* @example
|
98
|
+
* ```ts
|
99
|
+
* import { sendTransaction } from "thirdweb";
|
100
|
+
* import { activateProgram } from "thirdweb/extensions/stylus";
|
101
|
+
*
|
102
|
+
* const transaction = activateProgram({
|
103
|
+
* contract,
|
104
|
+
* program: ...,
|
105
|
+
* overrides: {
|
106
|
+
* ...
|
107
|
+
* }
|
108
|
+
* });
|
109
|
+
*
|
110
|
+
* // Send the transaction
|
111
|
+
* await sendTransaction({ transaction, account });
|
112
|
+
* ```
|
113
|
+
*/
|
114
|
+
export function activateProgram(
|
115
|
+
options: BaseTransactionOptions<
|
116
|
+
| ActivateProgramParams
|
117
|
+
| {
|
118
|
+
asyncParams: () => Promise<ActivateProgramParams>;
|
119
|
+
}
|
120
|
+
>,
|
121
|
+
) {
|
122
|
+
const asyncOptions = once(async () => {
|
123
|
+
return "asyncParams" in options ? await options.asyncParams() : options;
|
124
|
+
});
|
125
|
+
|
126
|
+
return prepareContractCall({
|
127
|
+
contract: options.contract,
|
128
|
+
method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
|
129
|
+
params: async () => {
|
130
|
+
const resolvedOptions = await asyncOptions();
|
131
|
+
return [resolvedOptions.program] as const;
|
132
|
+
},
|
133
|
+
value: async () => (await asyncOptions()).overrides?.value,
|
134
|
+
accessList: async () => (await asyncOptions()).overrides?.accessList,
|
135
|
+
gas: async () => (await asyncOptions()).overrides?.gas,
|
136
|
+
gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
|
137
|
+
maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
|
138
|
+
maxPriorityFeePerGas: async () =>
|
139
|
+
(await asyncOptions()).overrides?.maxPriorityFeePerGas,
|
140
|
+
nonce: async () => (await asyncOptions()).overrides?.nonce,
|
141
|
+
extraGas: async () => (await asyncOptions()).overrides?.extraGas,
|
142
|
+
erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
|
143
|
+
});
|
144
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import {
|
2
|
+
decodeAbiParameters,
|
3
|
+
formatTransactionRequest,
|
4
|
+
parseEther,
|
5
|
+
} from "viem";
|
6
|
+
import type { Chain } from "../../../chains/types.js";
|
7
|
+
import type { ThirdwebClient } from "../../../client/client.js";
|
8
|
+
import { getContract } from "../../../contract/contract.js";
|
9
|
+
import { eth_call } from "../../../rpc/actions/eth_call.js";
|
10
|
+
import { getRpcClient } from "../../../rpc/rpc.js";
|
11
|
+
import { encode } from "../../../transaction/actions/encode.js";
|
12
|
+
import type { PreparedTransaction } from "../../../transaction/prepare-transaction.js";
|
13
|
+
import { activateProgram } from "../__generated__/IArbWasm/write/activateProgram.js";
|
14
|
+
|
15
|
+
const ARB_WASM_ADDRESS = "0x0000000000000000000000000000000000000071";
|
16
|
+
|
17
|
+
export type ActivateStylusContractOptions = {
|
18
|
+
chain: Chain;
|
19
|
+
client: ThirdwebClient;
|
20
|
+
contractAddress: string;
|
21
|
+
};
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Activate a stylus contract by calling ArbWasm Precompile
|
25
|
+
* @param options - The options for activating the contract
|
26
|
+
* @returns A prepared transaction to send
|
27
|
+
* @example
|
28
|
+
* ```ts
|
29
|
+
* import { activateStylusContract } from "thirdweb/stylus";
|
30
|
+
* const transaction = activateStylusContract({
|
31
|
+
* client,
|
32
|
+
* chain,
|
33
|
+
* contractAddress,
|
34
|
+
* });
|
35
|
+
* await sendTransaction({ transaction, account });
|
36
|
+
* ```
|
37
|
+
*/
|
38
|
+
export async function activateStylusContract(
|
39
|
+
options: ActivateStylusContractOptions,
|
40
|
+
) {
|
41
|
+
const { chain, client, contractAddress } = options;
|
42
|
+
const arbWasmPrecompile = getContract({
|
43
|
+
client,
|
44
|
+
chain,
|
45
|
+
address: ARB_WASM_ADDRESS,
|
46
|
+
});
|
47
|
+
|
48
|
+
const dataFee = await estimateDataFee({
|
49
|
+
transaction: activateProgram({
|
50
|
+
program: contractAddress,
|
51
|
+
contract: arbWasmPrecompile,
|
52
|
+
}),
|
53
|
+
});
|
54
|
+
|
55
|
+
return activateProgram({
|
56
|
+
program: contractAddress,
|
57
|
+
contract: arbWasmPrecompile,
|
58
|
+
overrides: {
|
59
|
+
value: dataFee,
|
60
|
+
},
|
61
|
+
});
|
62
|
+
}
|
63
|
+
|
64
|
+
async function estimateDataFee(options: {
|
65
|
+
// biome-ignore lint/suspicious/noExplicitAny:
|
66
|
+
transaction: PreparedTransaction<any>;
|
67
|
+
}) {
|
68
|
+
const data = await encode(options.transaction);
|
69
|
+
|
70
|
+
const serializedTx = formatTransactionRequest({
|
71
|
+
data,
|
72
|
+
to: ARB_WASM_ADDRESS,
|
73
|
+
value: parseEther("1"), // only for simulation. it will be replaced with estimated data fee.
|
74
|
+
});
|
75
|
+
|
76
|
+
const rpcRequest = getRpcClient(options.transaction);
|
77
|
+
try {
|
78
|
+
const result = await eth_call(rpcRequest, serializedTx);
|
79
|
+
const [, dataFee] = decodeAbiParameters(
|
80
|
+
[
|
81
|
+
{
|
82
|
+
type: "uint16",
|
83
|
+
},
|
84
|
+
{
|
85
|
+
type: "uint256",
|
86
|
+
},
|
87
|
+
],
|
88
|
+
result,
|
89
|
+
);
|
90
|
+
|
91
|
+
return (dataFee * BigInt(100 + 10)) / BigInt(100); // bump 10%
|
92
|
+
} catch {
|
93
|
+
return 0n;
|
94
|
+
}
|
95
|
+
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { useQueryClient } from "@tanstack/react-query";
|
2
2
|
import { useCallback, useMemo, useState } from "react";
|
3
3
|
import type { Chain } from "../../../../../../chains/types.js";
|
4
|
+
import { getCachedChain } from "../../../../../../chains/utils.js";
|
4
5
|
import type { ThirdwebClient } from "../../../../../../client/client.js";
|
5
6
|
import { NATIVE_TOKEN_ADDRESS } from "../../../../../../constants/addresses.js";
|
6
7
|
import type { BuyWithCryptoStatus } from "../../../../../../pay/buyWithCrypto/getStatus.js";
|
@@ -112,10 +113,21 @@ export default function BuyScreen(props: BuyScreenProps) {
|
|
112
113
|
return <LoadingScreen />;
|
113
114
|
}
|
114
115
|
|
116
|
+
const supportedDestinations = props.supportedTokens
|
117
|
+
? Object.entries(props.supportedTokens).map(([chainId, tokens]) => ({
|
118
|
+
chain: getCachedChain(Number.parseInt(chainId)),
|
119
|
+
tokens: tokens.map((t) => ({
|
120
|
+
...t,
|
121
|
+
buyWithCryptoEnabled: true,
|
122
|
+
buyWithFiatEnabled: true,
|
123
|
+
})),
|
124
|
+
}))
|
125
|
+
: supportedDestinationsQuery.data;
|
126
|
+
|
115
127
|
return (
|
116
128
|
<BuyScreenContent
|
117
129
|
{...props}
|
118
|
-
supportedDestinations={
|
130
|
+
supportedDestinations={supportedDestinations}
|
119
131
|
/>
|
120
132
|
);
|
121
133
|
}
|
@@ -583,10 +583,10 @@ function useSwapStatus(props: {
|
|
583
583
|
uiStatus = "completed";
|
584
584
|
break;
|
585
585
|
case "FAILED":
|
586
|
-
case "NOT_FOUND":
|
587
586
|
uiStatus = "failed";
|
588
587
|
break;
|
589
588
|
case "PENDING":
|
589
|
+
case "NOT_FOUND":
|
590
590
|
uiStatus = "pending";
|
591
591
|
break;
|
592
592
|
case "NONE":
|
@@ -11,6 +11,7 @@ type ComputeDeploymentAddressOptions = {
|
|
11
11
|
encodedArgs: Hex;
|
12
12
|
create2FactoryAddress: string;
|
13
13
|
salt?: string;
|
14
|
+
extraDataWithUri?: Hex;
|
14
15
|
};
|
15
16
|
|
16
17
|
/**
|
@@ -40,10 +41,12 @@ export function computeDeploymentAddress(
|
|
40
41
|
: getSaltHash(bytecode);
|
41
42
|
|
42
43
|
// 1. create init bytecode hash with contract's bytecode and encoded args
|
43
|
-
const initBytecode =
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
const initBytecode = options.extraDataWithUri
|
45
|
+
? encodePacked(
|
46
|
+
["bytes", "bytes", "bytes"],
|
47
|
+
[bytecode, options.encodedArgs, options.extraDataWithUri],
|
48
|
+
)
|
49
|
+
: encodePacked(["bytes", "bytes"], [bytecode, options.encodedArgs]);
|
47
50
|
|
48
51
|
// 2. abi-encode pack the deployer address, salt, and bytecode hash
|
49
52
|
const deployInfoPacked = encodePacked(
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { Abi, AbiConstructor } from "abitype";
|
2
|
+
import { encodePacked } from "viem";
|
2
3
|
import type { Chain } from "../../chains/types.js";
|
3
4
|
import type { ThirdwebClient } from "../../client/client.js";
|
4
5
|
import { fetchPublishedContractMetadata } from "../../contract/deployment/publisher.js";
|
@@ -13,6 +14,7 @@ import {
|
|
13
14
|
type FetchDeployMetadataResult,
|
14
15
|
fetchBytecodeFromCompilerMetadata,
|
15
16
|
} from "./deploy-metadata.js";
|
17
|
+
import { encodeExtraDataWithUri } from "./encode-extra-data-with-uri.js";
|
16
18
|
import { getInitBytecodeWithSalt } from "./get-init-bytecode-with-salt.js";
|
17
19
|
|
18
20
|
/**
|
@@ -70,6 +72,7 @@ export async function computeDeploymentInfoFromMetadata(args: {
|
|
70
72
|
}
|
71
73
|
}
|
72
74
|
|
75
|
+
const isStylus = contractMetadata.metadata.language === "rust";
|
73
76
|
return computeDeploymentInfoFromBytecode({
|
74
77
|
client: args.client,
|
75
78
|
chain: args.chain,
|
@@ -81,6 +84,11 @@ export async function computeDeploymentInfoFromMetadata(args: {
|
|
81
84
|
}),
|
82
85
|
constructorParams: processedConstructorParams,
|
83
86
|
salt: args.salt,
|
87
|
+
extraDataWithUri: isStylus
|
88
|
+
? encodeExtraDataWithUri({
|
89
|
+
metadataUri: contractMetadata.metadataUri,
|
90
|
+
})
|
91
|
+
: undefined,
|
84
92
|
});
|
85
93
|
}
|
86
94
|
|
@@ -91,8 +99,9 @@ export async function computeDeploymentInfoFromBytecode(args: {
|
|
91
99
|
bytecode: Hex;
|
92
100
|
constructorParams?: Record<string, unknown>;
|
93
101
|
salt?: string;
|
102
|
+
extraDataWithUri?: Hex;
|
94
103
|
}) {
|
95
|
-
const { client, chain, constructorParams, salt } = args;
|
104
|
+
const { client, chain, constructorParams, salt, extraDataWithUri } = args;
|
96
105
|
const create2FactoryAddress = await computeCreate2FactoryAddress({
|
97
106
|
client,
|
98
107
|
chain,
|
@@ -110,11 +119,16 @@ export async function computeDeploymentInfoFromBytecode(args: {
|
|
110
119
|
encodedArgs,
|
111
120
|
salt,
|
112
121
|
});
|
122
|
+
|
123
|
+
const initCalldata = extraDataWithUri
|
124
|
+
? encodePacked(["bytes", "bytes"], [initBytecodeWithsalt, extraDataWithUri])
|
125
|
+
: initBytecodeWithsalt;
|
113
126
|
return {
|
114
127
|
bytecode,
|
115
|
-
|
128
|
+
initCalldata,
|
116
129
|
encodedArgs,
|
117
130
|
create2FactoryAddress,
|
118
131
|
salt,
|
132
|
+
extraDataWithUri,
|
119
133
|
};
|
120
134
|
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { encodePacked } from "ox/AbiParameters";
|
2
|
+
import { numberToHex, stringToHex } from "../encoding/hex.js";
|
3
|
+
|
4
|
+
export function encodeExtraDataWithUri(options: {
|
5
|
+
metadataUri: string;
|
6
|
+
}) {
|
7
|
+
const uriHex = stringToHex(options.metadataUri);
|
8
|
+
const lengthHex = numberToHex(uriHex.replace("0x", "").length / 2, {
|
9
|
+
size: 1,
|
10
|
+
});
|
11
|
+
|
12
|
+
return encodePacked(["bytes", "bytes"], [uriHex, lengthHex]);
|
13
|
+
}
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.93.
|
1
|
+
export const version = "5.93.7";
|