This repository has been archived by the owner on Mar 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
interop.js
123 lines (120 loc) · 4.18 KB
/
interop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import {existsSync} from 'fs';
import {homedir} from 'os';
import {RpcNode, ShellQuery, babylonnet, carthagenet, localhost, mainnet, pool, zeronet} from './rpc/__init__';
import {Key, is_installed} from './crypto';
import {is_key, is_pkh} from './encoding';
var _pj;
var default_key, default_key_hash, default_shell;
function _pj_snippets(container) {
function in_es6(left, right) {
if (((right instanceof Array) || ((typeof right) === "string"))) {
return (right.indexOf(left) > (- 1));
} else {
if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
return right.has(left);
} else {
return (left in right);
}
}
}
container["in_es6"] = in_es6;
return container;
}
_pj = {};
_pj_snippets(_pj);
default_shell = "carthagenet";
default_key = "edsk33N474hxzA4sKeWVM6iuGNGDpX2mGwHNxEA4UbWS8sW3Ta3NKH";
default_key_hash = "tz1cnQZXoznhduu4MVWfJF6GSyP6mMHMbbWa";
class KeyHash extends Key {
constructor(public_key_hash) {
super(KeyHash, self).__init__(0) // TODO(*) Im still python;
this._pkh = public_key_hash;
}
__repr__() {
var res;
res = [super.__repr__(), `
Public key hash`
, this.public_key_hash()];
return "\n".join(res);
}
public_key_hash() {
return this._pkh;
}
public_key() {
throw NotImplementedError;
}
secret_key(passphrase = null, ed25519_seed = true) {
throw NotImplementedError;
}
sign(message, generic = false) {
throw NotImplementedError;
}
verify(signature, message) {
throw NotImplementedError;
}
}
class Interop {
__repr__() {
var res;
res = [super.__repr__(), "\nProperties", `.key # ${this.key.public_key_hash()}`, `.shell # ${this.shell.node.uri} (${this.shell.node.network})`];
return "\n".join(res);
}
constructor(shell = null, key = null) {
var networks;
if ((shell === null)) {
shell = default_shell;
}
if ((((typeof shell) === "string") || (shell instanceof String))) {
networks = {"mainnet": mainnet, "babylonnet": babylonnet, "carthagenet": carthagenet, "zeronet": zeronet, "sandboxnet": localhost.sandboxnet, "mainnet-pool": pool.mainnet};
if (_pj.in_es6(shell, networks)) {
this.shell = networks[shell];
} else {
this.shell = new ShellQuery({"node": new RpcNode({"uri": shell})});
}
} else {
if ((shell instanceof ShellQuery)) {
this.shell = shell;
} else {
throw new NotImplementedError(shell);
}
}
if ((key === null)) {
key = (is_installed() ? default_key : default_key_hash);
}
if ((((typeof key) === "string") || (key instanceof String))) {
if (is_key(key)) {
this.key = Key.from_encoded_key(key);
} else {
if (is_pkh(key)) {
this.key = new KeyHash(key);
} else {
if (existsSync(homedir(key))) {
this.key = Key.from_faucet(key);
} else {
this.key = Key.from_alias(key);
}
}
}
} else {
if ((key instanceof Key)) {
this.key = key;
} else {
throw new NotImplementedError(key);
}
}
}
_spawn(kwargs = {}) {
throw NotImplementedError;
}
using(shell = null, key = null) {
/*
Change current rpc endpoint and account (private key)
:param shell: one of 'babylonnet', 'mainnet', 'zeronet', or RPC node uri, or instance of `ShellQuery`
:param key: base58 encoded key, path to the faucet file, alias from tezos-client, or instance of `Key`
:return: A copy of current object with changes applied
*/
return this._spawn({"shell": shell, "key": key});
}
}
export {Interop, KeyHash, default_shell, default_key, default_key_hash};
//# sourceMappingURL=interop.js.map