mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Change the type of the price of an asset to string.
This commit is contained in:
parent
080299dbd8
commit
6fe8430b08
80
package-lock.json
generated
80
package-lock.json
generated
@ -856,18 +856,11 @@
|
|||||||
"version": "1.5.0",
|
"version": "1.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||||
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"file-uri-to-path": "1.0.0"
|
"file-uri-to-path": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bip66": {
|
|
||||||
"version": "1.1.5",
|
|
||||||
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz",
|
|
||||||
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=",
|
|
||||||
"requires": {
|
|
||||||
"safe-buffer": "^5.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bl": {
|
"bl": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz",
|
||||||
@ -1871,16 +1864,6 @@
|
|||||||
"integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==",
|
"integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"drbg.js": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=",
|
|
||||||
"requires": {
|
|
||||||
"browserify-aes": "^1.0.6",
|
|
||||||
"create-hash": "^1.1.2",
|
|
||||||
"create-hmac": "^1.1.4"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"dtype": {
|
"dtype": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/dtype/-/dtype-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/dtype/-/dtype-2.0.0.tgz",
|
||||||
@ -2097,20 +2080,6 @@
|
|||||||
"xhr-request-promise": "^0.1.2"
|
"xhr-request-promise": "^0.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethereumjs-util": {
|
|
||||||
"version": "6.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz",
|
|
||||||
"integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==",
|
|
||||||
"requires": {
|
|
||||||
"bn.js": "^4.11.0",
|
|
||||||
"create-hash": "^1.1.2",
|
|
||||||
"ethjs-util": "0.1.6",
|
|
||||||
"keccak": "^1.0.2",
|
|
||||||
"rlp": "^2.0.0",
|
|
||||||
"safe-buffer": "^5.1.1",
|
|
||||||
"secp256k1": "^3.0.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"ethers": {
|
"ethers": {
|
||||||
"version": "4.0.0-beta.1",
|
"version": "4.0.0-beta.1",
|
||||||
"resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.1.tgz",
|
"resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.0-beta.1.tgz",
|
||||||
@ -2186,15 +2155,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ethjs-util": {
|
|
||||||
"version": "0.1.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz",
|
|
||||||
"integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==",
|
|
||||||
"requires": {
|
|
||||||
"is-hex-prefixed": "1.0.0",
|
|
||||||
"strip-hex-prefix": "1.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"eventemitter3": {
|
"eventemitter3": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.1.1.tgz",
|
||||||
@ -2462,7 +2422,8 @@
|
|||||||
"file-uri-to-path": {
|
"file-uri-to-path": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"fill-range": {
|
"fill-range": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
@ -4306,17 +4267,6 @@
|
|||||||
"verror": "1.10.0"
|
"verror": "1.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"keccak": {
|
|
||||||
"version": "1.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz",
|
|
||||||
"integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==",
|
|
||||||
"requires": {
|
|
||||||
"bindings": "^1.2.1",
|
|
||||||
"inherits": "^2.0.3",
|
|
||||||
"nan": "^2.2.1",
|
|
||||||
"safe-buffer": "^5.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"keccakjs": {
|
"keccakjs": {
|
||||||
"version": "0.2.3",
|
"version": "0.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/keccakjs/-/keccakjs-0.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/keccakjs/-/keccakjs-0.2.3.tgz",
|
||||||
@ -5881,15 +5831,6 @@
|
|||||||
"inherits": "^2.0.1"
|
"inherits": "^2.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rlp": {
|
|
||||||
"version": "2.2.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.2.tgz",
|
|
||||||
"integrity": "sha512-Ng2kJEN731Sfv4ZAY2i0ytPMc0BbJKBsVNl0QZY8LxOWSwd+1xpg+fpSRfaMn0heHU447s6Kgy8qfHZR0XTyVw==",
|
|
||||||
"requires": {
|
|
||||||
"bn.js": "^4.11.1",
|
|
||||||
"safe-buffer": "^5.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"run-queue": {
|
"run-queue": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz",
|
||||||
@ -5972,21 +5913,6 @@
|
|||||||
"pbkdf2": "^3.0.3"
|
"pbkdf2": "^3.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"secp256k1": {
|
|
||||||
"version": "3.6.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.6.2.tgz",
|
|
||||||
"integrity": "sha512-90nYt7yb0LmI4A2jJs1grglkTAXrBwxYAjP9bpeKjvJKOjG2fOeH/YI/lchDMIvjrOasd5QXwvV2jwN168xNng==",
|
|
||||||
"requires": {
|
|
||||||
"bindings": "^1.2.1",
|
|
||||||
"bip66": "^1.1.3",
|
|
||||||
"bn.js": "^4.11.3",
|
|
||||||
"create-hash": "^1.1.2",
|
|
||||||
"drbg.js": "^1.0.1",
|
|
||||||
"elliptic": "^6.2.3",
|
|
||||||
"nan": "^2.2.1",
|
|
||||||
"safe-buffer": "^5.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"seek-bzip": {
|
"seek-bzip": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz",
|
||||||
|
@ -68,7 +68,6 @@
|
|||||||
"@oceanprotocol/keeper-contracts": "^0.9.7",
|
"@oceanprotocol/keeper-contracts": "^0.9.7",
|
||||||
"bignumber.js": "^8.1.1",
|
"bignumber.js": "^8.1.1",
|
||||||
"deprecated-decorator": "^0.1.6",
|
"deprecated-decorator": "^0.1.6",
|
||||||
"ethereumjs-util": "^6.1.0",
|
|
||||||
"node-fetch": "^2.3.0",
|
"node-fetch": "^2.3.0",
|
||||||
"save-file": "^2.3.1",
|
"save-file": "^2.3.1",
|
||||||
"uuid": "^3.3.2",
|
"uuid": "^3.3.2",
|
||||||
|
@ -176,10 +176,10 @@ export interface MetaDataBase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Price of the asset.
|
* Price of the asset.
|
||||||
* @type {number}
|
* @type {string}
|
||||||
* @example 10
|
* @example "1000000000000000000"
|
||||||
*/
|
*/
|
||||||
price: number
|
price: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array of File objects including the encrypted file urls and some additional information.
|
* Array of File objects including the encrypted file urls and some additional information.
|
||||||
|
@ -9,7 +9,7 @@ export default class Dispenser extends ContractBase {
|
|||||||
return dispenser
|
return dispenser
|
||||||
}
|
}
|
||||||
|
|
||||||
public async requestTokens(amount: number, receiverAddress: string) {
|
public async requestTokens(amount: number | string, receiverAddress: string) {
|
||||||
return this.send("requestTokens", receiverAddress, [amount])
|
return this.send("requestTokens", receiverAddress, [String(amount)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ export default class OceanToken extends ContractBase {
|
|||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
|
||||||
public async approve(to: string, price: number, from?: string) {
|
public async approve(to: string, price: number | string, from?: string) {
|
||||||
return this.sendFrom("approve", [to, price], from)
|
return this.sendFrom("approve", [to, String(price)], from)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async decimals(): Promise<number> {
|
public async decimals(): Promise<number> {
|
||||||
|
@ -8,11 +8,11 @@ export class LockRewardCondition extends Condition {
|
|||||||
return Condition.getInstance(config, "LockRewardCondition", LockRewardCondition)
|
return Condition.getInstance(config, "LockRewardCondition", LockRewardCondition)
|
||||||
}
|
}
|
||||||
|
|
||||||
public hashValues(rewardAddress: string, amount: number) {
|
public hashValues(rewardAddress: string, amount: number | string) {
|
||||||
return super.hashValues(zeroX(rewardAddress), amount)
|
return super.hashValues(zeroX(rewardAddress), String(amount))
|
||||||
}
|
}
|
||||||
|
|
||||||
public fulfill(agreementId: string, rewardAddress: string, amount: number, from?: string) {
|
public fulfill(agreementId: string, rewardAddress: string, amount: number | string, from?: string) {
|
||||||
return super.fulfill(agreementId, [zeroX(rewardAddress), amount], from)
|
return super.fulfill(agreementId, [zeroX(rewardAddress), String(amount)], from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplate {
|
|||||||
* @param {string} from Consumer address.
|
* @param {string} from Consumer address.
|
||||||
* @return {Promise<string>} Agreement ID.
|
* @return {Promise<string>} Agreement ID.
|
||||||
*/
|
*/
|
||||||
public async createFullAgreement(did: string, amount: number, consumer: string, from?: string, agreementId?: string): Promise<string> {
|
public async createFullAgreement(did: string, amount: number | string, consumer: string, from?: string, agreementId?: string): Promise<string> {
|
||||||
agreementId = agreementId || generateId()
|
agreementId = agreementId || generateId()
|
||||||
const {accessSecretStoreConditionId, lockRewardConditionId, escrowRewardId} =
|
const {accessSecretStoreConditionId, lockRewardConditionId, escrowRewardId} =
|
||||||
await this.createFullAgreementData(agreementId, did, amount, consumer)
|
await this.createFullAgreementData(agreementId, did, amount, consumer)
|
||||||
@ -87,7 +87,7 @@ export class EscrowAccessSecretStoreTemplate extends AgreementTemplate {
|
|||||||
return zeroX(agreementId)
|
return zeroX(agreementId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async createFullAgreementData(agreementId: string, did: string, amount: number, consumer: string) {
|
private async createFullAgreementData(agreementId: string, did: string, amount: number | string, consumer: string) {
|
||||||
const {didRegistry, conditions} = this.ocean.keeper
|
const {didRegistry, conditions} = this.ocean.keeper
|
||||||
|
|
||||||
const {accessSecretStoreCondition, lockRewardCondition, escrowReward} = conditions
|
const {accessSecretStoreCondition, lockRewardCondition, escrowReward} = conditions
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import BigNumber from "bignumber.js"
|
import BigNumber from "bignumber.js"
|
||||||
import * as EthJsUtils from "ethereumjs-util"
|
|
||||||
import Balance from "../models/Balance"
|
import Balance from "../models/Balance"
|
||||||
|
|
||||||
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
|
import { Instantiable, InstantiableConfig } from "../Instantiable.abstract"
|
||||||
@ -79,7 +78,8 @@ export default class Account extends Instantiable {
|
|||||||
* @param {number} amount Tokens to be requested.
|
* @param {number} amount Tokens to be requested.
|
||||||
* @return {Promise<number>}
|
* @return {Promise<number>}
|
||||||
*/
|
*/
|
||||||
public async requestTokens(amount: number): Promise<number> {
|
public async requestTokens(amount: number | string): Promise<string> {
|
||||||
|
amount = String(amount)
|
||||||
try {
|
try {
|
||||||
await this.ocean.keeper
|
await this.ocean.keeper
|
||||||
.dispenser
|
.dispenser
|
||||||
@ -91,16 +91,4 @@ export default class Account extends Instantiable {
|
|||||||
}
|
}
|
||||||
return amount
|
return amount
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the account public key.
|
|
||||||
* @return {Promise<string>}
|
|
||||||
*/
|
|
||||||
public async getPublicKey(): Promise<string> {
|
|
||||||
const msg = this.web3.utils.sha3(this.getId())
|
|
||||||
const sig = await this.web3.eth.sign(msg, this.getId())
|
|
||||||
const {v, r, s} = EthJsUtils.fromRpcSig(sig)
|
|
||||||
|
|
||||||
return EthJsUtils.ecrecover(EthJsUtils.toBuffer(msg), v, r, s).toString("hex")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ export class OceanAgreementsConditions extends Instantiable {
|
|||||||
* @param {number} amount Asset amount.
|
* @param {number} amount Asset amount.
|
||||||
* @param {Account} from Account of sender.
|
* @param {Account} from Account of sender.
|
||||||
*/
|
*/
|
||||||
public async lockReward(agreementId: string, amount: number, from?: Account) {
|
public async lockReward(agreementId: string, amount: number | string, from?: Account) {
|
||||||
const {lockRewardCondition, escrowReward} = this.ocean.keeper.conditions
|
const {lockRewardCondition, escrowReward} = this.ocean.keeper.conditions
|
||||||
|
|
||||||
await this.ocean.keeper.token.approve(lockRewardCondition.getAddress(), amount, from.getId())
|
await this.ocean.keeper.token.approve(lockRewardCondition.getAddress(), amount, from.getId())
|
||||||
|
@ -67,21 +67,12 @@ describe("Account", () => {
|
|||||||
|
|
||||||
it("should return the amount of tokens granted", async () => {
|
it("should return the amount of tokens granted", async () => {
|
||||||
|
|
||||||
const tokens = 500
|
const tokens = "500"
|
||||||
const account: Account = accounts[0]
|
const account: Account = accounts[0]
|
||||||
const tokensGranted: number = await account.requestTokens(tokens)
|
const tokensGranted: string = await account.requestTokens(tokens)
|
||||||
|
|
||||||
assert(tokensGranted === tokens)
|
assert.equal(tokensGranted, tokens)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("#getPublicKey()", () => {
|
|
||||||
|
|
||||||
it("should get the public key of an account", async () => {
|
|
||||||
const publicKey = await accounts[1].getPublicKey()
|
|
||||||
assert(publicKey)
|
|
||||||
|
|
||||||
assert(publicKey.length === 128)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user