Skip to content

Commit e98054d

Browse files
committed
chore(appv2-movement): fixed comments
Signed-off-by: Kaan Caglan <caglankaan@gmail.com>
1 parent d3c41b3 commit e98054d

File tree

6 files changed

+20
-159
lines changed

6 files changed

+20
-159
lines changed

app2/src/lib/services/aptos/clients.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ export const getPublicClient = (chain: Chain) =>
2727
if (chain.rpc_type !== "aptos") {
2828
throw new NoAptosChainError({ chain })
2929
}
30+
const rpcUrl = chain.getRpcUrl("rpc")
3031
const aptosClient = yield* Effect.try({
3132
try: () => {
3233
const config = new AptosConfig({
33-
fullnode: "https://aptos.testnet.bardock.movementlabs.xyz/v1",
34+
fullnode: rpcUrl.toString(),
3435
network: Network.TESTNET
3536
})
3637
return new Aptos(config)
@@ -46,10 +47,12 @@ export const getWalletClient = (chain: Chain) =>
4647
throw new NoAptosChainError({ chain })
4748
}
4849

50+
const rpcUrl = chain.getRpcUrl("rpc")
51+
4952
const aptosClient = yield* Effect.try({
5053
try: () => {
5154
const config = new AptosConfig({
52-
fullnode: "https://aptos.testnet.bardock.movementlabs.xyz/v1",
55+
fullnode: rpcUrl.toString(),
5356
network: Network.TESTNET
5457
})
5558
const aptos = new Aptos(config)

app2/src/lib/services/shared/quote-token.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const getQuoteToken = (
8585
if (destinationChain.rpc_type === "aptos") {
8686
console.info("destinationChain is aptos")
8787
let network: Network
88-
let rpcUrl: string
88+
// let rpcUrl: string
8989

9090
const rpc = yield* destinationChain
9191
.requireRpcUrl("rpc")
@@ -94,17 +94,15 @@ export const getQuoteToken = (
9494
console.info("rpc: ", rpc.origin)
9595
if (channel.destination_chain_id === "250") {
9696
network = Network.TESTNET
97-
rpcUrl = "https://aptos.testnet.bardock.movementlabs.xyz/v1"
97+
// rpcUrl = "https://aptos.testnet.bardock.movementlabs.xyz/v1"
9898
} else {
9999
return yield* Effect.fail(
100100
new GetQuoteError({ cause: `Unsupported Aptos network: ${channel.destination_chain_id}` })
101101
)
102102
}
103103

104-
// const config = new AptosConfig({ network, fullnode: rpc.origin+"/v1" }); //TODO: rpc.origin is coming without "/v1" at the end, discuss this later
105-
//And also this rpc.origin returns:
106-
// :5173/transfer?source=union-testnet-9&destination=250&asset=0x6d756e6f:1 Access to XMLHttpRequest at 'https://rpc.250.movement.chain.kitchen/v1/accounts/0x80a825c8878d4e22f459f76e581cb477d82f0222e136b06f01ad146e2ae9ed84/module/ibc_app' from origin 'http://localhost:5173' has been blocked by CORS policy: Request header field x-aptos-typescript-sdk-origin-method is not allowed by Access-Control-Allow-Headers in preflight response.
107-
const config = new AptosConfig({ network, fullnode: rpcUrl })
104+
const config = new AptosConfig({ network, fullnode: rpc.origin + "/v1" }) //TODO: rpc.origin is coming without "/v1" at the end, discuss this later
105+
108106
const aptosClient = new Aptos(config)
109107

110108
const output = yield* Effect.tryPromise({

app2/src/lib/services/shared/salt.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ export const generateSalt = Effect.sync(() => {
1010
crypto.getRandomValues(rawSalt)
1111
return toHex(rawSalt) as Hex
1212
})
13+
14+
/**
15+
* Effect that generates cryptographically secure random salts
16+
* used to prevent transfer hash collisions
17+
*/
18+
export const generateSaltAptos = Effect.sync(() => {
19+
const saltHex = new Uint8Array(14)
20+
return toHex(saltHex)
21+
})

app2/src/lib/services/transfer-ucs03-aptos/quote-token.ts

Lines changed: 0 additions & 138 deletions
This file was deleted.

app2/src/lib/services/transfer-ucs03-aptos/salt.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

app2/src/lib/services/transfer-ucs03-aptos/transactions-aptos.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Hash, WaitForTransactionReceiptErrorType, WriteContractErrorType }
33
import { WaitForTransactionReceiptError, WriteContractError } from "./errors.ts"
44
import { getPublicClient } from "../aptos/clients.ts"
55
import { getAccount } from "$lib/services/transfer-ucs03-aptos/account.ts"
6-
import { generateSalt } from "./salt.ts"
6+
import { generateSaltAptos } from "$lib/services/shared"
77
import type { Chain } from "$lib/schema/chain.ts"
88
import type { ValidTransfer } from "$lib/schema/transfer-args.ts"
99

@@ -15,7 +15,7 @@ export const submitTransfer = (_chain: Chain, transfer: ValidTransfer["args"]) =
1515
const account = yield* Effect.flatMap(getAccount, account =>
1616
account ? Effect.succeed(account) : Effect.fail(new Error("No account connected"))
1717
)
18-
const salt = yield* generateSalt
18+
const salt = yield* generateSaltAptos
1919

2020
const walletPayload = {
2121
function: `${transfer.ucs03address}::ibc_app::transfer`,

0 commit comments

Comments
 (0)