mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import {Receipt} from "web3-utils"
|
|
import AccessStatus from "../../models/AccessStatus"
|
|
import ContractBase from "./ContractBase"
|
|
|
|
export default class OceanAuth extends ContractBase {
|
|
|
|
public static async getInstance(): Promise<OceanAuth> {
|
|
const auth: OceanAuth = new OceanAuth("OceanAuth")
|
|
await auth.init()
|
|
return auth
|
|
}
|
|
|
|
public async getOrderStatus(orderId: string): Promise<AccessStatus> {
|
|
return this.call("statusOfAccessRequest", [orderId])
|
|
.then((status: string) => {
|
|
const statusInt = parseInt(status, 10)
|
|
const statusString = AccessStatus[statusInt]
|
|
return AccessStatus[statusString]
|
|
})
|
|
}
|
|
|
|
public async getEncryptedAccessToken(orderId: string, consumerAddress: string): Promise<Receipt> {
|
|
return this.call("getEncryptedAccessToken", [orderId], consumerAddress)
|
|
}
|
|
|
|
public async getTempPubKey(orderId: string) {
|
|
return this.call("getTempPubKey", [orderId])
|
|
}
|
|
|
|
public async deliverAccessToken(orderId: string, accessToken: string, publisherAddress: string) {
|
|
return this.send("deliverAccessToken", publisherAddress, [orderId, accessToken])
|
|
}
|
|
|
|
}
|