Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Pyband & Bandchain.js: Added get request evm proof on pyband and bandchain.js #2972

Merged
merged 6 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@

### Helpers

- (impv) [\#2943](https://github.com/bandprotocol/bandchain/pull/2943) Bandchain.js: Added return `undefined` when account does not exist
- (feat) [\#2972](https://github.com/bandprotocol/bandchain/pull/2972) pyband&bandchain.js: Added get request evm proof on pyband and bandchain.js
- (impv) [\#2967](https://github.com/bandprotocol/bandchain/pull/2967) bandchain.js: Added new params to getReferenceData
- (impv) [\#2943](https://github.com/bandprotocol/bandchain/pull/2943) Bandchain.js: Added return `undefined` when account does not exist
- (impv) [\#2941](https://github.com/bandprotocol/bandchain/pull/2941) pyband: Added return None when account does not exist
- (bugs) [\#2935](https://github.com/bandprotocol/bandchain/pull/2935) bandchainjs: Fixed the msg field ordering
- (impv) [\#2924](https://github.com/bandprotocol/bandchain/pull/2924) pyband: added new type and refactor the dataclass
Expand Down
810 changes: 808 additions & 2 deletions helpers/bandchain2.js/__tests__/client/client.test.ts

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions helpers/bandchain2.js/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
OracleScript,
RequestInfo,
HexBytes,
EVMProof
} from './data'
import { Address } from './wallet'

Expand Down Expand Up @@ -488,4 +489,13 @@ export default class Client {

return requestIDs
}

async getRequestEVMProofByRequestID(requestID: number): Promise<EVMProof> {
if (!Number.isInteger(requestID)) throw Error('requestID is not an integer')
const response = await this.getResult(`/oracle/proof/${requestID}`)
return {
jsonProof: response.jsonProof,
evmProofBytes: Buffer.from(response.evmProofBytes, "hex")
}
}
}
6 changes: 6 additions & 0 deletions helpers/bandchain2.js/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,9 @@ export interface RequestInfo {
reports?: Report[]
result?: Result
}


export interface EVMProof {
jsonProof: object
evmProofBytes: Buffer
}
pzshine marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions helpers/pyband/pyband/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
TransactionBlockMode,
ReferencePrice,
ReferencePriceUpdated,
EVMProof,
)


Expand Down Expand Up @@ -203,3 +204,7 @@ def get_reference_data(self, pairs: List[str], min_count: int, ask_count: int) -

except:
raise ValueError("Error quering prices")

def get_request_evm_proof_by_request_id(self, request_id: int) -> EVMProof:
data = self._get_result("/oracle/proof/{}".format(request_id))
return EVMProof(json_proof=data["jsonProof"], evm_proof_bytes=HexBytes(bytes.fromhex(data["evmProofBytes"])))
6 changes: 6 additions & 0 deletions helpers/pyband/pyband/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ class ReferencePrice(object):
updated_at: ReferencePriceUpdated


@dataclass
class EVMProof(object):
json_proof: dict
evm_proof_bytes: HexBytes


DACITE_CONFIG = Config(
type_hooks={
int: int,
Expand Down
2 changes: 2 additions & 0 deletions helpers/pyband/pyband/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def with_auto(self, client: Client) -> "Transaction":

addr = self.msgs[0].get_sender()
account = client.get_account(addr)
if account == None:
raise SystemError("Account doesn't exist.")
self.account_num = account.account_number
self.sequence = account.sequence
return self
Expand Down
710 changes: 676 additions & 34 deletions helpers/pyband/tests/client/client_test.py

Large diffs are not rendered by default.