diff --git a/globalSetup.ts b/globalSetup.ts index de29cbbe..8e2a1e3c 100644 --- a/globalSetup.ts +++ b/globalSetup.ts @@ -1,4 +1,4 @@ -import { env } from 'neutronjs'; +import { env } from '@neutron-org/neutronjs'; export default async () => { const host1 = process.env.NODE1_URL || 'http://localhost:1317'; diff --git a/package.json b/package.json index 4bbc4faa..429f92fc 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@cosmos-client/core": "0.45.13", "@cosmos-client/cosmwasm": "^0.20.1", "@cosmos-client/ibc": "^1.2.1", + "@neutron-org/neutronjs": "^0.0.4", "@types/lodash": "^4.14.182", "@types/long": "^4.0.2", "axios": "^0.27.2", @@ -51,7 +52,6 @@ "lodash": "^4.17.21", "long": "^5.2.1", "merkletreejs": "^0.3.9", - "neutronjs": "file:../neutronjs", "yesno": "^0.4.0" }, "devDependencies": { diff --git a/src/testcases/parallel/dao_assert.test.ts b/src/testcases/parallel/dao_assert.test.ts index 789ee411..0f909452 100644 --- a/src/testcases/parallel/dao_assert.test.ts +++ b/src/testcases/parallel/dao_assert.test.ts @@ -5,7 +5,7 @@ import { NEUTRON_DENOM, TestStateLocalCosmosTestNet, types, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/parallel/governance.test.ts b/src/testcases/parallel/governance.test.ts index d93ef9a6..096c0b3e 100644 --- a/src/testcases/parallel/governance.test.ts +++ b/src/testcases/parallel/governance.test.ts @@ -5,7 +5,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/parallel/interchain_tx_query_resubmit.test.ts b/src/testcases/parallel/interchain_tx_query_resubmit.test.ts index 3958d999..07787b95 100644 --- a/src/testcases/parallel/interchain_tx_query_resubmit.test.ts +++ b/src/testcases/parallel/interchain_tx_query_resubmit.test.ts @@ -5,7 +5,7 @@ import { NEUTRON_DENOM, TestStateLocalCosmosTestNet, types, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/parallel/overrule.test.ts b/src/testcases/parallel/overrule.test.ts index 400f4a42..e199fd98 100644 --- a/src/testcases/parallel/overrule.test.ts +++ b/src/testcases/parallel/overrule.test.ts @@ -4,7 +4,7 @@ import { dao, NEUTRON_DENOM, TestStateLocalCosmosTestNet, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/parallel/simple.test.ts b/src/testcases/parallel/simple.test.ts index 5ea3b1eb..a1e86fc1 100644 --- a/src/testcases/parallel/simple.test.ts +++ b/src/testcases/parallel/simple.test.ts @@ -7,7 +7,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/parallel/stargate_queries.test.ts b/src/testcases/parallel/stargate_queries.test.ts index 13ee54a6..2aae6228 100644 --- a/src/testcases/parallel/stargate_queries.test.ts +++ b/src/testcases/parallel/stargate_queries.test.ts @@ -1,47 +1,47 @@ -import Long from 'long'; import { - CosmosWrapper, + cosmosWrapper, COSMOS_DENOM, NEUTRON_DENOM, - WalletWrapper, - getEventAttribute, -} from '../../helpers/cosmos'; -import { NeutronContract } from '../../helpers/types'; -import { msgCreateDenom } from '../../helpers/tokenfactory'; - -import { TestStateLocalCosmosTestNet } from '../common_localcosmosnet'; -import { CodeId } from '../../types'; + TestStateLocalCosmosTestNet, + tokenfactory, + types, +} from '@neutron-org/neutronjs'; +import Long from 'long'; +const config = require('../../config.json'); describe('Neutron / Simple', () => { let testState: TestStateLocalCosmosTestNet; - let neutronChain: CosmosWrapper; - let neutronAccount: WalletWrapper; + let neutronChain: cosmosWrapper.CosmosWrapper; + let neutronAccount: cosmosWrapper.WalletWrapper; let contractAddress: string; - let gaiaChain: CosmosWrapper; - let gaiaAccount: WalletWrapper; + let gaiaChain: cosmosWrapper.CosmosWrapper; + let gaiaAccount: cosmosWrapper.WalletWrapper; let newTokenDenom: string; beforeAll(async () => { - testState = new TestStateLocalCosmosTestNet(); + cosmosWrapper.registerCodecs(); + tokenfactory.registerCodecs(); + + testState = new TestStateLocalCosmosTestNet(config); await testState.init(); - neutronChain = new CosmosWrapper( + neutronChain = new cosmosWrapper.CosmosWrapper( testState.sdk1, testState.blockWaiter1, NEUTRON_DENOM, ); - neutronAccount = new WalletWrapper( + neutronAccount = new cosmosWrapper.WalletWrapper( neutronChain, testState.wallets.qaNeutron.genQaWal1, ); - gaiaChain = new CosmosWrapper( + gaiaChain = new cosmosWrapper.CosmosWrapper( testState.sdk2, testState.blockWaiter2, COSMOS_DENOM, ); - gaiaAccount = new WalletWrapper( + gaiaAccount = new cosmosWrapper.WalletWrapper( gaiaChain, testState.wallets.qaCosmos.genQaWal1, ); @@ -65,12 +65,12 @@ describe('Neutron / Simple', () => { test('create denom, mint', async () => { const denom = `teststargate`; - const data = await msgCreateDenom( + const data = await tokenfactory.msgCreateDenom( neutronAccount, neutronAccount.wallet.address.toString(), denom, ); - newTokenDenom = getEventAttribute( + newTokenDenom = cosmosWrapper.getEventAttribute( (data as any).events, 'create_denom', 'new_token_denom', @@ -79,9 +79,11 @@ describe('Neutron / Simple', () => { }); describe('Contract instantiation', () => { - let codeId: CodeId; + let codeId: types.CodeId; test('store contract', async () => { - codeId = await neutronAccount.storeWasm(NeutronContract.STARGATE_QUERIER); + codeId = await neutronAccount.storeWasm( + types.NeutronContract.STARGATE_QUERIER, + ); expect(codeId).toBeGreaterThan(0); }); test('instantiate', async () => { diff --git a/src/testcases/parallel/subdao.test.ts b/src/testcases/parallel/subdao.test.ts index 6c19f9df..1a5da49d 100644 --- a/src/testcases/parallel/subdao.test.ts +++ b/src/testcases/parallel/subdao.test.ts @@ -8,7 +8,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/parallel/tge.credits_vault.test.ts b/src/testcases/parallel/tge.credits_vault.test.ts index d86053d3..e829a667 100644 --- a/src/testcases/parallel/tge.credits_vault.test.ts +++ b/src/testcases/parallel/tge.credits_vault.test.ts @@ -7,7 +7,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/parallel/tge.investors_vesting_vault.test.ts b/src/testcases/parallel/tge.investors_vesting_vault.test.ts index b4dd72db..673cce08 100644 --- a/src/testcases/parallel/tge.investors_vesting_vault.test.ts +++ b/src/testcases/parallel/tge.investors_vesting_vault.test.ts @@ -5,7 +5,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const INVESTORS_VESTING_CONTRACT_KEY = 'VESTING_INVESTORS'; const INVESTORS_VESTING_VAULT_CONTRACT_KEY = 'INVESTORS_VESTING_VAULT'; diff --git a/src/testcases/parallel/tge.vesting_lp_vault.test.ts b/src/testcases/parallel/tge.vesting_lp_vault.test.ts index a4b5ab30..59ab03ab 100644 --- a/src/testcases/parallel/tge.vesting_lp_vault.test.ts +++ b/src/testcases/parallel/tge.vesting_lp_vault.test.ts @@ -6,7 +6,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; // general contract keys used across the tests const ASTRO_PAIR_CONTRACT_KEY = 'ASTRO_PAIR'; diff --git a/src/testcases/parallel/tokenfactory.test.ts b/src/testcases/parallel/tokenfactory.test.ts index e0b4e6f6..2aaa7a1b 100644 --- a/src/testcases/parallel/tokenfactory.test.ts +++ b/src/testcases/parallel/tokenfactory.test.ts @@ -5,7 +5,7 @@ import { TestStateLocalCosmosTestNet, tokenfactory, types, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/run_in_band/globalfee.test.ts b/src/testcases/run_in_band/globalfee.test.ts index 2c97494e..9f389b96 100644 --- a/src/testcases/run_in_band/globalfee.test.ts +++ b/src/testcases/run_in_band/globalfee.test.ts @@ -6,7 +6,7 @@ import { NEUTRON_DENOM, TestStateLocalCosmosTestNet, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/run_in_band/ibc_hooks.test.ts b/src/testcases/run_in_band/ibc_hooks.test.ts index c8a68aed..a2d257b6 100644 --- a/src/testcases/run_in_band/ibc_hooks.test.ts +++ b/src/testcases/run_in_band/ibc_hooks.test.ts @@ -5,7 +5,7 @@ import { NEUTRON_DENOM, TestStateLocalCosmosTestNet, types, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/run_in_band/interchain_kv_query.test.ts b/src/testcases/run_in_band/interchain_kv_query.test.ts index 79eb519c..1d89654f 100644 --- a/src/testcases/run_in_band/interchain_kv_query.test.ts +++ b/src/testcases/run_in_band/interchain_kv_query.test.ts @@ -12,7 +12,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const getKvCallbackStatus = ( cm: cosmosWrapper.CosmosWrapper, diff --git a/src/testcases/run_in_band/interchain_tx_query_plain.test.ts b/src/testcases/run_in_band/interchain_tx_query_plain.test.ts index e85973aa..92260c4d 100644 --- a/src/testcases/run_in_band/interchain_tx_query_plain.test.ts +++ b/src/testcases/run_in_band/interchain_tx_query_plain.test.ts @@ -7,7 +7,7 @@ import { NEUTRON_DENOM, TestStateLocalCosmosTestNet, types, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/run_in_band/interchaintx.test.ts b/src/testcases/run_in_band/interchaintx.test.ts index 9b3a7c07..6a54c703 100644 --- a/src/testcases/run_in_band/interchaintx.test.ts +++ b/src/testcases/run_in_band/interchaintx.test.ts @@ -10,7 +10,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/run_in_band/reserve.test.ts b/src/testcases/run_in_band/reserve.test.ts index 001f33e1..97e0e062 100644 --- a/src/testcases/run_in_band/reserve.test.ts +++ b/src/testcases/run_in_band/reserve.test.ts @@ -6,7 +6,7 @@ import { NEUTRON_DENOM, TestStateLocalCosmosTestNet, types, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); interface ReserveStats { diff --git a/src/testcases/run_in_band/tge.airdrop.test.ts b/src/testcases/run_in_band/tge.airdrop.test.ts index 0c48b09c..fa171506 100644 --- a/src/testcases/run_in_band/tge.airdrop.test.ts +++ b/src/testcases/run_in_band/tge.airdrop.test.ts @@ -4,7 +4,7 @@ import { TestStateLocalCosmosTestNet, tge, types, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); diff --git a/src/testcases/run_in_band/tge.auction.test.ts b/src/testcases/run_in_band/tge.auction.test.ts index 7313121b..26da0214 100644 --- a/src/testcases/run_in_band/tge.auction.test.ts +++ b/src/testcases/run_in_band/tge.auction.test.ts @@ -11,7 +11,7 @@ import { tokenfactory, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const MIN_LIQUDITY = 1000; const ATOM_DEPOSIT_AMOUNT = 10000; diff --git a/src/testcases/run_in_band/tge.credits.test.ts b/src/testcases/run_in_band/tge.credits.test.ts index c24d18ce..45b68845 100644 --- a/src/testcases/run_in_band/tge.credits.test.ts +++ b/src/testcases/run_in_band/tge.credits.test.ts @@ -4,7 +4,7 @@ import { TestStateLocalCosmosTestNet, types, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const getTimestamp = (secondsFromNow: number): number => (Date.now() / 1000 + secondsFromNow) | 0; diff --git a/src/testcases/run_in_band/tokenomics.test.ts b/src/testcases/run_in_band/tokenomics.test.ts index fd33f01f..a3e0a18c 100644 --- a/src/testcases/run_in_band/tokenomics.test.ts +++ b/src/testcases/run_in_band/tokenomics.test.ts @@ -6,7 +6,7 @@ import { NEUTRON_DENOM, TestStateLocalCosmosTestNet, wait, -} from 'neutronjs'; +} from '@neutron-org/neutronjs'; const config = require('../../config.json'); describe('Neutron / Tokenomics', () => { diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index 6b016f9a..00000000 --- a/src/types.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { cosmosclient, proto } from '@cosmos-client/core'; -import bech32 from 'bech32'; - -export class cosmosWrapper.Wallet { - address: cosmosclient.AccAddress | cosmosclient.ValAddress; - account: proto.cosmos.auth.v1beta1.BaseAccount | null; - pubKey: cosmosclient.PubKey; - privKey: cosmosclient.PrivKey; - addrPrefix: string; - constructor( - address: cosmosclient.AccAddress | cosmosclient.ValAddress, - account: proto.cosmos.auth.v1beta1.BaseAccount | null, - pubKey: cosmosclient.PubKey, - privKey: cosmosclient.PrivKey, - addrPrefix: string, - ) { - this.address = address; - this.account = account; - this.pubKey = pubKey; - this.privKey = privKey; - this.addrPrefix = addrPrefix; - this.address.toString = () => { - if (this.address instanceof cosmosclient.AccAddress) { - const words = bech32.toWords(Buffer.from(this.address.value())); - return bech32.encode(addrPrefix, words); - } else if (this.address instanceof cosmosclient.ValAddress) { - const words = bech32.toWords(Buffer.from(this.address.value())); - return bech32.encode(addrPrefix + 'valoper', words); - } - throw new Error('unexpected addr type'); - }; - } -} - -export type CodeId = number; diff --git a/yarn.lock b/yarn.lock index febe526d..8e6c6c6c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1591,6 +1591,17 @@ "@jridgewell/resolve-uri" "^3.0.3" "@jridgewell/sourcemap-codec" "^1.4.10" +"@neutron-org/neutronjs@^0.0.4": + version "0.0.4" + resolved "https://registry.yarnpkg.com/@neutron-org/neutronjs/-/neutronjs-0.0.4.tgz#c9de82542e2b1515db6e62c92e29c604be72d8d6" + integrity sha512-RB8aoj5WLW1qgpRZSguJxb0UXcjUy71mgewp81nBquiqtOvSBdFegP0qKwVE056We+cMSWPR2CpGSdnDIjap8w== + dependencies: + "@cosmos-client/core" "0.45.13" + "@cosmos-client/cosmwasm" "^0.20.1" + "@cosmos-client/ibc" "^1.2.1" + axios "^0.27.2" + merkletreejs "^0.3.9" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -4615,15 +4626,6 @@ negotiator@0.6.3: resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== -"neutronjs@file:../neutronjs": - version "0.0.1" - dependencies: - "@cosmos-client/core" "0.45.13" - "@cosmos-client/cosmwasm" "^0.20.1" - "@cosmos-client/ibc" "^1.2.1" - axios "^0.27.2" - merkletreejs "^0.3.9" - node-addon-api@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32"