Skip to content

Commit

Permalink
refactor(oracle)!: remove QUERY_FEE constant
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `QUERY_FEE` is not exported anymore
Use 30000 instead if necessary.

BREAKING CHANGE: Oracles created without queryFee by default
Specify `queryFee` in `registerOracle` if needed.
  • Loading branch information
davidyuk committed Feb 15, 2023
1 parent c35aecd commit 0e9c552
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/index-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export * from './tx/builder/helpers';
export * from './tx/builder/constants';
// TODO: move to constants
export {
ORACLE_TTL_TYPES, QUERY_FEE, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL, DRY_RUN_ACCOUNT, CallReturnType,
ORACLE_TTL_TYPES, ORACLE_TTL, QUERY_TTL, RESPONSE_TTL, DRY_RUN_ACCOUNT, CallReturnType,
} from './tx/builder/schema';
export * from './utils/amount-formatter';
export * from './utils/hd-wallet';
Expand Down
6 changes: 1 addition & 5 deletions src/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
* repository.
*/

import BigNumber from 'bignumber.js';
import { mapObject, pause } from './utils/other';
import { oracleQueryId } from './tx/builder/helpers';
import { unpackTx, buildTxAsync, BuildTxOptions } from './tx/builder';
import {
ORACLE_TTL,
ORACLE_TTL_TYPES,
QUERY_FEE,
QUERY_TTL,
RESPONSE_TTL,
} from './tx/builder/schema';
Expand Down Expand Up @@ -333,7 +331,6 @@ export async function registerOracle(
> {
const accountId = options.onAccount.address;
const oracleRegisterTx = await buildTxAsync({
queryFee: QUERY_FEE,
oracleTtlValue: ORACLE_TTL.value,
oracleTtlType: ORACLE_TTL.type,
...options,
Expand All @@ -349,9 +346,8 @@ export async function registerOracle(
}

type RegisterOracleOptionsType = SendTransactionOptions & Parameters<typeof getOracleObject>[1]
& BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'queryFee' | 'oracleTtlType' | 'oracleTtlValue'>
& BuildTxOptions<Tag.OracleRegisterTx, 'accountId' | 'queryFormat' | 'responseFormat' | 'oracleTtlType' | 'oracleTtlValue'>
& {
queryFee?: number | string | BigNumber;
oracleTtlType?: ORACLE_TTL_TYPES;
oracleTtlValue?: number;
};
Expand Down
1 change: 0 additions & 1 deletion src/tx/builder/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export enum ORACLE_TTL_TYPES {
}

// # ORACLE
export const QUERY_FEE = 30000;
export const ORACLE_TTL = { type: ORACLE_TTL_TYPES.delta, value: 500 };
export const QUERY_TTL = { type: ORACLE_TTL_TYPES.delta, value: 10 };
export const RESPONSE_TTL = { type: ORACLE_TTL_TYPES.delta, value: 10 };
Expand Down
6 changes: 3 additions & 3 deletions test/integration/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getSdk } from '.';
import {
AeSdk, UnexpectedTsError,
decode, encode, registerOracle,
ORACLE_TTL_TYPES, QUERY_FEE, Encoding, RequestTimedOutError,
ORACLE_TTL_TYPES, Encoding, RequestTimedOutError,
} from '../../src';
import { Encoded } from '../../src/utils/encoder';

Expand Down Expand Up @@ -89,10 +89,10 @@ describe('Oracle', () => {
oracleWithFee = await aeSdk.registerOracle("{'city': str}", "{'tmp': num}", { queryFee: queryFee.toString() });
});

it('Post Oracle Query with default query fee', async () => {
it('Post Oracle Query without query fee', async () => {
const query = await oracle.postQuery("{'city': 'Berlin'}");
if (query.tx?.queryFee == null) throw new UnexpectedTsError();
query.tx.queryFee.should.be.equal(BigInt(QUERY_FEE));
query.tx.queryFee.should.be.equal(0n);
});

it('Post Oracle Query with registered query fee', async () => {
Expand Down

0 comments on commit 0e9c552

Please sign in to comment.