Skip to content

Commit

Permalink
Merge pull request #293 from neutron-org/feat/slinky-bindings
Browse files Browse the repository at this point in the history
NTRN-260 slinky bindings (market map & oracle)
  • Loading branch information
swelf19 authored May 22, 2024
2 parents 54b96ff + cd70c26 commit 27f5334
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@cosmos-client/core": "^0.47.4",
"@cosmos-client/cosmwasm": "^0.40.3",
"@cosmos-client/ibc": "^1.2.1",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#539032708ccc600e3c66ae9f7bbde1c8a807a8a0",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#b0acb8a3bb7ad3af7cde5f67ba259a94c2fa3e4f",
"@types/lodash": "^4.14.182",
"@types/long": "^5.0.0",
"axios": "^0.27.2",
Expand Down
124 changes: 124 additions & 0 deletions src/testcases/run_in_band/slinky.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ import {
DaoMember,
getDaoContracts,
} from '@neutron-org/neutronjsplus/dist/dao';
import { NeutronContract } from '@neutron-org/neutronjsplus/dist/types';
import {
GetPriceResponse,
GetAllCurrencyPairsResponse,
GetPricesResponse,
} from '@neutron-org/neutronjsplus/src/oracle';
import {
ParamsResponse,
LastUpdatedResponse,
MarketMapResponse,
MarketResponse,
} from '@neutron-org/neutronjsplus/src/marketmap';

const config = require('../../config.json');

Expand Down Expand Up @@ -127,4 +139,116 @@ describe('Neutron / Slinky', () => {
expect(+res.price.price).toBeGreaterThan(0);
});
});

describe('wasmbindings oracle', () => {
let contractAddress: string;

test('setup contract', async () => {
const codeId = await neutronAccount.storeWasm(NeutronContract.ORACLE);
expect(codeId).toBeGreaterThan(0);

const res = await neutronAccount.instantiateContract(
codeId,
'{}',
'oracle',
);
contractAddress = res[0]._contract_address;
});

test('query prices', async () => {
const res = await neutronChain.queryContract<GetPricesResponse>(
contractAddress,
{
get_prices: {
currency_pair_ids: ['ETH/USDT'],
},
},
);
expect(res.prices).toHaveLength(1);
expect(+res.prices[0].price.price).toBeGreaterThan(0);
});

test('query price', async () => {
const res = await neutronChain.queryContract<GetPriceResponse>(
contractAddress,
{
get_price: { currency_pair: { Base: 'ETH', Quote: 'USDT' } },
},
);
expect(+res.price.price).toBeGreaterThan(0);
});

test('query currencies', async () => {
const res = await neutronChain.queryContract<GetAllCurrencyPairsResponse>(
contractAddress,
{
get_all_currency_pairs: {},
},
);
expect(res.currency_pairs[0].Base).toBe('ETH');
expect(res.currency_pairs[0].Quote).toBe('USDT');
});
});
describe('wasmbindings marketmap', () => {
let contractAddress: string;

test('setup contract', async () => {
const codeId = await neutronAccount.storeWasm(NeutronContract.MARKETMAP);
expect(codeId).toBeGreaterThan(0);

const res = await neutronAccount.instantiateContract(
codeId,
'{}',
'marketmap',
);
contractAddress = res[0]._contract_address;
});

test('query last', async () => {
const res = await neutronChain.queryContract<LastUpdatedResponse>(
contractAddress,
{
last_updated: {},
},
);
expect(res.last_updated).toBeGreaterThan(0);
});

test('query market', async () => {
const res = await neutronChain.queryContract<MarketResponse>(
contractAddress,
{
market: { currency_pair: { Base: 'ETH', Quote: 'USDT' } },
},
);
expect(res.market).toBeDefined();
});

test('query market map', async () => {
const res = await neutronChain.queryContract<MarketMapResponse>(
contractAddress,
{
market_map: {},
},
);
expect(res).toBeDefined();
expect(res.chain_id).toBeDefined();
expect(res.market_map).toBeDefined();
expect(res.last_updated).toBeDefined();
});

test('query params', async () => {
const res = await neutronChain.queryContract<ParamsResponse>(
contractAddress,
{
params: {},
},
);
expect(res).toBeDefined();
expect(res.params.admin).toBeDefined();
expect(res.params.market_authorities[0]).toEqual(
'neutron1hxskfdxpp5hqgtjj6am6nkjefhfzj359x0ar3z',
);
});
});
});
56 changes: 28 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1568,9 +1568,9 @@
resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.50.0.tgz#29c6419e8379d496ab6d0426eadf3c4d100cd186"
integrity sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA==

"@neutron-org/neutronjsplus@https://github.com/neutron-org/neutronjsplus.git#539032708ccc600e3c66ae9f7bbde1c8a807a8a0":
"@neutron-org/neutronjsplus@https://github.com/neutron-org/neutronjsplus.git#b0acb8a3bb7ad3af7cde5f67ba259a94c2fa3e4f":
version "0.4.0-rc19"
resolved "https://github.com/neutron-org/neutronjsplus.git#539032708ccc600e3c66ae9f7bbde1c8a807a8a0"
resolved "https://github.com/neutron-org/neutronjsplus.git#b0acb8a3bb7ad3af7cde5f67ba259a94c2fa3e4f"
dependencies:
"@bufbuild/protobuf" "^1.4.2"
"@cosmos-client/core" "^0.47.4"
Expand Down Expand Up @@ -1825,9 +1825,9 @@
integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==

"@types/lodash@^4.14.182":
version "4.17.4"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.4.tgz#0303b64958ee070059e3a7184048a55159fe20b7"
integrity sha512-wYCP26ZLxaT3R39kiN2+HcJ4kTd3U1waI/cY7ivWYqFP6pW3ZNpvi6Wd6PHZx7T/t8z0vlkXMg3QYLa7DZ/IJQ==
version "4.17.1"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.1.tgz#0fabfcf2f2127ef73b119d98452bd317c4a17eb8"
integrity sha512-X+2qazGS3jxLAIz5JDXDzglAF3KpijdhFxlf/V1+hEsOUc+HnWi81L/uv/EvGuV90WY+7mPGFCUDGfQC3Gj95Q==

"@types/long@^4.0.1":
version "4.0.2"
Expand All @@ -1847,9 +1847,9 @@
integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==

"@types/node@*", "@types/node@>=13.7.0":
version "20.12.12"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.12.tgz#7cbecdf902085cec634fdb362172dfe12b8f2050"
integrity sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==
version "20.12.11"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.11.tgz#c4ef00d3507000d17690643278a60dc55a9dc9be"
integrity sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==
dependencies:
undici-types "~5.26.4"

Expand Down Expand Up @@ -2423,9 +2423,9 @@ camelcase@^6.2.0:
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==

caniuse-lite@^1.0.30001587:
version "1.0.30001620"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001620.tgz#78bb6f35b8fe315b96b8590597094145d0b146b4"
integrity sha512-WJvYsOjd1/BYUY6SNGUosK9DUidBPDTnOARHp3fSmFO1ekdxaY6nKRttEVrfMmYi80ctS0kz1wiWmm14fVc3ew==
version "1.0.30001617"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001617.tgz#809bc25f3f5027ceb33142a7d6c40759d7a901eb"
integrity sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==

chalk@^2.3.0, chalk@^2.4.2:
version "2.4.2"
Expand Down Expand Up @@ -2607,16 +2607,16 @@ [email protected]:
integrity sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==

core-js-compat@^3.31.0, core-js-compat@^3.36.1:
version "3.37.1"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.37.1.tgz#c844310c7852f4bdf49b8d339730b97e17ff09ee"
integrity sha512-9TNiImhKvQqSUkOvk/mMRZzOANTiEVC7WaBNhHcKM7x+/5E1l5NvsysR19zuDQScE8k+kfQXWRN3AtS/eOSHpg==
version "3.37.0"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.37.0.tgz#d9570e544163779bb4dff1031c7972f44918dc73"
integrity sha512-vYq4L+T8aS5UuFg4UwDhc7YNRWVeVZwltad9C/jV3R2LgVOpS9BDr7l/WL6BN0dbV3k1XejPTHqqEzJgsa0frA==
dependencies:
browserslist "^4.23.0"

core-js@^3.23.5:
version "3.37.1"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.37.1.tgz#d21751ddb756518ac5a00e4d66499df981a62db9"
integrity sha512-Xn6qmxrQZyB0FFY8E3bgRXei3lWDJHhvI+u0q9TKIYM49G8pAr0FgnnrFRAmsbptZL1yxRADVXn+x5AGsbBfyw==
version "3.37.0"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.37.0.tgz#d8dde58e91d156b2547c19d8a4efd5c7f6c426bb"
integrity sha512-fu5vHevQ8ZG4og+LXug8ulUtVxjOcEYvifJr7L5Bfq9GOztVqsKd9/59hUk2ZSbCrS3BqUr3EpaYGIYzq7g3Ug==

cosmjs-types@^0.4.0:
version "0.4.1"
Expand Down Expand Up @@ -2812,9 +2812,9 @@ [email protected]:
integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==

electron-to-chromium@^1.4.668:
version "1.4.773"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.773.tgz#49741af9bb4e712ad899e35d8344d8d59cdb7e12"
integrity sha512-87eHF+h3PlCRwbxVEAw9KtK3v7lWfc/sUDr0W76955AdYTG4bV/k0zrl585Qnj/skRMH2qOSiE+kqMeOQ+LOpw==
version "1.4.763"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.763.tgz#64f2041ed496fd6fc710b9be806fe91da9334f91"
integrity sha512-k4J8NrtJ9QrvHLRo8Q18OncqBCB7tIUyqxRcJnlonQ0ioHKYB988GcDFF3ZePmnb8eHEopDs/wPHR/iGAFgoUQ==

elliptic@^6.4.0, elliptic@^6.5.3, elliptic@^6.5.4:
version "6.5.5"
Expand Down Expand Up @@ -4553,10 +4553,10 @@ path-type@^4.0.0:
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

picocolors@^1.0.0, picocolors@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.1.tgz#a8ad579b571952f0e5d25892de5445bcfe25aaa1"
integrity sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==
picocolors@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c"
integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==

picomatch@^2.0.4, picomatch@^2.2.3, picomatch@^2.3.1:
version "2.3.1"
Expand Down Expand Up @@ -5385,12 +5385,12 @@ [email protected], unpipe@~1.0.0:
integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==

update-browserslist-db@^1.0.13:
version "1.0.16"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz#f6d489ed90fb2f07d67784eb3f53d7891f736356"
integrity sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==
version "1.0.15"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.15.tgz#60ed9f8cba4a728b7ecf7356f641a31e3a691d97"
integrity sha512-K9HWH62x3/EalU1U6sjSZiylm9C8tgq2mSvshZpqc7QE69RaA2qjhkW2HlNA0tFpEbtyFz7HTqbSdN4MSwUodA==
dependencies:
escalade "^3.1.2"
picocolors "^1.0.1"
picocolors "^1.0.0"

uri-js@^4.2.2:
version "4.4.1"
Expand Down

0 comments on commit 27f5334

Please sign in to comment.