diff --git a/.changeset/open-readers-do.md b/.changeset/open-readers-do.md deleted file mode 100644 index 3626aef363d..00000000000 --- a/.changeset/open-readers-do.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"thirdweb": patch ---- - -Faster useSendTransaction execution diff --git a/.changeset/sharp-symbols-unite.md b/.changeset/sharp-symbols-unite.md deleted file mode 100644 index 5aa79e66f9b..00000000000 --- a/.changeset/sharp-symbols-unite.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"thirdweb": patch ---- - -Show deposit modal for tokens that don't have any UB routes diff --git a/.changeset/stale-yaks-bathe.md b/.changeset/stale-yaks-bathe.md deleted file mode 100644 index dca5a5b67d6..00000000000 --- a/.changeset/stale-yaks-bathe.md +++ /dev/null @@ -1,154 +0,0 @@ ---- -"thirdweb": minor ---- - -Adds Bridge.Transfer module for direct token transfers: - -```typescript -import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb"; - -const quote = await Bridge.Transfer.prepare({ - chainId: 1, - tokenAddress: NATIVE_TOKEN_ADDRESS, - amount: toWei("0.01"), - sender: "0x...", - receiver: "0x...", - client: thirdwebClient, -}); -``` - -This will return a quote that might look like: -```typescript -{ - originAmount: 10000026098875381n, - destinationAmount: 10000000000000000n, - blockNumber: 22026509n, - timestamp: 1741730936680, - estimatedExecutionTimeMs: 1000 - steps: [ - { - originToken: { - chainId: 1, - address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - symbol: "ETH", - name: "Ethereum", - decimals: 18, - priceUsd: 2000, - iconUri: "https://..." - }, - destinationToken: { - chainId: 1, - address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - symbol: "ETH", - name: "Ethereum", - decimals: 18, - priceUsd: 2000, - iconUri: "https://..." - }, - originAmount: 10000026098875381n, - destinationAmount: 10000000000000000n, - estimatedExecutionTimeMs: 1000 - transactions: [ - { - action: "approval", - id: "0x", - to: "0x...", - data: "0x...", - chainId: 1, - type: "eip1559" - }, - { - action: "transfer", - to: "0x...", - value: 10000026098875381n, - data: "0x...", - chainId: 1, - type: "eip1559" - } - ] - } - ], - expiration: 1741730936680, - intent: { - chainId: 1, - tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - amount: 10000000000000000n, - sender: "0x...", - receiver: "0x..." - } -} -``` - -## Sending the transactions -The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions: - - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction. - - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address. - - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price. - -NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full completion of the transfer. - -You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option: - -```ts -const quote = await Bridge.Transfer.prepare({ - chainId: 1, - tokenAddress: NATIVE_TOKEN_ADDRESS, - amount: toWei("0.01"), - sender: "0x...", - receiver: "0x...", - purchaseData: { - reference: "payment-123", - metadata: { - note: "Transfer to Alice" - } - }, - client: thirdwebClient, -}); -``` - -## Fees -There may be fees associated with the transfer. These fees are paid by the `feePayer` address, which defaults to the `sender` address. You can specify a different address with the `feePayer` option. If you do not specify an option or explicitly specify `sender`, the fees will be added to the input amount. If you specify the `receiver` as the fee payer the fees will be subtracted from the destination amount. - -For example, if you were to request a transfer with `feePayer` set to `receiver`: -```typescript -const quote = await Bridge.Transfer.prepare({ - chainId: 1, - tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC - amount: 100_000_000n, // 100 USDC - sender: "0x...", - receiver: "0x...", - feePayer: "receiver", - client: thirdwebClient, -}); -``` - -The returned quote might look like: -```typescript -{ - originAmount: 100_000_000n, // 100 USDC - destinationAmount: 99_970_000n, // 99.97 USDC - ... -} -``` - -If you were to request a transfer with `feePayer` set to `sender`: -```typescript -const quote = await Bridge.Transfer.prepare({ - chainId: 1, - tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC - amount: 100_000_000n, // 100 USDC - sender: "0x...", - receiver: "0x...", - feePayer: "sender", - client: thirdwebClient, -}); -``` - -The returned quote might look like: -```typescript -{ - originAmount: 100_030_000n, // 100.03 USDC - destinationAmount: 100_000_000n, // 100 USDC - ... -} -``` diff --git a/.changeset/tidy-seas-sing.md b/.changeset/tidy-seas-sing.md deleted file mode 100644 index 3a4a8ebc255..00000000000 --- a/.changeset/tidy-seas-sing.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -"thirdweb": patch ---- - -Added Bridge.Onramp.prepare and Bridge.Onramp.status functions - -## Bridge.Onramp.prepare - -Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token. - -```typescript -import { Bridge } from "thirdweb"; -import { ethereum } from "thirdweb/chains"; -import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb/utils"; - -const preparedOnramp = await Bridge.Onramp.prepare({ - client: thirdwebClient, - onramp: "stripe", - chainId: ethereum.id, - tokenAddress: NATIVE_TOKEN_ADDRESS, - receiver: "0x...", // receiver's address - amount: toWei("10"), // 10 of the destination token - // Optional params: - // sender: "0x...", // sender's address - // onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // token to initially onramp to - // onrampChainId: 1, // chain to initially onramp to - // currency: "USD", - // maxSteps: 2, - // purchaseData: { customId: "123" } -}); - -console.log(preparedOnramp.link); // URL to redirect the user to -console.log(preparedOnramp.currencyAmount); // Price in fiat currency -``` - -## Bridge.Onramp.status - -Retrieves the status of an Onramp session created via Bridge.Onramp.prepare. - -```typescript -import { Bridge } from "thirdweb"; - -const onrampStatus = await Bridge.Onramp.status({ - id: "022218cc-96af-4291-b90c-dadcb47571ec", - client: thirdwebClient, -}); - -// Possible results: -// { -// status: "CREATED", -// transactions: [], -// purchaseData: { -// orderId: "abc-123", -// }, -// } -// -// or -// { -// status: "PENDING", -// transactions: [], -// purchaseData: { -// orderId: "abc-123", -// }, -// } -// -// or -// { -// status: "COMPLETED", -// transactions: [ -// { -// chainId: 1, -// transactionHash: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", -// }, -// ], -// purchaseData: { -// orderId: "abc-123", -// }, -// } -``` diff --git a/packages/thirdweb/CHANGELOG.md b/packages/thirdweb/CHANGELOG.md index 2acbfa9e78a..cd29ed30f65 100644 --- a/packages/thirdweb/CHANGELOG.md +++ b/packages/thirdweb/CHANGELOG.md @@ -1,5 +1,250 @@ # thirdweb +## 5.100.0 + +### Minor Changes + +- [#7064](https://github.com/thirdweb-dev/js/pull/7064) [`64964da`](https://github.com/thirdweb-dev/js/commit/64964da22e11d4a40696d4c0aecb69f74c67fff8) Thanks [@gregfromstl](https://github.com/gregfromstl)! - Adds Bridge.Transfer module for direct token transfers: + + ```typescript + import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb"; + + const quote = await Bridge.Transfer.prepare({ + chainId: 1, + tokenAddress: NATIVE_TOKEN_ADDRESS, + amount: toWei("0.01"), + sender: "0x...", + receiver: "0x...", + client: thirdwebClient, + }); + ``` + + This will return a quote that might look like: + + ```typescript + { + originAmount: 10000026098875381n, + destinationAmount: 10000000000000000n, + blockNumber: 22026509n, + timestamp: 1741730936680, + estimatedExecutionTimeMs: 1000 + steps: [ + { + originToken: { + chainId: 1, + address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + symbol: "ETH", + name: "Ethereum", + decimals: 18, + priceUsd: 2000, + iconUri: "https://..." + }, + destinationToken: { + chainId: 1, + address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + symbol: "ETH", + name: "Ethereum", + decimals: 18, + priceUsd: 2000, + iconUri: "https://..." + }, + originAmount: 10000026098875381n, + destinationAmount: 10000000000000000n, + estimatedExecutionTimeMs: 1000 + transactions: [ + { + action: "approval", + id: "0x", + to: "0x...", + data: "0x...", + chainId: 1, + type: "eip1559" + }, + { + action: "transfer", + to: "0x...", + value: 10000026098875381n, + data: "0x...", + chainId: 1, + type: "eip1559" + } + ] + } + ], + expiration: 1741730936680, + intent: { + chainId: 1, + tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + amount: 10000000000000000n, + sender: "0x...", + receiver: "0x..." + } + } + ``` + + ## Sending the transactions + + The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions: + + - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction. + - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address. + - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price. + + NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full completion of the transfer. + + You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option: + + ```ts + const quote = await Bridge.Transfer.prepare({ + chainId: 1, + tokenAddress: NATIVE_TOKEN_ADDRESS, + amount: toWei("0.01"), + sender: "0x...", + receiver: "0x...", + purchaseData: { + reference: "payment-123", + metadata: { + note: "Transfer to Alice", + }, + }, + client: thirdwebClient, + }); + ``` + + ## Fees + + There may be fees associated with the transfer. These fees are paid by the `feePayer` address, which defaults to the `sender` address. You can specify a different address with the `feePayer` option. If you do not specify an option or explicitly specify `sender`, the fees will be added to the input amount. If you specify the `receiver` as the fee payer the fees will be subtracted from the destination amount. + + For example, if you were to request a transfer with `feePayer` set to `receiver`: + + ```typescript + const quote = await Bridge.Transfer.prepare({ + chainId: 1, + tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC + amount: 100_000_000n, // 100 USDC + sender: "0x...", + receiver: "0x...", + feePayer: "receiver", + client: thirdwebClient, + }); + ``` + + The returned quote might look like: + + ```typescript + { + originAmount: 100_000_000n, // 100 USDC + destinationAmount: 99_970_000n, // 99.97 USDC + ... + } + ``` + + If you were to request a transfer with `feePayer` set to `sender`: + + ```typescript + const quote = await Bridge.Transfer.prepare({ + chainId: 1, + tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC + amount: 100_000_000n, // 100 USDC + sender: "0x...", + receiver: "0x...", + feePayer: "sender", + client: thirdwebClient, + }); + ``` + + The returned quote might look like: + + ```typescript + { + originAmount: 100_030_000n, // 100.03 USDC + destinationAmount: 100_000_000n, // 100 USDC + ... + } + ``` + +### Patch Changes + +- [#7064](https://github.com/thirdweb-dev/js/pull/7064) [`64964da`](https://github.com/thirdweb-dev/js/commit/64964da22e11d4a40696d4c0aecb69f74c67fff8) Thanks [@gregfromstl](https://github.com/gregfromstl)! - Faster useSendTransaction execution + +- [#7092](https://github.com/thirdweb-dev/js/pull/7092) [`d623978`](https://github.com/thirdweb-dev/js/commit/d6239785cfdd7e5900e79e58befe5ffaf2736896) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Show deposit modal for tokens that don't have any UB routes + +- [#7076](https://github.com/thirdweb-dev/js/pull/7076) [`89ccc80`](https://github.com/thirdweb-dev/js/commit/89ccc80d9c5dd188bef495bda048c3aa7f0739af) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Added Bridge.Onramp.prepare and Bridge.Onramp.status functions + + ## Bridge.Onramp.prepare + + Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token. + + ```typescript + import { Bridge } from "thirdweb"; + import { ethereum } from "thirdweb/chains"; + import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb/utils"; + + const preparedOnramp = await Bridge.Onramp.prepare({ + client: thirdwebClient, + onramp: "stripe", + chainId: ethereum.id, + tokenAddress: NATIVE_TOKEN_ADDRESS, + receiver: "0x...", // receiver's address + amount: toWei("10"), // 10 of the destination token + // Optional params: + // sender: "0x...", // sender's address + // onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // token to initially onramp to + // onrampChainId: 1, // chain to initially onramp to + // currency: "USD", + // maxSteps: 2, + // purchaseData: { customId: "123" } + }); + + console.log(preparedOnramp.link); // URL to redirect the user to + console.log(preparedOnramp.currencyAmount); // Price in fiat currency + ``` + + ## Bridge.Onramp.status + + Retrieves the status of an Onramp session created via Bridge.Onramp.prepare. + + ```typescript + import { Bridge } from "thirdweb"; + + const onrampStatus = await Bridge.Onramp.status({ + id: "022218cc-96af-4291-b90c-dadcb47571ec", + client: thirdwebClient, + }); + + // Possible results: + // { + // status: "CREATED", + // transactions: [], + // purchaseData: { + // orderId: "abc-123", + // }, + // } + // + // or + // { + // status: "PENDING", + // transactions: [], + // purchaseData: { + // orderId: "abc-123", + // }, + // } + // + // or + // { + // status: "COMPLETED", + // transactions: [ + // { + // chainId: 1, + // transactionHash: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", + // }, + // ], + // purchaseData: { + // orderId: "abc-123", + // }, + // } + ``` + ## 5.99.3 ### Patch Changes diff --git a/packages/thirdweb/package.json b/packages/thirdweb/package.json index b394c56b547..3e44ad011ba 100644 --- a/packages/thirdweb/package.json +++ b/packages/thirdweb/package.json @@ -1,6 +1,6 @@ { "name": "thirdweb", - "version": "5.99.3", + "version": "5.100.0", "repository": { "type": "git", "url": "git+https://github.com/thirdweb-dev/js.git#main" @@ -147,26 +147,66 @@ }, "typesVersions": { "*": { - "adapters/*": ["./dist/types/exports/adapters/*.d.ts"], - "auth": ["./dist/types/exports/auth.d.ts"], - "chains": ["./dist/types/exports/chains.d.ts"], - "contract": ["./dist/types/exports/contract.d.ts"], - "deploys": ["./dist/types/exports/deploys.d.ts"], - "event": ["./dist/types/exports/event.d.ts"], - "extensions/*": ["./dist/types/exports/extensions/*.d.ts"], - "pay": ["./dist/types/exports/pay.d.ts"], - "react": ["./dist/types/exports/react.d.ts"], - "react-native": ["./dist/types/exports/react.native.d.ts"], - "rpc": ["./dist/types/exports/rpc.d.ts"], - "storage": ["./dist/types/exports/storage.d.ts"], - "transaction": ["./dist/types/exports/transaction.d.ts"], - "utils": ["./dist/types/exports/utils.d.ts"], - "wallets": ["./dist/types/exports/wallets.d.ts"], - "wallets/*": ["./dist/types/exports/wallets/*.d.ts"], - "modules": ["./dist/types/exports/modules.d.ts"], - "social": ["./dist/types/exports/social.d.ts"], - "ai": ["./dist/types/exports/ai.d.ts"], - "bridge": ["./dist/types/exports/bridge.d.ts"] + "adapters/*": [ + "./dist/types/exports/adapters/*.d.ts" + ], + "auth": [ + "./dist/types/exports/auth.d.ts" + ], + "chains": [ + "./dist/types/exports/chains.d.ts" + ], + "contract": [ + "./dist/types/exports/contract.d.ts" + ], + "deploys": [ + "./dist/types/exports/deploys.d.ts" + ], + "event": [ + "./dist/types/exports/event.d.ts" + ], + "extensions/*": [ + "./dist/types/exports/extensions/*.d.ts" + ], + "pay": [ + "./dist/types/exports/pay.d.ts" + ], + "react": [ + "./dist/types/exports/react.d.ts" + ], + "react-native": [ + "./dist/types/exports/react.native.d.ts" + ], + "rpc": [ + "./dist/types/exports/rpc.d.ts" + ], + "storage": [ + "./dist/types/exports/storage.d.ts" + ], + "transaction": [ + "./dist/types/exports/transaction.d.ts" + ], + "utils": [ + "./dist/types/exports/utils.d.ts" + ], + "wallets": [ + "./dist/types/exports/wallets.d.ts" + ], + "wallets/*": [ + "./dist/types/exports/wallets/*.d.ts" + ], + "modules": [ + "./dist/types/exports/modules.d.ts" + ], + "social": [ + "./dist/types/exports/social.d.ts" + ], + "ai": [ + "./dist/types/exports/ai.d.ts" + ], + "bridge": [ + "./dist/types/exports/bridge.d.ts" + ] } }, "browser": { diff --git a/packages/wagmi-adapter/CHANGELOG.md b/packages/wagmi-adapter/CHANGELOG.md index 7130e5f56d6..469b41a3c34 100644 --- a/packages/wagmi-adapter/CHANGELOG.md +++ b/packages/wagmi-adapter/CHANGELOG.md @@ -1,5 +1,7 @@ # @thirdweb-dev/wagmi-adapter +## 0.2.80 + ## 0.2.79 ## 0.2.78 diff --git a/packages/wagmi-adapter/package.json b/packages/wagmi-adapter/package.json index 2e163e153cb..80356719489 100644 --- a/packages/wagmi-adapter/package.json +++ b/packages/wagmi-adapter/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/wagmi-adapter", - "version": "0.2.79", + "version": "0.2.80", "repository": { "type": "git", "url": "git+https://github.com/thirdweb-dev/js.git#main"