From 2b4e155adc8c6087e6d3e8f8c0116e70c375fff0 Mon Sep 17 00:00:00 2001 From: lljxx1 Date: Thu, 27 Nov 2025 15:17:08 +0800 Subject: [PATCH 1/2] feat: add lighter --- src/utils.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index e9b433f..ac6addd 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -11,7 +11,8 @@ export type VmType = | "solana-vm" | "sui-vm" | "ton-vm" - | "tron-vm"; + | "tron-vm" + | "lighter-vm"; export type ChainIdToVmType = Record; @@ -40,6 +41,8 @@ export const getVmTypeNativeCurrency = (vmType: VmType) => { return "11111111111111111111111111111111"; case "tron-vm": return "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb"; + case "lighter-vm": + return "0"; default: throw new Error(`Native currency not available for vm type ${vmType}`); } @@ -113,6 +116,14 @@ export const encodeAddress = (address: string, vmType: VmType): Uint8Array => { case "tron-vm": { return hexToBytes(`0x${tronweb.utils.address.toHex(address)}`); } + + case "lighter-vm": { + return hexToBytes(`0x${Number(address).toString(16).padStart(32, "0")}`); + } + + default: { + throw new Error(`Vm type not implemented (encodeAddress)`); + } } }; @@ -167,6 +178,10 @@ export const decodeAddress = (address: Uint8Array, vmType: VmType): string => { case "tron-vm": { return tronweb.utils.address.fromHex(bytesToHex(address).slice(2)); } + + case "lighter-vm": { + return Number("0x" + Buffer.from(address).toString("hex")).toString(); + } } }; @@ -204,6 +219,10 @@ export const encodeTransactionId = ( case "tron-vm": { return hexToBytes(`0x${transactionId}`); } + + case "lighter-vm": { + return hexToBytes(`0x${transactionId}`); + } } }; @@ -239,5 +258,9 @@ export const decodeTransactionId = ( case "tron-vm": { return bytesToHex(transactionId).slice(2); } + + case "lighter-vm": { + return bytesToHex(transactionId).slice(2); + } } }; From 3b470b539b04a727eb0b436ef4154689801e6cab Mon Sep 17 00:00:00 2001 From: lljxx1 Date: Fri, 28 Nov 2025 11:04:57 +0800 Subject: [PATCH 2/2] feat: add lighter --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a7c8de..2f7046c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@reservoir0x/relay-protocol-sdk", - "version": "0.0.53", + "version": "0.0.54", "description": "Relay protocol SDK", "main": "dist/index.js", "types": "dist/index.d.ts",