Skip to content

Commit bbb70a9

Browse files
committed
chore(ts-sdk-sui): nix-fmt applied
Signed-off-by: kaancaglan <[email protected]>
1 parent 1a5e346 commit bbb70a9

File tree

9 files changed

+152
-153
lines changed

9 files changed

+152
-153
lines changed

ts-sdk-sui/examples/sui-create-client-generate-instruction.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,54 @@
11
// @ts-ignore
22
if (typeof BigInt.prototype.toJSON !== "function") {
33
// @ts-ignore
4-
BigInt.prototype.toJSON = function () {
4+
BigInt.prototype.toJSON = function() {
55
return this.toString()
66
}
77
}
8-
import { Effect, Logger } from "effect"
98
import { getFullnodeUrl } from "@mysten/sui/client"
10-
import { PublicClient, WalletClient, writeContract, readCoinMetadata, readCoinBalances, sendInstruction } from "../src/Sui.js"
119
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
10+
import { ChannelId } from "@unionlabs/sdk/schema/channel"
11+
import * as ZkgmClient from "@unionlabs/sdk/ZkgmClient"
1212
import * as ZkgmClientRequest from "@unionlabs/sdk/ZkgmClientRequest"
1313
import * as ZkgmClientResponse from "@unionlabs/sdk/ZkgmClientResponse"
14-
import { ChannelId } from "@unionlabs/sdk/schema/channel"
1514
import * as ZkgmIncomingMessage from "@unionlabs/sdk/ZkgmIncomingMessage"
16-
import * as ZkgmClient from "@unionlabs/sdk/ZkgmClient"
15+
import { Effect, Logger } from "effect"
16+
import {
17+
PublicClient,
18+
readCoinBalances,
19+
readCoinMetadata,
20+
sendInstruction,
21+
WalletClient,
22+
writeContract,
23+
} from "../src/Sui.js"
1724
import { layerWithoutWallet } from "../src/SuiZkgmClient.js"
1825

1926
import { Transaction } from "@mysten/sui/transactions"
20-
import * as TokenOrder from "@unionlabs/sdk/TokenOrder"
21-
import { UniversalChainId } from "@unionlabs/sdk/schema/chain"
2227
import { ChainRegistry } from "@unionlabs/sdk/ChainRegistry"
28+
import { UniversalChainId } from "@unionlabs/sdk/schema/chain"
29+
import * as TokenOrder from "@unionlabs/sdk/TokenOrder"
2330

2431
const MNEMONIC = process.env.SUI_MNEMONIC ?? "..."
25-
const RECIPIENT = process.env.RECIPIENT ?? "0x03ff9dd9e093387bdd4432c6a3eb6a1bd5a8f39a530042ac7efe576f18d3232b"
32+
const RECIPIENT = process.env.RECIPIENT
33+
?? "0x03ff9dd9e093387bdd4432c6a3eb6a1bd5a8f39a530042ac7efe576f18d3232b"
2634

2735
const keypair = Ed25519Keypair.deriveKeypair(MNEMONIC)
2836

29-
30-
const program = Effect.gen(function* () {
31-
32-
37+
const program = Effect.gen(function*() {
3338
// TODO: Source will be SUI testnet
3439
const source = yield* ChainRegistry.byUniversalId(
3540
UniversalChainId.make("ethereum.17000"),
3641
)
3742

3843
console.log("source", source)
39-
44+
4045
// TODO: Destination will be somewhere
4146
const destination = yield* ChainRegistry.byUniversalId(
4247
UniversalChainId.make("union.union-1"),
4348
)
4449
const wallet = yield* WalletClient
4550

46-
const sender = wallet.signer.toSuiAddress();
51+
const sender = wallet.signer.toSuiAddress()
4752

4853
console.log("sender:", sender)
4954

@@ -70,7 +75,6 @@ const program = Effect.gen(function* () {
7075
instruction: tokenOrder,
7176
})
7277

73-
7478
const zkgmClient = yield* ZkgmClient.ZkgmClient
7579

7680
const response: ZkgmClientResponse.ZkgmClientResponse = yield* zkgmClient.execute(request)
@@ -82,18 +86,15 @@ const program = Effect.gen(function* () {
8286
)
8387

8488
yield* Effect.log("Completion", completion)
85-
86-
8789
}).pipe(
8890
Effect.provide(layerWithoutWallet),
8991
Effect.provide(PublicClient.Live({ url: getFullnodeUrl("testnet") })),
9092
Effect.provide(
9193
WalletClient.Live({
92-
url: getFullnodeUrl("testnet"),
93-
signer: keypair,
94-
}),
94+
url: getFullnodeUrl("testnet"),
95+
signer: keypair,
96+
}),
9597
),
96-
9798
Effect.provide(ChainRegistry.Default),
9899
Effect.provide(Logger.replace(Logger.defaultLogger, Logger.prettyLoggerDefault)),
99100
)

ts-sdk-sui/examples/sui-create-client-read-coin-related.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,31 @@
11
// @ts-ignore
22
if (typeof BigInt.prototype.toJSON !== "function") {
33
// @ts-ignore
4-
BigInt.prototype.toJSON = function () {
4+
BigInt.prototype.toJSON = function() {
55
return this.toString()
66
}
77
}
88

9-
import { Effect, Logger } from "effect"
109
import { getFullnodeUrl } from "@mysten/sui/client"
10+
import { Effect, Logger } from "effect"
1111

1212
import {
13-
PublicClient,
14-
readCoinMetadata,
15-
readCoinBalances,
16-
readTotalCoinBalance,
1713
getAllCoinsUnique,
18-
getCoinName,
1914
getCoinDecimals,
15+
getCoinName,
16+
PublicClient,
17+
readCoinBalances,
18+
readCoinMetadata,
2019
readCoinSymbol,
20+
readTotalCoinBalance,
2121
} from "../src/Sui.js"
2222

23-
const ADDRESS =
24-
process.env.ADDRESS ??
25-
"0x03ff9dd9e093387bdd4432c6a3eb6a1bd5a8f39a530042ac7efe576f18d3232b"
23+
const ADDRESS = process.env.ADDRESS
24+
?? "0x03ff9dd9e093387bdd4432c6a3eb6a1bd5a8f39a530042ac7efe576f18d3232b"
2625

2726
const COIN_TYPE = "0x2::sui::SUI" as any
2827

29-
const program = Effect.gen(function* () {
28+
const program = Effect.gen(function*() {
3029
const { client } = yield* PublicClient
3130
yield* Effect.log("Sui public client initialized", client.network)
3231

@@ -47,7 +46,6 @@ const program = Effect.gen(function* () {
4746
const total = yield* readTotalCoinBalance(COIN_TYPE, ADDRESS as any)
4847
yield* Effect.log("SUI total balance (mist as BigInt)", total.toString())
4948

50-
5149
const unique = yield* getAllCoinsUnique(ADDRESS as any)
5250

5351
yield* Effect.log("All coins (unique, summed)", unique)

ts-sdk-sui/examples/sui-create-client-write-contract.ts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
11
// @ts-ignore
22
if (typeof BigInt.prototype.toJSON !== "function") {
33
// @ts-ignore
4-
BigInt.prototype.toJSON = function () {
4+
BigInt.prototype.toJSON = function() {
55
return this.toString()
66
}
77
}
8-
import { Effect, Logger } from "effect"
98
import { getFullnodeUrl } from "@mysten/sui/client"
10-
import { PublicClient, WalletClient, writeContract, readCoinMetadata, readCoinBalances } from "../src/Sui.js"
119
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519"
1210
import { Transaction } from "@mysten/sui/transactions"
11+
import { Effect, Logger } from "effect"
12+
import {
13+
PublicClient,
14+
readCoinBalances,
15+
readCoinMetadata,
16+
WalletClient,
17+
writeContract,
18+
} from "../src/Sui.js"
1319

14-
const MNEMONIC = process.env.MNEMONIC ?? "fix auto gallery heart practice drip joke nice decline lift attend bread"
15-
const RECIPIENT = process.env.RECIPIENT ?? "0x03ff9dd9e093387bdd4432c6a3eb6a1bd5a8f39a530042ac7efe576f18d3232b"
20+
const MNEMONIC = process.env.MNEMONIC
21+
?? "fix auto gallery heart practice drip joke nice decline lift attend bread"
22+
const RECIPIENT = process.env.RECIPIENT
23+
?? "0x03ff9dd9e093387bdd4432c6a3eb6a1bd5a8f39a530042ac7efe576f18d3232b"
1624

1725
const keypair = Ed25519Keypair.deriveKeypair(MNEMONIC)
1826

19-
20-
const program = Effect.gen(function* () {
27+
const program = Effect.gen(function*() {
2128
const { client } = yield* PublicClient
22-
yield* Effect.log("Sui public client initialized", client.network )
29+
yield* Effect.log("Sui public client initialized", client.network)
2330
const meta = yield* readCoinMetadata("0x2::sui::SUI" as any)
2431
yield* Effect.log("SUI metadata", meta)
2532

2633
yield* Effect.log("keypair.getPublicKey().toSuiAddress()", keypair.getPublicKey().toSuiAddress())
27-
const balances = yield* readCoinBalances("0x2::sui::SUI" as any, keypair.getPublicKey().toSuiAddress() as any)
34+
const balances = yield* readCoinBalances(
35+
"0x2::sui::SUI" as any,
36+
keypair.getPublicKey().toSuiAddress() as any,
37+
)
2838
yield* Effect.log("SUI balances", balances)
2939

30-
3140
const wallet = yield* WalletClient
3241
const amountMist = 10_000_000n // 0.01 SUI
3342

@@ -38,26 +47,23 @@ const program = Effect.gen(function* () {
3847
const res = yield* writeContract(
3948
client,
4049
keypair,
41-
"0x2", // packageId: Sui framework
42-
"transfer", // module: sui::transfer
43-
"public_transfer", // function
44-
["0x2::coin::Coin<0x2::sui::SUI>"], // type arg T
45-
[coin, recipient], // (obj: T, recipient: address)
50+
"0x2", // packageId: Sui framework
51+
"transfer", // module: sui::transfer
52+
"public_transfer", // function
53+
["0x2::coin::Coin<0x2::sui::SUI>"], // type arg T
54+
[coin, recipient], // (obj: T, recipient: address)
4655
tx,
4756
)
4857

4958
yield* Effect.log("Transfer submitted", res)
50-
51-
5259
}).pipe(
5360
Effect.provide(PublicClient.Live({ url: getFullnodeUrl("testnet") })),
5461
Effect.provide(
5562
WalletClient.Live({
56-
url: getFullnodeUrl("testnet"),
57-
signer: keypair, // ✅ Sui signer
58-
}),
63+
url: getFullnodeUrl("testnet"),
64+
signer: keypair, // ✅ Sui signer
65+
}),
5966
),
60-
6167
Effect.provide(Logger.replace(Logger.defaultLogger, Logger.prettyLoggerDefault)),
6268
)
6369

0 commit comments

Comments
 (0)