Updated Equilibrium types (#4299)
* Updated Equilibrium types; Fixed broken extrinsic fee calc for Equilibrium * Lint fix
This commit is contained in:
parent
e005b9d563
commit
d6ae01475b
@ -5,58 +5,76 @@
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
export default {
|
||||
BlockNumber: 'u64',
|
||||
Keys: 'SessionKeys3',
|
||||
Balance: 'u64',
|
||||
FixedI64: 'i64',
|
||||
SignedBalance: {
|
||||
_enum: {
|
||||
Positive: 'Balance',
|
||||
Negative: 'Balance'
|
||||
}
|
||||
},
|
||||
ReinitRequest: {
|
||||
account: 'AccountId',
|
||||
authority_index: 'AuthIndex',
|
||||
validators_len: 'u32',
|
||||
block_num: 'BlockNumber'
|
||||
BalanceOf: 'Balance',
|
||||
BalancesAggregate: {
|
||||
total_issuance: 'Balance',
|
||||
total_debt: 'Balance'
|
||||
},
|
||||
BlockNumber: 'u64',
|
||||
ChainId: 'u8',
|
||||
Currency: {
|
||||
_enum: ['Unknown', 'Usd', 'EQ', 'Eth', 'Btc', 'Eos', 'Dot']
|
||||
},
|
||||
UserGroup: {
|
||||
_enum: ['Unknown', 'Balances', 'Bailsman']
|
||||
},
|
||||
TotalAggregates: {
|
||||
collateral: 'Balance',
|
||||
debt: 'Balance'
|
||||
},
|
||||
PricePeriod: {
|
||||
_enum: ['Min', 'TenMin', 'Hour', 'FourHour', 'Day']
|
||||
},
|
||||
DataPoint: {
|
||||
price: 'u64',
|
||||
account_id: 'AccountId',
|
||||
block_number: 'BlockNumber',
|
||||
timestamp: 'u64'
|
||||
},
|
||||
DepositNonce: 'u64',
|
||||
FixedI64: 'i64',
|
||||
Keys: 'SessionKeys3',
|
||||
LookupSource: 'AccountId',
|
||||
OperationRequest: {
|
||||
account: 'AccountId',
|
||||
authority_index: 'AuthIndex',
|
||||
validators_len: 'u32',
|
||||
block_num: 'BlockNumber'
|
||||
},
|
||||
PricePayload: 'Data',
|
||||
PricePeriod: {
|
||||
_enum: ['Min', 'TenMin', 'Hour', 'FourHour', 'Day']
|
||||
},
|
||||
PricePoint: {
|
||||
block_number: 'BlockNumber',
|
||||
timestamp: 'u64',
|
||||
price: 'u64',
|
||||
data_points: 'Vec<DataPoint>'
|
||||
},
|
||||
BalancesAggregate: {
|
||||
total_issuance: 'Balance',
|
||||
total_debt: 'Balance'
|
||||
ProposalStatus: {
|
||||
_enum: [
|
||||
'Initiated',
|
||||
'Approved',
|
||||
'Rejected'
|
||||
]
|
||||
},
|
||||
VestingInfo: {
|
||||
locked: 'Balance',
|
||||
perBlock: 'Balance',
|
||||
startingBlock: 'BlockNumber'
|
||||
ProposalVotes: {
|
||||
votes_for: 'Vec<AccountId>',
|
||||
votes_against: 'Vec<AccountId>',
|
||||
status: 'ProposalStatus',
|
||||
expiry: 'BlockNumber'
|
||||
},
|
||||
ReinitRequest: {
|
||||
account: 'AccountId',
|
||||
authority_index: 'AuthIndex',
|
||||
validators_len: 'u32',
|
||||
block_num: 'BlockNumber'
|
||||
},
|
||||
ResourceId: '[u8; 32]',
|
||||
SignedBalance: {
|
||||
_enum: {
|
||||
Positive: 'Balance',
|
||||
Negative: 'Balance'
|
||||
}
|
||||
},
|
||||
SubAccType: {
|
||||
_enum: ['Bailsman', 'Borrower', 'Lender']
|
||||
},
|
||||
TotalAggregates: {
|
||||
collateral: 'Balance',
|
||||
debt: 'Balance'
|
||||
},
|
||||
LookupSource: 'AccountId',
|
||||
BalanceOf: 'Balance',
|
||||
TransferReason: {
|
||||
_enum: [
|
||||
'Common',
|
||||
@ -64,16 +82,16 @@ export default {
|
||||
'MarginCall',
|
||||
'BailsmenRedistribution',
|
||||
'TreasuryEqBuyout',
|
||||
'TreasuryBuyEq'
|
||||
'TreasuryBuyEq',
|
||||
'Subaccount'
|
||||
]
|
||||
},
|
||||
ProposalStatus: {
|
||||
_enum: ['Initiated', 'Approved', 'Rejected']
|
||||
UserGroup: {
|
||||
_enum: ['Unknown', 'Balances', 'Bailsmen', 'Borrowers', 'Lenders']
|
||||
},
|
||||
ProposalVotes: {
|
||||
votes_for: 'Vec<AccountId>',
|
||||
votes_against: 'Vec<AccountId>',
|
||||
status: 'ProposalStatus',
|
||||
expiry: 'BlockNumber'
|
||||
VestingInfo: {
|
||||
locked: 'Balance',
|
||||
perBlock: 'Balance',
|
||||
startingBlock: 'BlockNumber'
|
||||
}
|
||||
};
|
||||
|
||||
@ -43,17 +43,62 @@ type RawResult = [
|
||||
AccountInfo
|
||||
];
|
||||
|
||||
type EQDeriveBalancesQuery = (
|
||||
type EQDeriveBalancesAccountQuery = (
|
||||
address: AccountIndex | AccountId | Address | string
|
||||
) => Observable<{ accountNonce: Index; }>;
|
||||
|
||||
type EQDeriveBalancesAllQuery = (
|
||||
address: AccountIndex | AccountId | Address | string
|
||||
) => Observable<EQDeriveBalancesAll>;
|
||||
|
||||
export default {
|
||||
derives: {
|
||||
// TODO derive.democracy.locks
|
||||
// TODO derice.staking.account
|
||||
balances: {
|
||||
all: (
|
||||
account: (
|
||||
// Compatibility with calc tx fee
|
||||
instanceId: string,
|
||||
api: ApiInterfaceRx
|
||||
): EQDeriveBalancesQuery =>
|
||||
): EQDeriveBalancesAccountQuery =>
|
||||
memo(
|
||||
instanceId,
|
||||
(address: AccountId | AccountIndex | Address | string) =>
|
||||
api.derive.accounts.accountId(address).pipe(
|
||||
switchMap(
|
||||
(accountId): Observable<[AccountId, [Index]]> =>
|
||||
accountId
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
api
|
||||
.queryMulti([
|
||||
[api.query.system.account, accountId]
|
||||
])
|
||||
.pipe(
|
||||
map((raw): [Index] => {
|
||||
if (raw.length < 1) {
|
||||
throw new Error('Data expected');
|
||||
}
|
||||
|
||||
const data = raw as [AccountInfo];
|
||||
|
||||
return [data[0].nonce];
|
||||
})
|
||||
)
|
||||
])
|
||||
: of([
|
||||
api.registry.createType('AccountId'),
|
||||
[api.registry.createType('Index')]
|
||||
])
|
||||
),
|
||||
map(([, [accountNonce]]) => ({ accountNonce }))
|
||||
)
|
||||
),
|
||||
all: (
|
||||
// Compatibility for account balance in explorer
|
||||
instanceId: string,
|
||||
api: ApiInterfaceRx
|
||||
): EQDeriveBalancesAllQuery =>
|
||||
memo(
|
||||
instanceId,
|
||||
(address: AccountIndex | AccountId | Address | string) =>
|
||||
@ -123,12 +168,7 @@ export default {
|
||||
map(
|
||||
([
|
||||
accountId,
|
||||
[
|
||||
freeBalance,
|
||||
reservedBalance,
|
||||
vestingLocked,
|
||||
accountNonce
|
||||
]
|
||||
[freeBalance, reservedBalance, vestingLocked, accountNonce]
|
||||
]): EQDeriveBalancesAll => ({
|
||||
accountId,
|
||||
accountNonce,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user