-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
192 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,4 @@ db.sqlite | |
db.sqlite3* | ||
|
||
move/*/build | ||
.tsup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
docs/src/content/docs/integrations/api/typescript-sdk/_data/demo-files.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { dedent } from "ts-dedent" | ||
import type { FileSystemTree } from "@webcontainer/api" | ||
|
||
export const demoFiles = { | ||
"mod.ts": { | ||
file: { | ||
contents: dedent(/* ts */ ` | ||
import { http } from "viem" | ||
import { arbitrumSepolia } from "viem/chains" | ||
import { privateKeyToAccount } from "viem/accounts" | ||
import { createUnionClient, type TransferAssetsParameters } from "@unionlabs/client" | ||
const account = privateKeyToAccount(\`0x$\{process.env["PRIVATE_KEY"]\}\`) | ||
console.info(\`Account address: $\{JSON.stringify(account, undefined, 2)\}\`) | ||
const client = createUnionClient({ | ||
account, | ||
chainId: \`$\{arbitrumSepolia.id\}\`, | ||
transport: http("https://sepolia-rollup.arbitrum.io/rpc") | ||
}) | ||
const payload = { | ||
amount: 1n, | ||
autoApprove: false, | ||
destinationChainId: "stride-internal-1", | ||
receiver: "stride14qemq0vw6y3gc3u3e0aty2e764u4gs5l66hpe3", | ||
denomAddress: "0xb1d4538b4571d411f07960ef2838ce337fe1e80e" // LINK | ||
} satisfies TransferAssetsParameters<\`$\{typeof arbitrumSepolia.id\}\`> | ||
const gasResponse = await client.simulateTransaction(payload) | ||
if (gasResponse.isErr()) { | ||
console.error(\`Gas estimation error: $\{gasResponse.error\}\`) | ||
process.exit(1) | ||
} | ||
console.info(\`Gas estimation: $\{gasResponse.value\}\`) | ||
const approval = await client.approveTransaction(payload) | ||
if (approval.isErr()) { | ||
console.error(\`Approval error: $\{approval.error\}\`) | ||
process.exit(1) | ||
} | ||
console.info(\`Approval hash: $\{approval.value\}\`) | ||
const transfer = await client.transferAsset(payload) | ||
if (transfer.isErr()) { | ||
console.error(\`Transfer error: $\{transfer.error\}\`) | ||
process.exit(1) | ||
} | ||
console.info(\`Transfer hash: $\{transfer.value\}\`) | ||
`).trim() | ||
} | ||
}, | ||
".npmrc": { | ||
file: { | ||
contents: dedent(` | ||
engine-strict=true | ||
npm_config_yes=true | ||
auto-install-peers=true | ||
enable-pre-post-scripts=true | ||
strict-peer-dependencies=false | ||
node-options="--no-warnings" | ||
`).trim() | ||
} | ||
}, | ||
"package.json": { | ||
file: { | ||
contents: dedent(/* json */ ` | ||
{ | ||
"name": "demo", | ||
"type": "module", | ||
"dependencies": { | ||
"tsx": "latest", | ||
"viem": "latest", | ||
"@unionlabs/client": "latest" | ||
} | ||
} | ||
`).trim() | ||
} | ||
} | ||
} satisfies FileSystemTree |
Oops, something went wrong.