@xyo-network/chain-sdk 1.3.16 → 1.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../src/index-shared.ts","../../src/test/evm/runGanache.ts","../../src/test/evm/stakingContractUtils.ts"],"sourcesContent":["export * from './index-shared.ts'\nexport * from './test/index.ts'\n","export * from '@xyo-network/chain-ethereum'\nexport * from '@xyo-network/chain-modules'\nexport * from '@xyo-network/chain-orchestration'\nexport * from '@xyo-network/chain-protocol'\nexport * from '@xyo-network/chain-services'\nexport * from '@xyo-network/chain-utils'\nexport * from '@xyo-network/chain-validation'\nexport * from '@xyo-network/xl1-protocol'\n","import type { ChildProcess } from 'node:child_process'\nimport { spawn } from 'node:child_process'\n\nimport { delay } from '@xylabs/delay'\nimport { JsonRpcProvider } from 'ethers/providers'\n\nasync function isGanacheRunning(url: string) {\n try {\n const provider = new JsonRpcProvider(url)\n await provider.getBlockNumber() // Try to fetch the latest block number\n return true // If this succeeds, the server is running\n } catch {\n return false // If this fails, the server is not running\n }\n}\n\nexport async function startGanache(port: number, mnemonic: string) {\n console.log('Starting Ganache CLI...')\n\n // Start Ganache CLI\n const ganacheProcess = spawn(\n 'yarn',\n ['ganache', '--port', `${port}`, '--chain.chainId', '1337', '--mnemonic', mnemonic],\n { stdio: 'inherit' },\n )\n\n // Wait for Ganache to be ready\n while (!await isGanacheRunning(`http://127.0.0.1:${port}`)) {\n await delay(500)\n }\n\n return ganacheProcess\n}\n\nexport function stopGanache(process: ChildProcess) {\n console.log('Stopping Ganache CLI...')\n\n if (process) {\n process.kill('SIGTERM')\n console.log('Ganache CLI stopped.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Address } from '@xylabs/hex'\nimport { asAddress } from '@xylabs/hex'\nimport { Account } from '@xyo-network/account'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { createChain } from '@xyo-network/chain-ethereum'\nimport { buildBlock } from '@xyo-network/chain-protocol'\nimport { XYO_ZERO_ADDRESS } from '@xyo-network/chain-utils'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { BurnableErc20__factory as Erc20Factory } from '@xyo-network/typechain'\nimport type { WalletInstance } from '@xyo-network/wallet-model'\nimport type { ChainStakeIntent, HydratedBlock } from '@xyo-network/xl1-protocol'\nimport { ChainStakeIntentSchema } from '@xyo-network/xl1-protocol'\nimport { buildTransaction } from '@xyo-network/xl1-protocol-sdk'\nimport { getAddress } from 'ethers/address'\nimport { JsonRpcProvider } from 'ethers/providers'\nimport { parseUnits } from 'ethers/utils'\nimport { Wallet } from 'ethers/wallet'\n\nconst gasConfig = () => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport const createTestErc20 = async (ganachePort: number, testPhrase: string, contractCreator: WalletInstance): Promise<Address> => {\n const provider = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWallet = new Wallet(contractCreator.privateKey, provider)\n const erc20 = new Erc20Factory(ethWallet)\n const totalSupply = parseUnits('1000000', 18)\n const erc20Contract = await (await erc20.deploy('Test Token', 'TST', totalSupply, gasConfig())).waitForDeployment()\n const erc20Address = await erc20Contract.getAddress()\n const erc20ContractPerson0 = Erc20Factory.connect(erc20Address, ethWallet)\n const balance = await erc20ContractPerson0.balanceOf(ethWallet.address)\n assertEx(balance === totalSupply, () => 'Balance does not match total supply')\n return assertEx(asAddress(erc20Address), () => 'Invalid ERC20 contract address')\n}\n\nexport const transferTestTokens = async (ganachePort: number, erc20Address: Address, account0: WalletInstance, account1: WalletInstance) => {\n const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)\n const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson1 = new Wallet(account1.privateKey, provider1)\n const erc20ContractPerson0 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson0)\n const transferAmount = parseUnits('1000', 18)\n await (await erc20ContractPerson0.transfer(ethWalletPerson1.address, transferAmount, gasConfig())).wait()\n const erc20ContractPerson1 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson1)\n const balance = await erc20ContractPerson1.balanceOf(ethWalletPerson1.address)\n assertEx(balance === transferAmount, () => 'Balance does not match transfer amount')\n}\n\nexport const createTestChainContract = async (\n ganachePort: number,\n erc20Address: Address,\n account0: WalletInstance,\n initialProducer: AccountInstance,\n): Promise<Address> => {\n const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)\n const [xyoChainContractAddress] = await createChain(\n ethWalletPerson0,\n erc20Address,\n initialProducer,\n XYO_ZERO_ADDRESS,\n 0n,\n XYO_ZERO_ADDRESS,\n 50_000n,\n gasConfig(),\n )\n return assertEx(asAddress(xyoChainContractAddress), () => 'Invalid staking contract address')\n}\n\nexport const approveTestStakeChainAddress = async (ganachePort: number, erc20Address: Address, xyoChainContractAddress: Address, account1: WalletInstance) => {\n const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson1 = new Wallet(account1.privateKey, provider1)\n const erc20ContractPerson1 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson1)\n\n const _approveResultTx = await (await erc20ContractPerson1.approve(getAddress(xyoChainContractAddress), parseUnits('100', 18), gasConfig())).wait()\n}\n\nexport const createTestGenesisBlock = async (\n blockProducerAccounts: WalletInstance[],\n): Promise<HydratedBlock> => {\n const randomChainId = (await Account.random()).address\n // Create staked intents for all the block producers declaring their intent to produce blocks\n const signedStakedBlockProducerIntents = await Promise.all(blockProducerAccounts.map(async (blockProducerAccount) => {\n const stakeIntent = new PayloadBuilder<ChainStakeIntent>({ schema: ChainStakeIntentSchema }).fields({\n from: blockProducerAccount.address,\n exp: Number.MAX_SAFE_INTEGER,\n nbf: 0,\n intent: 'producer',\n })\n .build()\n\n const signedStakedBlockProducerIntent = await buildTransaction(\n randomChainId,\n [stakeIntent],\n [],\n blockProducerAccount,\n 0,\n 1000,\n )\n return signedStakedBlockProducerIntent\n }))\n const intents = signedStakedBlockProducerIntents.map(intent => intent[0])\n const payloads = signedStakedBlockProducerIntents.flatMap(intent => intent[1]) as WithStorageMeta<ChainStakeIntent>[]\n return await buildBlock(randomChainId, signedStakedBlockProducerIntents, [...intents, ...payloads], blockProducerAccounts)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;ACAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,qCAAc;AACd,oCAAc;AACd,0CAAc;AACd,qCAAc;AACd,qCAAc;AACd,kCAAc;AACd,uCAAc;AACd,mCAAc;;;ADPd,0BAAc;;;AECd,SAASA,aAAa;AAEtB,SAASC,aAAa;AACtB,SAASC,uBAAuB;AAEhC,eAAeC,iBAAiBC,KAAW;AACzC,MAAI;AACF,UAAMC,WAAW,IAAIC,gBAAgBF,GAAAA;AACrC,UAAMC,SAASE,eAAc;AAC7B,WAAO;EACT,QAAQ;AACN,WAAO;EACT;AACF;AAReJ;AAUf,eAAsBK,aAAaC,MAAcC,UAAgB;AAC/DC,UAAQC,IAAI,yBAAA;AAGZ,QAAMC,iBAAiBC,MACrB,QACA;IAAC;IAAW;IAAU,GAAGL,IAAAA;IAAQ;IAAmB;IAAQ;IAAcC;KAC1E;IAAEK,OAAO;EAAU,CAAA;AAIrB,SAAO,CAAC,MAAMZ,iBAAiB,oBAAoBM,IAAAA,EAAM,GAAG;AAC1D,UAAMO,MAAM,GAAA;EACd;AAEA,SAAOH;AACT;AAhBsBL;AAkBf,SAASS,YAAYC,SAAqB;AAC/CP,UAAQC,IAAI,yBAAA;AAEZ,MAAIM,SAAS;AACXA,YAAQC,KAAK,SAAA;AACbR,YAAQC,IAAI,sBAAA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,uBAAAA,GAA0BtC,WAAW,OAAO,EAAA,GAAKH,UAAAA,CAAAA,GAAcqC,KAAI;AACnJ,GAN4C;AAQrC,IAAMU,yBAAyB,8BACpCC,0BAAAA;AAEA,QAAMC,iBAAiB,MAAMC,QAAQC,OAAM,GAAI1B;AAE/C,QAAM2B,mCAAmC,MAAMC,QAAQC,IAAIN,sBAAsBO,IAAI,OAAOC,yBAAAA;AAC1F,UAAMC,cAAc,IAAIC,eAAiC;MAAEC,QAAQC;IAAuB,CAAA,EAAGC,OAAO;MAClGC,MAAMN,qBAAqB/B;MAC3BsC,KAAKC,OAAOC;MACZC,KAAK;MACLC,QAAQ;IACV,CAAA,EACGC,MAAK;AAER,UAAMC,kCAAkC,MAAMC,iBAC5CrB,eACA;MAACQ;OACD,CAAA,GACAD,sBACA,GACA,GAAA;AAEF,WAAOa;EACT,CAAA,CAAA;AACA,QAAME,UAAUnB,iCAAiCG,IAAIY,CAAAA,WAAUA,OAAO,CAAA,CAAE;AACxE,QAAMK,WAAWpB,iCAAiCqB,QAAQN,CAAAA,WAAUA,OAAO,CAAA,CAAE;AAC7E,SAAO,MAAMO,WAAWzB,eAAeG,kCAAkC;OAAImB;OAAYC;KAAWxB,qBAAAA;AACtG,GA3BsC;","names":["spawn","delay","JsonRpcProvider","isGanacheRunning","url","provider","JsonRpcProvider","getBlockNumber","startGanache","port","mnemonic","console","log","ganacheProcess","spawn","stdio","delay","stopGanache","process","kill","assertEx","asAddress","Account","createChain","buildBlock","XYO_ZERO_ADDRESS","PayloadBuilder","BurnableErc20__factory","Erc20Factory","ChainStakeIntentSchema","buildTransaction","getAddress","JsonRpcProvider","parseUnits","Wallet","gasConfig","gasLimit","gasPrice","parseUnits","createTestErc20","ganachePort","testPhrase","contractCreator","provider","JsonRpcProvider","ethWallet","Wallet","privateKey","erc20","Erc20Factory","totalSupply","erc20Contract","deploy","waitForDeployment","erc20Address","getAddress","erc20ContractPerson0","connect","balance","balanceOf","address","assertEx","asAddress","transferTestTokens","account0","account1","provider0","ethWalletPerson0","provider1","ethWalletPerson1","transferAmount","transfer","wait","erc20ContractPerson1","createTestChainContract","initialProducer","xyoChainContractAddress","createChain","XYO_ZERO_ADDRESS","approveTestStakeChainAddress","_approveResultTx","approve","createTestGenesisBlock","blockProducerAccounts","randomChainId","Account","random","signedStakedBlockProducerIntents","Promise","all","map","blockProducerAccount","stakeIntent","PayloadBuilder","schema","ChainStakeIntentSchema","fields","from","exp","Number","MAX_SAFE_INTEGER","nbf","intent","build","signedStakedBlockProducerIntent","buildTransaction","intents","payloads","flatMap","buildBlock"]}
1
+ {"version":3,"sources":["../../src/index.ts","../../src/index-shared.ts","../../src/test/evm/runGanache.ts","../../src/test/evm/stakingContractUtils.ts"],"sourcesContent":["export * from './index-shared.ts'\nexport * from './test/index.ts'\n","export * from '@xyo-network/chain-ethereum'\nexport * from '@xyo-network/chain-modules'\nexport * from '@xyo-network/chain-orchestration'\nexport * from '@xyo-network/chain-protocol'\nexport * from '@xyo-network/chain-services'\nexport * from '@xyo-network/chain-utils'\nexport * from '@xyo-network/chain-validation'\nexport * from '@xyo-network/xl1-protocol'\n","import type { ChildProcess } from 'node:child_process'\nimport { spawn } from 'node:child_process'\n\nimport { delay } from '@xylabs/delay'\nimport { JsonRpcProvider } from 'ethers/providers'\n\nasync function isGanacheRunning(url: string) {\n try {\n const provider = new JsonRpcProvider(url)\n await provider.getBlockNumber() // Try to fetch the latest block number\n return true // If this succeeds, the server is running\n } catch {\n return false // If this fails, the server is not running\n }\n}\n\nexport async function startGanache(port: number, mnemonic: string) {\n console.log('Starting Ganache CLI...')\n\n // Start Ganache CLI\n const ganacheProcess = spawn(\n 'yarn',\n ['ganache', '--port', `${port}`, '--chain.chainId', '1337', '--mnemonic', mnemonic],\n { stdio: 'inherit' },\n )\n\n // Wait for Ganache to be ready\n while (!await isGanacheRunning(`http://127.0.0.1:${port}`)) {\n await delay(500)\n }\n\n return ganacheProcess\n}\n\nexport function stopGanache(process?: ChildProcess | undefined) {\n console.log('Stopping Ganache CLI...')\n if (process) {\n process.kill('SIGTERM')\n console.log('Ganache CLI stopped.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Address } from '@xylabs/hex'\nimport { asAddress } from '@xylabs/hex'\nimport { Account } from '@xyo-network/account'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { createChain } from '@xyo-network/chain-ethereum'\nimport { buildBlock } from '@xyo-network/chain-protocol'\nimport { XYO_ZERO_ADDRESS } from '@xyo-network/chain-utils'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { BurnableErc20__factory as Erc20Factory } from '@xyo-network/typechain'\nimport type { WalletInstance } from '@xyo-network/wallet-model'\nimport type { ChainStakeIntent, HydratedBlock } from '@xyo-network/xl1-protocol'\nimport { ChainStakeIntentSchema } from '@xyo-network/xl1-protocol'\nimport { buildTransaction } from '@xyo-network/xl1-protocol-sdk'\nimport { getAddress } from 'ethers/address'\nimport { JsonRpcProvider } from 'ethers/providers'\nimport { parseUnits } from 'ethers/utils'\nimport { Wallet } from 'ethers/wallet'\n\nconst gasConfig = () => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport const createTestErc20 = async (ganachePort: number, testPhrase: string, contractCreator: WalletInstance): Promise<Address> => {\n const provider = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWallet = new Wallet(contractCreator.privateKey, provider)\n const erc20 = new Erc20Factory(ethWallet)\n const totalSupply = parseUnits('1000000', 18)\n const erc20Contract = await (await erc20.deploy('Test Token', 'TST', totalSupply, gasConfig())).waitForDeployment()\n const erc20Address = await erc20Contract.getAddress()\n const erc20ContractPerson0 = Erc20Factory.connect(erc20Address, ethWallet)\n const balance = await erc20ContractPerson0.balanceOf(ethWallet.address)\n assertEx(balance === totalSupply, () => 'Balance does not match total supply')\n return assertEx(asAddress(erc20Address), () => 'Invalid ERC20 contract address')\n}\n\nexport const transferTestTokens = async (ganachePort: number, erc20Address: Address, account0: WalletInstance, account1: WalletInstance) => {\n const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)\n const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson1 = new Wallet(account1.privateKey, provider1)\n const erc20ContractPerson0 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson0)\n const transferAmount = parseUnits('1000', 18)\n await (await erc20ContractPerson0.transfer(ethWalletPerson1.address, transferAmount, gasConfig())).wait()\n const erc20ContractPerson1 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson1)\n const balance = await erc20ContractPerson1.balanceOf(ethWalletPerson1.address)\n assertEx(balance === transferAmount, () => 'Balance does not match transfer amount')\n}\n\nexport const createTestChainContract = async (\n ganachePort: number,\n erc20Address: Address,\n account0: WalletInstance,\n initialProducer: AccountInstance,\n): Promise<Address> => {\n const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)\n const [xyoChainContractAddress] = await createChain(\n ethWalletPerson0,\n erc20Address,\n initialProducer,\n XYO_ZERO_ADDRESS,\n 0n,\n XYO_ZERO_ADDRESS,\n 50_000n,\n gasConfig(),\n )\n return assertEx(asAddress(xyoChainContractAddress), () => 'Invalid staking contract address')\n}\n\nexport const approveTestStakeChainAddress = async (ganachePort: number, erc20Address: Address, xyoChainContractAddress: Address, account1: WalletInstance) => {\n const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson1 = new Wallet(account1.privateKey, provider1)\n const erc20ContractPerson1 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson1)\n\n const _approveResultTx = await (await erc20ContractPerson1.approve(getAddress(xyoChainContractAddress), parseUnits('100', 18), gasConfig())).wait()\n}\n\nexport const createTestGenesisBlock = async (\n blockProducerAccounts: WalletInstance[],\n): Promise<HydratedBlock> => {\n const randomChainId = (await Account.random()).address\n // Create staked intents for all the block producers declaring their intent to produce blocks\n const signedStakedBlockProducerIntents = await Promise.all(blockProducerAccounts.map(async (blockProducerAccount) => {\n const stakeIntent = new PayloadBuilder<ChainStakeIntent>({ schema: ChainStakeIntentSchema }).fields({\n from: blockProducerAccount.address,\n exp: Number.MAX_SAFE_INTEGER,\n nbf: 0,\n intent: 'producer',\n })\n .build()\n\n const signedStakedBlockProducerIntent = await buildTransaction(\n randomChainId,\n [stakeIntent],\n [],\n blockProducerAccount,\n 0,\n 1000,\n )\n return signedStakedBlockProducerIntent\n }))\n const intents = signedStakedBlockProducerIntents.map(intent => intent[0])\n const payloads = signedStakedBlockProducerIntents.flatMap(intent => intent[1]) as WithStorageMeta<ChainStakeIntent>[]\n return await buildBlock(randomChainId, signedStakedBlockProducerIntents, [...intents, ...payloads], blockProducerAccounts)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;ACAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,qCAAc;AACd,oCAAc;AACd,0CAAc;AACd,qCAAc;AACd,qCAAc;AACd,kCAAc;AACd,uCAAc;AACd,mCAAc;;;ADPd,0BAAc;;;AECd,SAASA,aAAa;AAEtB,SAASC,aAAa;AACtB,SAASC,uBAAuB;AAEhC,eAAeC,iBAAiBC,KAAW;AACzC,MAAI;AACF,UAAMC,WAAW,IAAIC,gBAAgBF,GAAAA;AACrC,UAAMC,SAASE,eAAc;AAC7B,WAAO;EACT,QAAQ;AACN,WAAO;EACT;AACF;AAReJ;AAUf,eAAsBK,aAAaC,MAAcC,UAAgB;AAC/DC,UAAQC,IAAI,yBAAA;AAGZ,QAAMC,iBAAiBC,MACrB,QACA;IAAC;IAAW;IAAU,GAAGL,IAAAA;IAAQ;IAAmB;IAAQ;IAAcC;KAC1E;IAAEK,OAAO;EAAU,CAAA;AAIrB,SAAO,C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,iBAAgB,oBAAoBJ,WAAAA,IAAe,IAAA;AACzE,QAAM6B,mBAAmB,IAAIvB,OAAOmB,SAASlB,YAAYqB,SAAAA;AACzD,QAAMK,uBAAuBxB,aAAaQ,QAAQF,WAAWD,YAAAA,GAAee,gBAAAA;AAE5E,QAAMW,mBAAmB,OAAO,MAAMP,qBAAqBQ,QAAQ1B,WAAWqB,uBAAAA,GAA0BtC,WAAW,OAAO,EAAA,GAAKH,UAAAA,CAAAA,GAAcqC,KAAI;AACnJ,GAN4C;AAQrC,IAAMU,yBAAyB,8BACpCC,0BAAAA;AAEA,QAAMC,iBAAiB,MAAMC,QAAQC,OAAM,GAAI1B;AAE/C,QAAM2B,mCAAmC,MAAMC,QAAQC,IAAIN,sBAAsBO,IAAI,OAAOC,yBAAAA;AAC1F,UAAMC,cAAc,IAAIC,eAAiC;MAAEC,QAAQC;IAAuB,CAAA,EAAGC,OAAO;MAClGC,MAAMN,qBAAqB/B;MAC3BsC,KAAKC,OAAOC;MACZC,KAAK;MACLC,QAAQ;IACV,CAAA,EACGC,MAAK;AAER,UAAMC,kCAAkC,MAAMC,iBAC5CrB,eACA;MAACQ;OACD,CAAA,GACAD,sBACA,GACA,GAAA;AAEF,WAAOa;EACT,CAAA,CAAA;AACA,QAAME,UAAUnB,iCAAiCG,IAAIY,CAAAA,WAAUA,OAAO,CAAA,CAAE;AACxE,QAAMK,WAAWpB,iCAAiCqB,QAAQN,CAAAA,WAAUA,OAAO,CAAA,CAAE;AAC7E,SAAO,MAAMO,WAAWzB,eAAeG,kCAAkC;OAAImB;OAAYC;KAAWxB,qBAAAA;AACtG,GA3BsC;","names":["spawn","delay","JsonRpcProvider","isGanacheRunning","url","provider","JsonRpcProvider","getBlockNumber","startGanache","port","mnemonic","console","log","ganacheProcess","spawn","stdio","delay","stopGanache","process","kill","assertEx","asAddress","Account","createChain","buildBlock","XYO_ZERO_ADDRESS","PayloadBuilder","BurnableErc20__factory","Erc20Factory","ChainStakeIntentSchema","buildTransaction","getAddress","JsonRpcProvider","parseUnits","Wallet","gasConfig","gasLimit","gasPrice","parseUnits","createTestErc20","ganachePort","testPhrase","contractCreator","provider","JsonRpcProvider","ethWallet","Wallet","privateKey","erc20","Erc20Factory","totalSupply","erc20Contract","deploy","waitForDeployment","erc20Address","getAddress","erc20ContractPerson0","connect","balance","balanceOf","address","assertEx","asAddress","transferTestTokens","account0","account1","provider0","ethWalletPerson0","provider1","ethWalletPerson1","transferAmount","transfer","wait","erc20ContractPerson1","createTestChainContract","initialProducer","xyoChainContractAddress","createChain","XYO_ZERO_ADDRESS","approveTestStakeChainAddress","_approveResultTx","approve","createTestGenesisBlock","blockProducerAccounts","randomChainId","Account","random","signedStakedBlockProducerIntents","Promise","all","map","blockProducerAccount","stakeIntent","PayloadBuilder","schema","ChainStakeIntentSchema","fields","from","exp","Number","MAX_SAFE_INTEGER","nbf","intent","build","signedStakedBlockProducerIntent","buildTransaction","intents","payloads","flatMap","buildBlock"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index-node.ts","../../src/index.ts","../../src/index-shared.ts","../../src/test/evm/runGanache.ts","../../src/test/evm/stakingContractUtils.ts"],"sourcesContent":["// eslint-disable-next-line no-restricted-imports\nexport * from './index.ts'\n","export * from './index-shared.ts'\nexport * from './test/index.ts'\n","export * from '@xyo-network/chain-ethereum'\nexport * from '@xyo-network/chain-modules'\nexport * from '@xyo-network/chain-orchestration'\nexport * from '@xyo-network/chain-protocol'\nexport * from '@xyo-network/chain-services'\nexport * from '@xyo-network/chain-utils'\nexport * from '@xyo-network/chain-validation'\nexport * from '@xyo-network/xl1-protocol'\n","import type { ChildProcess } from 'node:child_process'\nimport { spawn } from 'node:child_process'\n\nimport { delay } from '@xylabs/delay'\nimport { JsonRpcProvider } from 'ethers/providers'\n\nasync function isGanacheRunning(url: string) {\n try {\n const provider = new JsonRpcProvider(url)\n await provider.getBlockNumber() // Try to fetch the latest block number\n return true // If this succeeds, the server is running\n } catch {\n return false // If this fails, the server is not running\n }\n}\n\nexport async function startGanache(port: number, mnemonic: string) {\n console.log('Starting Ganache CLI...')\n\n // Start Ganache CLI\n const ganacheProcess = spawn(\n 'yarn',\n ['ganache', '--port', `${port}`, '--chain.chainId', '1337', '--mnemonic', mnemonic],\n { stdio: 'inherit' },\n )\n\n // Wait for Ganache to be ready\n while (!await isGanacheRunning(`http://127.0.0.1:${port}`)) {\n await delay(500)\n }\n\n return ganacheProcess\n}\n\nexport function stopGanache(process: ChildProcess) {\n console.log('Stopping Ganache CLI...')\n\n if (process) {\n process.kill('SIGTERM')\n console.log('Ganache CLI stopped.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Address } from '@xylabs/hex'\nimport { asAddress } from '@xylabs/hex'\nimport { Account } from '@xyo-network/account'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { createChain } from '@xyo-network/chain-ethereum'\nimport { buildBlock } from '@xyo-network/chain-protocol'\nimport { XYO_ZERO_ADDRESS } from '@xyo-network/chain-utils'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { BurnableErc20__factory as Erc20Factory } from '@xyo-network/typechain'\nimport type { WalletInstance } from '@xyo-network/wallet-model'\nimport type { ChainStakeIntent, HydratedBlock } from '@xyo-network/xl1-protocol'\nimport { ChainStakeIntentSchema } from '@xyo-network/xl1-protocol'\nimport { buildTransaction } from '@xyo-network/xl1-protocol-sdk'\nimport { getAddress } from 'ethers/address'\nimport { JsonRpcProvider } from 'ethers/providers'\nimport { parseUnits } from 'ethers/utils'\nimport { Wallet } from 'ethers/wallet'\n\nconst gasConfig = () => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport const createTestErc20 = async (ganachePort: number, testPhrase: string, contractCreator: WalletInstance): Promise<Address> => {\n const provider = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWallet = new Wallet(contractCreator.privateKey, provider)\n const erc20 = new Erc20Factory(ethWallet)\n const totalSupply = parseUnits('1000000', 18)\n const erc20Contract = await (await erc20.deploy('Test Token', 'TST', totalSupply, gasConfig())).waitForDeployment()\n const erc20Address = await erc20Contract.getAddress()\n const erc20ContractPerson0 = Erc20Factory.connect(erc20Address, ethWallet)\n const balance = await erc20ContractPerson0.balanceOf(ethWallet.address)\n assertEx(balance === totalSupply, () => 'Balance does not match total supply')\n return assertEx(asAddress(erc20Address), () => 'Invalid ERC20 contract address')\n}\n\nexport const transferTestTokens = async (ganachePort: number, erc20Address: Address, account0: WalletInstance, account1: WalletInstance) => {\n const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)\n const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson1 = new Wallet(account1.privateKey, provider1)\n const erc20ContractPerson0 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson0)\n const transferAmount = parseUnits('1000', 18)\n await (await erc20ContractPerson0.transfer(ethWalletPerson1.address, transferAmount, gasConfig())).wait()\n const erc20ContractPerson1 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson1)\n const balance = await erc20ContractPerson1.balanceOf(ethWalletPerson1.address)\n assertEx(balance === transferAmount, () => 'Balance does not match transfer amount')\n}\n\nexport const createTestChainContract = async (\n ganachePort: number,\n erc20Address: Address,\n account0: WalletInstance,\n initialProducer: AccountInstance,\n): Promise<Address> => {\n const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)\n const [xyoChainContractAddress] = await createChain(\n ethWalletPerson0,\n erc20Address,\n initialProducer,\n XYO_ZERO_ADDRESS,\n 0n,\n XYO_ZERO_ADDRESS,\n 50_000n,\n gasConfig(),\n )\n return assertEx(asAddress(xyoChainContractAddress), () => 'Invalid staking contract address')\n}\n\nexport const approveTestStakeChainAddress = async (ganachePort: number, erc20Address: Address, xyoChainContractAddress: Address, account1: WalletInstance) => {\n const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson1 = new Wallet(account1.privateKey, provider1)\n const erc20ContractPerson1 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson1)\n\n const _approveResultTx = await (await erc20ContractPerson1.approve(getAddress(xyoChainContractAddress), parseUnits('100', 18), gasConfig())).wait()\n}\n\nexport const createTestGenesisBlock = async (\n blockProducerAccounts: WalletInstance[],\n): Promise<HydratedBlock> => {\n const randomChainId = (await Account.random()).address\n // Create staked intents for all the block producers declaring their intent to produce blocks\n const signedStakedBlockProducerIntents = await Promise.all(blockProducerAccounts.map(async (blockProducerAccount) => {\n const stakeIntent = new PayloadBuilder<ChainStakeIntent>({ schema: ChainStakeIntentSchema }).fields({\n from: blockProducerAccount.address,\n exp: Number.MAX_SAFE_INTEGER,\n nbf: 0,\n intent: 'producer',\n })\n .build()\n\n const signedStakedBlockProducerIntent = await buildTransaction(\n randomChainId,\n [stakeIntent],\n [],\n blockProducerAccount,\n 0,\n 1000,\n )\n return signedStakedBlockProducerIntent\n }))\n const intents = signedStakedBlockProducerIntents.map(intent => intent[0])\n const payloads = signedStakedBlockProducerIntents.flatMap(intent => intent[1]) as WithStorageMeta<ChainStakeIntent>[]\n return await buildBlock(randomChainId, signedStakedBlockProducerIntents, [...intents, ...payloads], blockProducerAccounts)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;ACAA;;;;;;;;;;;;ACAA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPA,qCAAc;AACd,oCAAc;AACd,0CAAc;AACd,qCAAc;AACd,qCAAc;AACd,kCAAc;AACd,uCAAc;AACd,mCAAc;;;ADPd,0BAAc;;;AECd,SAASA,aAAa;AAEtB,SAASC,aAAa;AACtB,SAASC,uBAAuB;AAEhC,eAAeC,iBAAiBC,KAAW;AACzC,MAAI;AACF,UAAMC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CAAE;AAC7E,SAAO,MAAMO,WAAWzB,eAAeG,kCAAkC;OAAImB;OAAYC;KAAWxB,qBAAAA;AACtG,GA3BsC;;;AJjFtC,+BAAc;","names":["spawn","delay","JsonRpcProvider","isGanacheRunning","url","provider","JsonRpcProvider","getBlockNumber","startGanache","port","mnemonic","console","log","ganacheProcess","spawn","stdio","delay","stopGanache","process","kill","assertEx","asAddress","Account","createChain","buildBlock","XYO_ZERO_ADDRESS","PayloadBuilder","BurnableErc20__factory","Erc20Factory","ChainStakeIntentSchema","buildTransaction","getAddress","JsonRpcProvider","parseUnits","Wallet","gasConfig","gasLimit","gasPrice","parseUnits","createTestErc20","ganachePort","testPhrase","contractCreator","provider","JsonRpcProvider","ethWallet","Wallet","privateKey","erc20","Erc20Factory","totalSupply","erc20Contract","deploy","waitForDeployment","erc20Address","getAddress","erc20ContractPerson0","connect","balance","balanceOf","address","assertEx","asAddress","transferTestTokens","account0","account1","provider0","ethWalletPerson0","provider1","ethWalletPerson1","transferAmount","transfer","wait","erc20ContractPerson1","createTestChainContract","initialProducer","xyoChainContractAddress","createChain","XYO_ZERO_ADDRESS","approveTestStakeChainAddress","_approveResultTx","approve","createTestGenesisBlock","blockProducerAccounts","randomChainId","Account","random","signedStakedBlockProducerIntents","Promise","all","map","blockProducerAccount","stakeIntent","PayloadBuilder","schema","ChainStakeIntentSchema","fields","from","exp","Number","MAX_SAFE_INTEGER","nbf","intent","build","signedStakedBlockProducerIntent","buildTransaction","intents","payloads","flatMap","buildBlock"]}
1
+ {"version":3,"sources":["../../src/index-node.ts","../../src/index.ts","../../src/index-shared.ts","../../src/test/evm/runGanache.ts","../../src/test/evm/stakingContractUtils.ts"],"sourcesContent":["// eslint-disable-next-line no-restricted-imports\nexport * from './index.ts'\n","export * from './index-shared.ts'\nexport * from './test/index.ts'\n","export * from '@xyo-network/chain-ethereum'\nexport * from '@xyo-network/chain-modules'\nexport * from '@xyo-network/chain-orchestration'\nexport * from '@xyo-network/chain-protocol'\nexport * from '@xyo-network/chain-services'\nexport * from '@xyo-network/chain-utils'\nexport * from '@xyo-network/chain-validation'\nexport * from '@xyo-network/xl1-protocol'\n","import type { ChildProcess } from 'node:child_process'\nimport { spawn } from 'node:child_process'\n\nimport { delay } from '@xylabs/delay'\nimport { JsonRpcProvider } from 'ethers/providers'\n\nasync function isGanacheRunning(url: string) {\n try {\n const provider = new JsonRpcProvider(url)\n await provider.getBlockNumber() // Try to fetch the latest block number\n return true // If this succeeds, the server is running\n } catch {\n return false // If this fails, the server is not running\n }\n}\n\nexport async function startGanache(port: number, mnemonic: string) {\n console.log('Starting Ganache CLI...')\n\n // Start Ganache CLI\n const ganacheProcess = spawn(\n 'yarn',\n ['ganache', '--port', `${port}`, '--chain.chainId', '1337', '--mnemonic', mnemonic],\n { stdio: 'inherit' },\n )\n\n // Wait for Ganache to be ready\n while (!await isGanacheRunning(`http://127.0.0.1:${port}`)) {\n await delay(500)\n }\n\n return ganacheProcess\n}\n\nexport function stopGanache(process?: ChildProcess | undefined) {\n console.log('Stopping Ganache CLI...')\n if (process) {\n process.kill('SIGTERM')\n console.log('Ganache CLI stopped.')\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Address } from '@xylabs/hex'\nimport { asAddress } from '@xylabs/hex'\nimport { Account } from '@xyo-network/account'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { createChain } from '@xyo-network/chain-ethereum'\nimport { buildBlock } from '@xyo-network/chain-protocol'\nimport { XYO_ZERO_ADDRESS } from '@xyo-network/chain-utils'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { BurnableErc20__factory as Erc20Factory } from '@xyo-network/typechain'\nimport type { WalletInstance } from '@xyo-network/wallet-model'\nimport type { ChainStakeIntent, HydratedBlock } from '@xyo-network/xl1-protocol'\nimport { ChainStakeIntentSchema } from '@xyo-network/xl1-protocol'\nimport { buildTransaction } from '@xyo-network/xl1-protocol-sdk'\nimport { getAddress } from 'ethers/address'\nimport { JsonRpcProvider } from 'ethers/providers'\nimport { parseUnits } from 'ethers/utils'\nimport { Wallet } from 'ethers/wallet'\n\nconst gasConfig = () => {\n return {\n gasLimit: 2_000_000, // Set the gas limit\n gasPrice: parseUnits('100', 'gwei'),\n }\n}\n\nexport const createTestErc20 = async (ganachePort: number, testPhrase: string, contractCreator: WalletInstance): Promise<Address> => {\n const provider = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWallet = new Wallet(contractCreator.privateKey, provider)\n const erc20 = new Erc20Factory(ethWallet)\n const totalSupply = parseUnits('1000000', 18)\n const erc20Contract = await (await erc20.deploy('Test Token', 'TST', totalSupply, gasConfig())).waitForDeployment()\n const erc20Address = await erc20Contract.getAddress()\n const erc20ContractPerson0 = Erc20Factory.connect(erc20Address, ethWallet)\n const balance = await erc20ContractPerson0.balanceOf(ethWallet.address)\n assertEx(balance === totalSupply, () => 'Balance does not match total supply')\n return assertEx(asAddress(erc20Address), () => 'Invalid ERC20 contract address')\n}\n\nexport const transferTestTokens = async (ganachePort: number, erc20Address: Address, account0: WalletInstance, account1: WalletInstance) => {\n const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)\n const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson1 = new Wallet(account1.privateKey, provider1)\n const erc20ContractPerson0 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson0)\n const transferAmount = parseUnits('1000', 18)\n await (await erc20ContractPerson0.transfer(ethWalletPerson1.address, transferAmount, gasConfig())).wait()\n const erc20ContractPerson1 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson1)\n const balance = await erc20ContractPerson1.balanceOf(ethWalletPerson1.address)\n assertEx(balance === transferAmount, () => 'Balance does not match transfer amount')\n}\n\nexport const createTestChainContract = async (\n ganachePort: number,\n erc20Address: Address,\n account0: WalletInstance,\n initialProducer: AccountInstance,\n): Promise<Address> => {\n const provider0 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson0 = new Wallet(account0.privateKey, provider0)\n const [xyoChainContractAddress] = await createChain(\n ethWalletPerson0,\n erc20Address,\n initialProducer,\n XYO_ZERO_ADDRESS,\n 0n,\n XYO_ZERO_ADDRESS,\n 50_000n,\n gasConfig(),\n )\n return assertEx(asAddress(xyoChainContractAddress), () => 'Invalid staking contract address')\n}\n\nexport const approveTestStakeChainAddress = async (ganachePort: number, erc20Address: Address, xyoChainContractAddress: Address, account1: WalletInstance) => {\n const provider1 = new JsonRpcProvider(`http://127.0.0.1:${ganachePort}`, 1337)\n const ethWalletPerson1 = new Wallet(account1.privateKey, provider1)\n const erc20ContractPerson1 = Erc20Factory.connect(getAddress(erc20Address), ethWalletPerson1)\n\n const _approveResultTx = await (await erc20ContractPerson1.approve(getAddress(xyoChainContractAddress), parseUnits('100', 18), gasConfig())).wait()\n}\n\nexport const createTestGenesisBlock = async (\n blockProducerAccounts: WalletInstance[],\n): Promise<HydratedBlock> => {\n const randomChainId = (await Account.random()).address\n // Create staked intents for all the block producers declaring their intent to produce blocks\n const signedStakedBlockProducerIntents = await Promise.all(blockProducerAccounts.map(async (blockProducerAccount) => {\n const stakeIntent = new PayloadBuilder<ChainStakeIntent>({ schema: ChainStakeIntentSchema }).fields({\n from: blockProducerAccount.address,\n exp: Number.MAX_SAFE_INTEGER,\n nbf: 0,\n intent: 'producer',\n })\n .build()\n\n const signedStakedBlockProducerIntent = await buildTransaction(\n randomChainId,\n [stakeIntent],\n [],\n blockProducerAccount,\n 0,\n 1000,\n )\n return signedStakedBlockProducerIntent\n }))\n const intents = signedStakedBlockProducerIntents.map(intent => intent[0])\n const payloads = signedStakedBlockProducerIntents.flatMap(intent => intent[1]) as WithStorageMeta<ChainStakeIntent>[]\n return await buildBlock(randomChainId, signedStakedBlockProducerIntents, [...intents, ...payloads], blockProducerAccounts)\n}\n"],"mappings":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B/B;MAC3BsC,KAAKC,OAAOC;MACZC,KAAK;MACLC,QAAQ;IACV,CAAA,EACGC,MAAK;AAER,UAAMC,kCAAkC,MAAMC,iBAC5CrB,eACA;MAACQ;OACD,CAAA,GACAD,sBACA,GACA,GAAA;AAEF,WAAOa;EACT,CAAA,CAAA;AACA,QAAME,UAAUnB,iCAAiCG,IAAIY,CAAAA,WAAUA,OAAO,CAAA,CAAE;AACxE,QAAMK,WAAWpB,iCAAiCqB,QAAQN,CAAAA,WAAUA,OAAO,CAAA,CAAE;AAC7E,SAAO,MAAMO,WAAWzB,eAAeG,kCAAkC;OAAImB;OAAYC;KAAWxB,qBAAAA;AACtG,GA3BsC;;;AJjFtC,+BAAc;","names":["spawn","delay","JsonRpcProvider","isGanacheRunning","url","provider","JsonRpcProvider","getBlockNumber","startGanache","port","mnemonic","console","log","ganacheProcess","spawn","stdio","delay","stopGanache","process","kill","assertEx","asAddress","Account","createChain","buildBlock","XYO_ZERO_ADDRESS","PayloadBuilder","BurnableErc20__factory","Erc20Factory","ChainStakeIntentSchema","buildTransaction","getAddress","JsonRpcProvider","parseUnits","Wallet","gasConfig","gasLimit","gasPrice","parseUnits","createTestErc20","ganachePort","testPhrase","contractCreator","provider","JsonRpcProvider","ethWallet","Wallet","privateKey","erc20","Erc20Factory","totalSupply","erc20Contract","deploy","waitForDeployment","erc20Address","getAddress","erc20ContractPerson0","connect","balance","balanceOf","address","assertEx","asAddress","transferTestTokens","account0","account1","provider0","ethWalletPerson0","provider1","ethWalletPerson1","transferAmount","transfer","wait","erc20ContractPerson1","createTestChainContract","initialProducer","xyoChainContractAddress","createChain","XYO_ZERO_ADDRESS","approveTestStakeChainAddress","_approveResultTx","approve","createTestGenesisBlock","blockProducerAccounts","randomChainId","Account","random","signedStakedBlockProducerIntents","Promise","all","map","blockProducerAccount","stakeIntent","PayloadBuilder","schema","ChainStakeIntentSchema","fields","from","exp","Number","MAX_SAFE_INTEGER","nbf","intent","build","signedStakedBlockProducerIntent","buildTransaction","intents","payloads","flatMap","buildBlock"]}
@@ -1,4 +1,4 @@
1
1
  import type { ChildProcess } from 'node:child_process';
2
2
  export declare function startGanache(port: number, mnemonic: string): Promise<ChildProcess>;
3
- export declare function stopGanache(process: ChildProcess): void;
3
+ export declare function stopGanache(process?: ChildProcess | undefined): void;
4
4
  //# sourceMappingURL=runGanache.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runGanache.d.ts","sourceRoot":"","sources":["../../../../src/test/evm/runGanache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAgBtD,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,yBAgBhE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,QAOhD"}
1
+ {"version":3,"file":"runGanache.d.ts","sourceRoot":"","sources":["../../../../src/test/evm/runGanache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAgBtD,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,yBAgBhE;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,SAAS,QAM7D"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/package.json",
3
3
  "name": "@xyo-network/chain-sdk",
4
- "version": "1.3.16",
4
+ "version": "1.3.18",
5
5
  "description": "XYO Layer One SDK",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -49,40 +49,40 @@
49
49
  "deploy3": "echo Deploy3 not allowed!"
50
50
  },
51
51
  "dependencies": {
52
- "@xylabs/assert": "^4.9.2",
53
- "@xylabs/delay": "^4.9.2",
54
- "@xylabs/hex": "^4.9.2",
55
- "@xyo-network/account": "^3.14.16",
56
- "@xyo-network/account-model": "^3.14.16",
57
- "@xyo-network/chain-ethereum": "^1.3.16",
58
- "@xyo-network/chain-modules": "^1.3.16",
59
- "@xyo-network/chain-orchestration": "^1.3.16",
60
- "@xyo-network/chain-protocol": "^1.3.16",
61
- "@xyo-network/chain-services": "^1.3.16",
62
- "@xyo-network/chain-utils": "^1.3.16",
63
- "@xyo-network/chain-validation": "^1.3.16",
64
- "@xyo-network/payload-builder": "^3.14.16",
52
+ "@xylabs/assert": "^4.9.4",
53
+ "@xylabs/delay": "^4.9.4",
54
+ "@xylabs/hex": "^4.9.4",
55
+ "@xyo-network/account": "^3.14.18",
56
+ "@xyo-network/account-model": "^3.14.18",
57
+ "@xyo-network/chain-ethereum": "^1.3.18",
58
+ "@xyo-network/chain-modules": "^1.3.18",
59
+ "@xyo-network/chain-orchestration": "^1.3.18",
60
+ "@xyo-network/chain-protocol": "^1.3.18",
61
+ "@xyo-network/chain-services": "^1.3.18",
62
+ "@xyo-network/chain-utils": "^1.3.18",
63
+ "@xyo-network/chain-validation": "^1.3.18",
64
+ "@xyo-network/payload-builder": "^3.14.18",
65
65
  "@xyo-network/typechain": "^3.5.2",
66
- "@xyo-network/wallet": "^3.14.16",
67
- "@xyo-network/wallet-model": "^3.14.16",
66
+ "@xyo-network/wallet": "^3.14.18",
67
+ "@xyo-network/wallet-model": "^3.14.18",
68
68
  "@xyo-network/xl1-protocol": "^1.3.12",
69
- "@xyo-network/xl1-protocol-sdk": "^1.3.16",
70
- "ethers": "6.13.7"
69
+ "@xyo-network/xl1-protocol-sdk": "^1.3.18",
70
+ "ethers": "6.14.0"
71
71
  },
72
72
  "devDependencies": {
73
- "@types/node": "^22.15.12",
74
- "@xylabs/decimal-precision": "^4.9.2",
75
- "@xylabs/delay": "^4.9.2",
73
+ "@types/node": "^22.15.17",
74
+ "@xylabs/decimal-precision": "^4.9.4",
75
+ "@xylabs/delay": "^4.9.4",
76
76
  "@xylabs/ts-scripts-yarn3": "^6.5.5",
77
77
  "@xylabs/tsconfig": "^6.5.5",
78
- "@xyo-network/account": "^3.14.16",
79
- "@xyo-network/account-model": "^3.14.16",
80
- "@xyo-network/archivist-memory": "^3.14.16",
81
- "@xyo-network/boundwitness-builder": "^3.14.16",
82
- "@xyo-network/chain-analyze": "^1.3.16",
83
- "@xyo-network/payload-model": "^3.14.16",
78
+ "@xyo-network/account": "^3.14.18",
79
+ "@xyo-network/account-model": "^3.14.18",
80
+ "@xyo-network/archivist-memory": "^3.14.18",
81
+ "@xyo-network/boundwitness-builder": "^3.14.18",
82
+ "@xyo-network/chain-analyze": "^1.3.18",
83
+ "@xyo-network/payload-model": "^3.14.18",
84
84
  "eslint": "^9.26.0",
85
- "knip": "^5.54.1",
85
+ "knip": "^5.55.1",
86
86
  "typescript": "^5.8.3",
87
87
  "vitest": "^3.1.3"
88
88
  },
@@ -32,9 +32,8 @@ export async function startGanache(port: number, mnemonic: string) {
32
32
  return ganacheProcess
33
33
  }
34
34
 
35
- export function stopGanache(process: ChildProcess) {
35
+ export function stopGanache(process?: ChildProcess | undefined) {
36
36
  console.log('Stopping Ganache CLI...')
37
-
38
37
  if (process) {
39
38
  process.kill('SIGTERM')
40
39
  console.log('Ganache CLI stopped.')