Skip to content

Commit

Permalink
[PVM][API] Owner / OwnerParam differentation
Browse files Browse the repository at this point in the history
  • Loading branch information
peak3d committed Apr 25, 2023
1 parent c4468dc commit d3525b6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/platformvm/getClaimables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Avalanche } from "caminojs/index"
import {
GetClaimablesResponse,
KeyChain,
Owner,
OwnerParam,
PlatformVMAPI
} from "caminojs/apis/platformvm"
import { ExamplesConfig } from "../common/examplesConfig"
Expand Down Expand Up @@ -37,7 +37,7 @@ const main = async (): Promise<any> => {
addresses: pAddressStrings,
threshold: 1,
locktime: "0"
} as Owner
} as OwnerParam
])
console.log(claimables)
}
Expand Down
20 changes: 16 additions & 4 deletions src/apis/platformvm/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ import {
GetAllDepositOffersResponse,
GetDepositsParams,
GetDepositsResponse,
Owner
Owner,
OwnerParam
} from "./interfaces"
import { TransferableInput } from "./inputs"
import { TransferableOutput } from "./outputs"
Expand Down Expand Up @@ -653,7 +654,11 @@ export class PlatformVMAPI extends JRPCAPI {
start: new BN(deposit.start),
duration: deposit.duration,
amount: new BN(deposit.amount),
rewardOwner: deposit.rewardOwner
rewardOwner: {
locktime: new BN(deposit.rewardOwner.locktime),
threshold: new BN(deposit.rewardOwner.threshold).toNumber(),
addresses: deposit.rewardOwner.addresses
} as Owner
} as APIDeposit
}),
availableRewards: deposits.availableRewards.map((a) => new BN(a)),
Expand All @@ -668,7 +673,9 @@ export class PlatformVMAPI extends JRPCAPI {
*
* @returns Promise for an object containing the amounts that can be claimed.
*/
getClaimables = async (owners: Owner[]): Promise<GetClaimablesResponse> => {
getClaimables = async (
owners: OwnerParam[]
): Promise<GetClaimablesResponse> => {
const params = {
Owners: owners
}
Expand Down Expand Up @@ -1454,7 +1461,12 @@ export class PlatformVMAPI extends JRPCAPI {
"platform.getMultisigAlias",
params
)
return response.data.result
return {
memo: response.data.result.memo,
locktime: new BN(response.data.result.locktime),
threshold: new BN(response.data.result.threshold).toNumber(),
addresses: response.data.result.addresses
} as MultisigAliasReply
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/apis/platformvm/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ export interface GetMaxStakeAmountParams {
}

export interface Owner {
locktime: BN
threshold: number
addresses: string[]
}

export interface OwnerParam {
locktime: string
threshold: number
addresses: string[]
Expand All @@ -312,8 +318,8 @@ export interface MultisigAliasReply extends Owner {
export interface SpendParams {
from: string[] | string
signer: string[] | string
to?: Owner
change?: Owner
to?: OwnerParam
change?: OwnerParam

lockMode: 0 | 1 | 2
amountToLock: string
Expand Down

0 comments on commit d3525b6

Please sign in to comment.