1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/src/keeper/contracts/Auth.ts

35 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-10-05 12:34:31 +02:00
import {Receipt} from "web3-utils"
import AccessStatus from "../../models/AccessStatus"
2018-10-18 13:12:23 +02:00
import ContractBase from "./ContractBase"
2018-10-18 13:12:23 +02:00
export default class OceanAuth extends ContractBase {
2018-10-16 14:56:18 +02:00
public static async getInstance(): Promise<OceanAuth> {
const auth: OceanAuth = new OceanAuth("OceanAuth")
2018-10-02 10:06:26 +02:00
await auth.init()
return auth
}
2018-10-17 18:24:01 +02:00
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]
2018-10-05 12:34:31 +02:00
})
}
2018-10-17 18:24:01 +02:00
public async getEncryptedAccessToken(orderId: string, consumerAddress: string): Promise<Receipt> {
return this.call("getEncryptedAccessToken", [orderId], consumerAddress)
}
2018-10-17 18:24:01 +02:00
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])
2018-10-17 18:24:01 +02:00
}
}