Skip to content

Commit

Permalink
Merge pull request #30 from xendfinance/mainnet
Browse files Browse the repository at this point in the history
preparing mainnet
  • Loading branch information
theiceeman authored Sep 25, 2024
2 parents f59e6ac + f0ef836 commit 6b97b2a
Show file tree
Hide file tree
Showing 22 changed files with 742 additions and 72 deletions.
33 changes: 24 additions & 9 deletions backend-ausdce/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ import { EIP712DOMAIN_NAME, EIP712DOMAIN_VERSION, eip712Transaction } from '@/ut

export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!)

const getWallet = () => {
return process.env.DEBUG
? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
: new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
const getWallet = (signerIndex: number) => {
if (signerIndex === 0) {
return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
}
return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID))
}


async function signHashedTransaction(
transaction: FulfillTxContract,
chainId: string,
contractAddress: string
contractAddress: string,
signerIndex: number
) {
const wallet = getWallet()
const wallet = getWallet(signerIndex)
const domain = {
name: EIP712DOMAIN_NAME,
version: EIP712DOMAIN_VERSION,
Expand Down Expand Up @@ -71,12 +73,25 @@ export const signTransaction = async (
throw Error('waiting for confirmations')
if (tx.toChain.startsWith('evm.')) {
const chainId = tx.toChain.replace('evm.', '')
const { bridgeAssist } = useContracts(undefined, chainId as ChainId)
return await signHashedTransaction(
// const { bridgeAssist } = useContracts(undefined, chainId as ChainId)
let signatures = []
const signer0 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
bridgeAssist(toBridgeAddress).address
toBridgeAddress,
0
)
signatures.push(signer0)
if (process.env.PROD){
const signer1 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
toBridgeAddress,
1
)
signatures.push(signer1)
}
return signatures
} else {
throw Error('bad contract params')
}
Expand Down
33 changes: 24 additions & 9 deletions backend-usdc/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ const eip712Transaction = {

export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!)

const getWallet: () => TypedDataSigner = () =>
process.env.DEBUG
? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
: new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
const getWallet = (signerIndex: number) => {
if (signerIndex === 0) {
return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
}
return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID))
}
// : new GotbitKmsSigner(
// process.env.GKMS_URL!,
// process.env.GKMS_ACCESS_KEY!,
Expand Down Expand Up @@ -78,9 +80,10 @@ export type TransactionAndFulfilled = {
export async function signHashedTransaction(
transaction: FulfillTxContract,
chainId: string,
contractAddress: string
contractAddress: string,
signerIndex: number
): Promise<string> {
const wallet = getWallet()
const wallet = getWallet(signerIndex)
const domain = {
name: EIP712DOMAIN_NAME,
version: EIP712DOMAIN_VERSION,
Expand Down Expand Up @@ -235,12 +238,24 @@ export const signTransaction = async (
throw Error('waiting for confirmations')
if (tx.toChain.startsWith('evm.')) {
const chainId = tx.toChain.replace('evm.', '')
const { bridgeAssist } = useContracts(undefined, chainId as ChainId)
return await signHashedTransaction(
let signatures = []
const signer0 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
bridgeAssist(toBridgeAddress).address
toBridgeAddress,
0
)
signatures.push(signer0)
if (process.env.PROD){
const signer1 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
toBridgeAddress,
1
)
signatures.push(signer1)
}
return signatures
} else {
throw Error('bad contract params')
}
Expand Down
33 changes: 24 additions & 9 deletions backend-usdt/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ const eip712Transaction = {

export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!)

const getWallet: () => TypedDataSigner = () =>
process.env.DEBUG
? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
: new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
const getWallet = (signerIndex: number) => {
if (signerIndex === 0) {
return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
}
return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID))
}
// : new GotbitKmsSigner(
// process.env.GKMS_URL!,
// process.env.GKMS_ACCESS_KEY!,
Expand Down Expand Up @@ -78,9 +80,10 @@ export type TransactionAndFulfilled = {
export async function signHashedTransaction(
transaction: FulfillTxContract,
chainId: string,
contractAddress: string
contractAddress: string,
signerIndex: number
): Promise<string> {
const wallet = getWallet()
const wallet = getWallet(signerIndex)
const domain = {
name: EIP712DOMAIN_NAME,
version: EIP712DOMAIN_VERSION,
Expand Down Expand Up @@ -237,12 +240,24 @@ export const signTransaction = async (
throw Error('waiting for confirmations')
if (tx.toChain.startsWith('evm.')) {
const chainId = tx.toChain.replace('evm.', '')
const { bridgeAssist } = useContracts(undefined, chainId as ChainId)
return await signHashedTransaction(
let signatures = []
const signer0 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
bridgeAssist(toBridgeAddress).address
toBridgeAddress,
0
)
signatures.push(signer0)
if (process.env.PROD){
const signer1 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
toBridgeAddress,
1
)
signatures.push(signer1)
}
return signatures
} else {
throw Error('bad contract params')
}
Expand Down
24 changes: 18 additions & 6 deletions backend-wbtc/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,24 @@ export const signTransaction = async (
throw Error('waiting for confirmations')
if (tx.toChain.startsWith('evm.')) {
const chainId = tx.toChain.replace('evm.', '')
const { bridgeAssist } = useContracts(undefined, chainId as ChainId)
const signature1 = await signHashedTransaction(extractFulfillTransaction(tx), chainId, bridgeAssist(toBridgeAddress).address, 0)
const signature2 = await signHashedTransaction(extractFulfillTransaction(tx), chainId, bridgeAssist(toBridgeAddress).address, 1)
console.log(signature1, signature2)
return [signature1, signature2]

let signatures = []
const signer0 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
toBridgeAddress,
0
)
signatures.push(signer0)

const signer1 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
toBridgeAddress,
1
)
signatures.push(signer1)

return signatures
} else {
throw Error('bad contract params')
}
Expand Down
33 changes: 24 additions & 9 deletions backend-wnt/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ const eip712Transaction = {

export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!)

const getWallet: () => TypedDataSigner = () =>
process.env.DEBUG
? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
: new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
const getWallet = (signerIndex: number) => {
if (signerIndex === 0) {
return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
}
return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID))
}
// : new GotbitKmsSigner(
// process.env.GKMS_URL!,
// process.env.GKMS_ACCESS_KEY!,
Expand Down Expand Up @@ -77,9 +79,10 @@ export type TransactionAndFulfilled = {
export async function signHashedTransaction(
transaction: FulfillTxContract,
chainId: string,
contractAddress: string
contractAddress: string,
signerIndex: number
): Promise<string> {
const wallet = getWallet()
const wallet = getWallet(signerIndex)
const domain = {
name: EIP712DOMAIN_NAME,
version: EIP712DOMAIN_VERSION,
Expand Down Expand Up @@ -235,12 +238,24 @@ export const signTransaction = async (
throw Error('waiting for confirmations')
if (tx.toChain.startsWith('evm.')) {
const chainId = tx.toChain.replace('evm.', '')
const { bridgeAssist } = useContracts(undefined, chainId as ChainId)
return await signHashedTransaction(
let signatures = []
const signer0 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
bridgeAssist(toBridgeAddress).address
toBridgeAddress,
0
)
signatures.push(signer0)
if (process.env.PROD){
const signer1 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
toBridgeAddress,
1
)
signatures.push(signer1)
}
return signatures
} else {
throw Error('bad contract params')
}
Expand Down
33 changes: 24 additions & 9 deletions backend/src/services/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ const eip712Transaction = {

export const getWalletEVM = () => new Wallet(process.env.PRIVATE_KEY!)

const getWallet: () => TypedDataSigner = () =>
process.env.DEBUG
? new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
: new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
const getWallet = (signerIndex: number) => {
if (signerIndex === 0) {
return new Wallet(process.env.PRIVATE_KEY, getProvider(config.DEFAULT_CHAINID))
}
return new Wallet(process.env.PRIVATE_KEY2!, getProvider(config.DEFAULT_CHAINID))
}
// : new GotbitKmsSigner(
// process.env.GKMS_URL!,
// process.env.GKMS_ACCESS_KEY!,
Expand Down Expand Up @@ -77,9 +79,10 @@ export type TransactionAndFulfilled = {
export async function signHashedTransaction(
transaction: FulfillTxContract,
chainId: string,
contractAddress: string
contractAddress: string,
signerIndex: number
): Promise<string> {
const wallet = getWallet()
const wallet = getWallet(signerIndex)
const domain = {
name: EIP712DOMAIN_NAME,
version: EIP712DOMAIN_VERSION,
Expand Down Expand Up @@ -239,12 +242,24 @@ export const signTransaction = async (
throw Error('waiting for confirmations')
if (tx.toChain.startsWith('evm.')) {
const chainId = tx.toChain.replace('evm.', '')
// const { bridgeAssist } = useContracts(undefined, chainId as ChainId)
return await signHashedTransaction(
let signatures = []
const signer0 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
toBridgeAddress //bridgeAssist(toBridgeAddress).address
toBridgeAddress,
0
)
signatures.push(signer0)
if (process.env.PROD){
const signer1 = await signHashedTransaction(
extractFulfillTransaction(tx),
chainId,
toBridgeAddress,
1
)
signatures.push(signer1)
}
return signatures
} else {
throw Error('bad contract params')
}
Expand Down
47 changes: 47 additions & 0 deletions contracts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ export const CHAIN_IDS = {
bitlayer: 200810
}

export const MAINNET_CHAIN_IDS = {
assetChain: 42420,
arbitrum: 42161,
polygon: 137,
ethereum: 1,
bsc: 56,
base: 8453,
bitlayer: 200901
}

export const DEFAULT_NATIVE_TOKEN_CONTRACT =
'0x0000000000000000000000000000000000000001'

export const DEFAULT_TOKEN_PARAMS: {
[chainId: number]: { [token: string]: IDefaultTokenParams }
} = {
Expand Down Expand Up @@ -252,4 +265,38 @@ export const BRIDGED_TOKEN_PARAMS: {
chainIdOriginal: CHAIN_IDS.bitlayer,
},
},
}

export const MAINNET_BRIDGED_TOKEN_PARAMS: {
[chainId: number]: { [token: string]: IBridgedTokenParams }
} = {
42420: {
WNT: {
name: 'Wicrypt Network Token',
symbol: 'WNT',
decimals: 18,
totalSupply: '0',
isLockActive: false,
tokenOriginal: '0xAD4b9c1FbF4923061814dD9d5732EB703FaA53D4',
chainIdOriginal: CHAIN_IDS.arbitrum,
},
USDT: {
name: 'Tether USD',
symbol: 'USDT',
decimals: 6,
totalSupply: '0',
isLockActive: true,
tokenOriginal: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
chainIdOriginal: CHAIN_IDS.ethereum,
},
BTC: {
name: 'Bitlayer Bitcoin',
symbol: 'BTC',
decimals: 18,
totalSupply: '0',
isLockActive: true,
tokenOriginal: DEFAULT_NATIVE_TOKEN_CONTRACT,
chainIdOriginal: CHAIN_IDS.bitlayer,
},
},
}
Loading

0 comments on commit 6b97b2a

Please sign in to comment.