Skip to content

Commit bb0ea52

Browse files
authored
Merge branch 'main' into Add_webhooks_feature_to_Insight_dashboard
2 parents 5d068e0 + 6104401 commit bb0ea52

File tree

134 files changed

+8491
-7174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+8491
-7174
lines changed

.changeset/open-readers-do.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Faster useSendTransaction execution

.changeset/stale-yaks-bathe.md

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
"thirdweb": minor
3+
---
4+
5+
Adds Bridge.Transfer module for direct token transfers:
6+
7+
```typescript
8+
import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb";
9+
10+
const quote = await Bridge.Transfer.prepare({
11+
chainId: 1,
12+
tokenAddress: NATIVE_TOKEN_ADDRESS,
13+
amount: toWei("0.01"),
14+
sender: "0x...",
15+
receiver: "0x...",
16+
client: thirdwebClient,
17+
});
18+
```
19+
20+
This will return a quote that might look like:
21+
```typescript
22+
{
23+
originAmount: 10000026098875381n,
24+
destinationAmount: 10000000000000000n,
25+
blockNumber: 22026509n,
26+
timestamp: 1741730936680,
27+
estimatedExecutionTimeMs: 1000
28+
steps: [
29+
{
30+
originToken: {
31+
chainId: 1,
32+
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
33+
symbol: "ETH",
34+
name: "Ethereum",
35+
decimals: 18,
36+
priceUsd: 2000,
37+
iconUri: "https://..."
38+
},
39+
destinationToken: {
40+
chainId: 1,
41+
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
42+
symbol: "ETH",
43+
name: "Ethereum",
44+
decimals: 18,
45+
priceUsd: 2000,
46+
iconUri: "https://..."
47+
},
48+
originAmount: 10000026098875381n,
49+
destinationAmount: 10000000000000000n,
50+
estimatedExecutionTimeMs: 1000
51+
transactions: [
52+
{
53+
action: "approval",
54+
id: "0x",
55+
to: "0x...",
56+
data: "0x...",
57+
chainId: 1,
58+
type: "eip1559"
59+
},
60+
{
61+
action: "transfer",
62+
to: "0x...",
63+
value: 10000026098875381n,
64+
data: "0x...",
65+
chainId: 1,
66+
type: "eip1559"
67+
}
68+
]
69+
}
70+
],
71+
expiration: 1741730936680,
72+
intent: {
73+
chainId: 1,
74+
tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
75+
amount: 10000000000000000n,
76+
sender: "0x...",
77+
receiver: "0x..."
78+
}
79+
}
80+
```
81+
82+
## Sending the transactions
83+
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:
84+
- Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction.
85+
- 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.
86+
- If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price.
87+
88+
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.
89+
90+
You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option:
91+
92+
```ts
93+
const quote = await Bridge.Transfer.prepare({
94+
chainId: 1,
95+
tokenAddress: NATIVE_TOKEN_ADDRESS,
96+
amount: toWei("0.01"),
97+
sender: "0x...",
98+
receiver: "0x...",
99+
purchaseData: {
100+
reference: "payment-123",
101+
metadata: {
102+
note: "Transfer to Alice"
103+
}
104+
},
105+
client: thirdwebClient,
106+
});
107+
```
108+
109+
## Fees
110+
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.
111+
112+
For example, if you were to request a transfer with `feePayer` set to `receiver`:
113+
```typescript
114+
const quote = await Bridge.Transfer.prepare({
115+
chainId: 1,
116+
tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
117+
amount: 100_000_000n, // 100 USDC
118+
sender: "0x...",
119+
receiver: "0x...",
120+
feePayer: "receiver",
121+
client: thirdwebClient,
122+
});
123+
```
124+
125+
The returned quote might look like:
126+
```typescript
127+
{
128+
originAmount: 100_000_000n, // 100 USDC
129+
destinationAmount: 99_970_000n, // 99.97 USDC
130+
...
131+
}
132+
```
133+
134+
If you were to request a transfer with `feePayer` set to `sender`:
135+
```typescript
136+
const quote = await Bridge.Transfer.prepare({
137+
chainId: 1,
138+
tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
139+
amount: 100_000_000n, // 100 USDC
140+
sender: "0x...",
141+
receiver: "0x...",
142+
feePayer: "sender",
143+
client: thirdwebClient,
144+
});
145+
```
146+
147+
The returned quote might look like:
148+
```typescript
149+
{
150+
originAmount: 100_030_000n, // 100.03 USDC
151+
destinationAmount: 100_000_000n, // 100 USDC
152+
...
153+
}
154+
```

.changeset/tidy-seas-sing.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Added Bridge.Onramp.prepare and Bridge.Onramp.status functions
6+
7+
## Bridge.Onramp.prepare
8+
9+
Prepares an onramp transaction, returning a link from the specified provider to onramp to the specified token.
10+
11+
```typescript
12+
import { Bridge } from "thirdweb";
13+
import { ethereum } from "thirdweb/chains";
14+
import { NATIVE_TOKEN_ADDRESS, toWei } from "thirdweb/utils";
15+
16+
const preparedOnramp = await Bridge.Onramp.prepare({
17+
client: thirdwebClient,
18+
onramp: "stripe",
19+
chainId: ethereum.id,
20+
tokenAddress: NATIVE_TOKEN_ADDRESS,
21+
receiver: "0x...", // receiver's address
22+
amount: toWei("10"), // 10 of the destination token
23+
// Optional params:
24+
// sender: "0x...", // sender's address
25+
// onrampTokenAddress: NATIVE_TOKEN_ADDRESS, // token to initially onramp to
26+
// onrampChainId: 1, // chain to initially onramp to
27+
// currency: "USD",
28+
// maxSteps: 2,
29+
// purchaseData: { customId: "123" }
30+
});
31+
32+
console.log(preparedOnramp.link); // URL to redirect the user to
33+
console.log(preparedOnramp.currencyAmount); // Price in fiat currency
34+
```
35+
36+
## Bridge.Onramp.status
37+
38+
Retrieves the status of an Onramp session created via Bridge.Onramp.prepare.
39+
40+
```typescript
41+
import { Bridge } from "thirdweb";
42+
43+
const onrampStatus = await Bridge.Onramp.status({
44+
id: "022218cc-96af-4291-b90c-dadcb47571ec",
45+
client: thirdwebClient,
46+
});
47+
48+
// Possible results:
49+
// {
50+
// status: "CREATED",
51+
// transactions: [],
52+
// purchaseData: {
53+
// orderId: "abc-123",
54+
// },
55+
// }
56+
//
57+
// or
58+
// {
59+
// status: "PENDING",
60+
// transactions: [],
61+
// purchaseData: {
62+
// orderId: "abc-123",
63+
// },
64+
// }
65+
//
66+
// or
67+
// {
68+
// status: "COMPLETED",
69+
// transactions: [
70+
// {
71+
// chainId: 1,
72+
// transactionHash: "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
73+
// },
74+
// ],
75+
// purchaseData: {
76+
// orderId: "abc-123",
77+
// },
78+
// }
79+
```

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
- run: pnpm test
9090

9191
- name: Code Coverage
92-
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
92+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
9393
with:
9494
directory: packages/
9595
flags: packages

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
# Initializes the CodeQL tools for scanning.
4848
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
49+
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
5050
with:
5151
languages: ${{ matrix.language }}
5252
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -59,7 +59,7 @@ jobs:
5959
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6060
# If this step fails, then you should remove it and run the build manually (see below)
6161
- name: Autobuild
62-
uses: github/codeql-action/autobuild@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
62+
uses: github/codeql-action/autobuild@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
6363

6464
# ℹ️ Command-line programs to run using the OS shell.
6565
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -72,4 +72,4 @@ jobs:
7272
# ./location_of_script_within_repo/buildscript.sh
7373

7474
- name: Perform CodeQL Analysis
75-
uses: github/codeql-action/analyze@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
75+
uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- name: Create release Pull Request or publish to NPM
3838
id: changesets
39-
uses: changesets/action@746c25e23caa47dceb6a48ee85b4cbc5a9f5f293 #v1.4.0
39+
uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba #v1.4.0
4040
with:
4141
publish: pnpm release
4242
version: pnpm version-packages

0 commit comments

Comments
 (0)