Skip to content

Commit

Permalink
Support laos network in server, #925
Browse files Browse the repository at this point in the history
  • Loading branch information
wliyongfeng committed Jul 10, 2024
1 parent 9d0a6a5 commit 0cbf431
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backend/packages/server/src/utils/address.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
const { currentChain } = require("../env");
const { getSs58Format } = require("./consts/chains");
const { getSs58Format, chains } = require("./consts/chains");
const { hexToU8a, isHex } = require("@polkadot/util");
const { decodeAddress, encodeAddress } = require("@polkadot/util-crypto");

function encodeAddressByChain(addr = "") {
const ss58Format = getSs58Format(currentChain());
const chain = currentChain();
if (chain === chains.laos) {
return addr;
}

const ss58Format = getSs58Format(chain);
return encodeAddress(
isHex(addr) ? hexToU8a(addr) : decodeAddress(addr, ss58Format),
ss58Format,
Expand Down
2 changes: 2 additions & 0 deletions backend/packages/server/src/utils/consts/chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const chains = Object.freeze({
"bridgehub-polkadot": "bridgehub-polkadot",
"bridgehub-kusama": "bridgehub-kusama",
"bridgehub-westend": "bridgehub-westend",
laos: "laos",
});

const ss58Format = Object.freeze({
Expand All @@ -50,6 +51,7 @@ const ss58Format = Object.freeze({
[chains.crust]: 66,
[chains.invarch]: 117,
[chains.tinkernet]: 117,
[chains.laos]: 42,
[chains["people-kusama"]]: 2,
[chains["bridgehub-polkadot"]]: 0,
[chains["bridgehub-kusama"]]: 2,
Expand Down

0 comments on commit 0cbf431

Please sign in to comment.