Skip to content

Commit

Permalink
feat(app2): update reciever
Browse files Browse the repository at this point in the history
  • Loading branch information
Swepool committed Mar 3, 2025
1 parent ce2da72 commit 0947ebe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
9 changes: 9 additions & 0 deletions app2/src/lib/schema/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ export const AddressAptosCanonical = AddressCanonicalBytes.pipe(
)
export const AddressAptosDisplay = AddressAptosCanonical
export const AddressAptosZkgm = AddressAptosCanonical

export const ReceiverAddress = Schema.Union(
AddressCosmosCanonical,
AddressEvmCanonical,
AddressAptosCanonical
).annotations({
identifier: "ReceiverAddress",
message: () => "receiver must be a valid address (e.g., cosmos1... or 0x...)"
})
2 changes: 1 addition & 1 deletion app2/src/lib/schema/channel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Schema } from "effect"

export const ChannelId = Schema.Int.pipe(
Schema.nonNegative({ message: () => "sourceChannelId must be non-negative" }),
Schema.nonNegative({ message: () => "ChannelId must be non-negative" }),
Schema.brand("ChannelId")
)
24 changes: 5 additions & 19 deletions app2/src/lib/schema/transfer-arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Schema } from "effect"
import {
AddressAptosCanonical,
AddressCosmosCanonical,
AddressEvmCanonical
AddressEvmCanonical,
ReceiverAddress
} from "$lib/schema/address"
import { RpcType } from "$lib/schema/chain"
import { EVMWethToken, TokenRawAmount, TokenRawDenom } from "$lib/schema/token"
Expand Down Expand Up @@ -33,12 +34,7 @@ export class EVMTransfer extends Schema.Class<EVMTransfer>("EVMTransfer")({
),
...CommonTransferFields,
wethToken: EVMWethToken,
receiver: AddressEvmCanonical.pipe(
Schema.annotations({
message: () =>
"receiver must be a valid EVM canonical address (e.g., 0x followed by 40 hex chars)"
})
),
receiver: ReceiverAddress,
ucs03address: AddressEvmCanonical.pipe(
Schema.annotations({
message: () =>
Expand All @@ -54,12 +50,7 @@ export class CosmosTransfer extends Schema.Class<CosmosTransfer>("CosmosTransfer
),
...CommonTransferFields,
wethToken: Schema.Null,
receiver: AddressCosmosCanonical.pipe(
Schema.annotations({
message: () =>
"receiver must be a valid Cosmos canonical address (e.g., 0x followed by 40 or 64 hex chars)"
})
),
receiver: ReceiverAddress,
ucs03address: AddressCosmosCanonical.pipe(
// Changed to hex
Schema.annotations({
Expand All @@ -76,12 +67,7 @@ export class AptosTransfer extends Schema.Class<AptosTransfer>("AptosTransfer")(
),
...CommonTransferFields,
wethToken: Schema.Null,
receiver: AddressAptosCanonical.pipe(
Schema.annotations({
message: () =>
"receiver must be a valid Aptos canonical address (e.g., 0x followed by 64 hex chars)"
})
),
receiver: ReceiverAddress,
ucs03address: AddressAptosCanonical.pipe(
Schema.annotations({
message: () =>
Expand Down

0 comments on commit 0947ebe

Please sign in to comment.