indium 0.0.9 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/indium.rb +20 -57
- metadata +9 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acf0e6d7ec868e722ba35b8c69e224085c36dbaf879444d2fabb2fbc615d82f3
|
4
|
+
data.tar.gz: c6082918207b40ef23e0ad927b27de53d4ba8c65b173a26c0e86f72b8685927f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 604b7d0408f182d9cd04f1b993aa773de734598eeed0b7934002cc8737ffec1cd9d256735bb0311dd2cd2bac0cdcc0fd5cf3ad3e08a928c9342993d0adaa87c3
|
7
|
+
data.tar.gz: c7d5242b1bdd419ba1f173ab8a5dad47e403c3383021f9b6fd5a86e3f60de1be2186efff451e31de060c03471948621c3dd7e91f433ef2708ea2ac63abf37d49
|
data/lib/indium.rb
CHANGED
@@ -1,76 +1,39 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'json'
|
1
|
+
require 'ethereum.rb'
|
2
|
+
require 'eth'
|
4
3
|
|
5
4
|
class Indium
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@issuer_address = "GB6TBT62K4NG2MIHMGGRZPIW2GI62T56RCWHWHKCY2BIORDPQQ5LCPVR"
|
10
|
-
@issuer = Stellar::KeyPair.from_address(@issuer_address)
|
11
|
-
@asset = Stellar::Asset.alphanum12("INDIUM", @issuer)
|
12
|
-
@mode = mode # test or prod
|
13
|
-
if mode == 'test'
|
14
|
-
@client = Stellar::Client.default_testnet
|
15
|
-
@horizon = "https://horizon-testnet.stellar.org"
|
16
|
-
elsif mode == 'prod'
|
17
|
-
@client = Stellar::Client.default
|
18
|
-
@horizon = "https://horizon.stellar.org"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def balances(pubkey)
|
23
|
-
resp = HTTParty.get(@horizon + "/accounts/" + pubkey)
|
24
|
-
JSON.parse(resp.body)["balances"].inject({}) do |f,h|
|
25
|
-
f.merge({ (h["asset_code"] || h["asset_type"]) => h["balance"] })
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def balances_direct(pubkey)
|
30
|
-
account = Stellar::Account.from_address(pubkey)
|
31
|
-
@client.account_info(account).balances.inject({}) do |f,h|
|
32
|
-
f.merge({ (h["asset_code"] || h["asset_type"]) => h["balance"] })
|
5
|
+
def initialize(node_url, chain_id)
|
6
|
+
Eth.configure do |config|
|
7
|
+
config.chain_id = chain_id # nil by default, meaning valid on any chain
|
33
8
|
end
|
9
|
+
@client = Ethereum::HttpClient.new(node_url)
|
34
10
|
end
|
35
11
|
|
36
|
-
def
|
37
|
-
|
38
|
-
recipient = Stellar::Account.from_address(receiver_pubkey)
|
39
|
-
|
40
|
-
@client.send_payment({
|
41
|
-
from: sender,
|
42
|
-
to: recipient,
|
43
|
-
amount: Stellar::Amount.new(amount)
|
44
|
-
})
|
12
|
+
def balance(pubkey)
|
13
|
+
@client.eth_get_balance(pubkey)
|
45
14
|
end
|
46
15
|
|
47
|
-
def transfer(amount,
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
@client.send_payment({
|
52
|
-
from: sender,
|
53
|
-
to: recipient,
|
54
|
-
amount: Stellar::Amount.new(amount, @asset)
|
55
|
-
})
|
16
|
+
def transfer(sender_privkey, receiver_pubkey, amount, hex_data, gas_limit = 21_000, gas_price = 3_141_592)
|
17
|
+
@client.gas_price = gas_price
|
18
|
+
@client.gas_limit = gas_limit
|
19
|
+
@client.transfer(sender_privkey, receiver_pubkey, amount) # transfer_and_wait ?
|
56
20
|
end
|
57
21
|
|
58
22
|
def create_indium_account(privkey)
|
59
|
-
|
60
|
-
|
23
|
+
kp = Eth::Key.new
|
24
|
+
return [kp.address, kp.private_hex]
|
25
|
+
end
|
61
26
|
|
62
|
-
|
63
|
-
|
64
|
-
asset: @asset
|
65
|
-
}) # create a trustline for Indium token
|
66
|
-
return [account.address, account.keypair.seed]
|
27
|
+
def self.local
|
28
|
+
self.new('http://localhost:8545',43391)
|
67
29
|
end
|
68
30
|
|
69
31
|
def self.test
|
70
|
-
self.new('
|
32
|
+
self.new('http://localhost:8545',43391)
|
71
33
|
end
|
72
34
|
|
73
35
|
def self.prod
|
74
|
-
|
36
|
+
raise "Indium production network is not yet live"
|
37
|
+
self.new('https://rpcnode.indium.network:8545',43391)
|
75
38
|
end
|
76
39
|
end
|
metadata
CHANGED
@@ -1,59 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: indium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nilesh Trivedi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: eth
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.4.6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.4.6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: ethereum.rb
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.1.8
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
|
42
|
-
name: json
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.1'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.1'
|
55
|
-
description: Library for querying/posting Indium transactions from Stellar test/main
|
56
|
-
network
|
40
|
+
version: 2.1.8
|
41
|
+
description: Library for querying/posting transactions from the Indium network
|
57
42
|
email: github@nileshtrivedi.com
|
58
43
|
executables: []
|
59
44
|
extensions: []
|