gl_wallet 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 +7 -0
- data/lib/gl_wallet.rb +67 -0
- metadata +58 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 19bad04ca3eda6b5cbb88e50bae03b8f022e25f9a175dd6c5d3b872bf3227079
|
|
4
|
+
data.tar.gz: 5cddc389d63822cb71df364440e9ea73532b9eb7b0c197a7c5e8d341eafdaa55
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ea51709cb5db3013774984c84c48f49bce41f86e31a70daf0ca6f0b90c55e56bb86169a641461953891c329db7da723b4ccaf54d2ead8a3575052b39b5ad2f53
|
|
7
|
+
data.tar.gz: 1e13d91831993826a93820c5a44fcdb5accc431c384f0d95fecfef9832e917e90cde7c25e3473fc416bfa9458f9b5afbd7705700fd21f5b046c1e7dd111a384d
|
data/lib/gl_wallet.rb
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'json'
|
|
3
|
+
|
|
4
|
+
class GlWallet
|
|
5
|
+
attr_accessor :network, :is_mainnet, :secret, :url
|
|
6
|
+
|
|
7
|
+
def initialize(network, is_mainnet, secret, url)
|
|
8
|
+
self.network = network
|
|
9
|
+
self.is_mainnet = is_mainnet
|
|
10
|
+
self.secret = secret
|
|
11
|
+
self.url = url
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def authenticate
|
|
15
|
+
user_id = self.secret # Replace with the actual user ID
|
|
16
|
+
|
|
17
|
+
# Create a Hash with the request body for token generation
|
|
18
|
+
token_generation_payload = {
|
|
19
|
+
'userId' => user_id
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# Make the POST request for token generation
|
|
23
|
+
token_url = URI("#{self.url}/api/v1/genarateTokens")
|
|
24
|
+
token_generation_request = Net::HTTP::Post.new(token_url, {'Content-Type' => 'application/json'})
|
|
25
|
+
token_generation_request.body = token_generation_payload.to_json
|
|
26
|
+
|
|
27
|
+
token_generation_response = Net::HTTP.start(token_url.hostname, token_url.port) do |http|
|
|
28
|
+
http.request(token_generation_request)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
jwt_token = JSON.parse(token_generation_response.body)['data']['token']
|
|
32
|
+
|
|
33
|
+
puts "JWT Token #{jwt_token}"
|
|
34
|
+
jwt_token
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def create_bulk_accounts(n = 50)
|
|
38
|
+
token = authenticate
|
|
39
|
+
create_bulk_account_url = URI("#{self.url}/api/v1/account/createBulk")
|
|
40
|
+
# Headers for JSON content and authorization
|
|
41
|
+
headers = {
|
|
42
|
+
'Content-Type' => 'application/json',
|
|
43
|
+
'Authorization' => "Bearer #{token}" # Replace YOUR_JWT_TOKEN with your actual JWT token
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# Create a Hash with the request body for creating bulk accounts
|
|
47
|
+
create_bulk_payload = {
|
|
48
|
+
'network' => self.network,
|
|
49
|
+
'isMainnet' => self.is_mainnet,
|
|
50
|
+
'n' => n
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Make the POST request for creating bulk accounts
|
|
54
|
+
create_bulk_request = Net::HTTP::Post.new(create_bulk_account_url, headers)
|
|
55
|
+
create_bulk_request.body = create_bulk_payload.to_json
|
|
56
|
+
|
|
57
|
+
create_bulk_response = Net::HTTP.start(create_bulk_account_url.hostname, create_bulk_account_url.port) do |http|
|
|
58
|
+
http.request(create_bulk_request)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
puts "Create Bulk Account Response Code: #{create_bulk_response.code}"
|
|
62
|
+
puts "Create Bulk Account Response Body: #{create_bulk_response.body}"
|
|
63
|
+
|
|
64
|
+
JSON.parse(create_bulk_response.body).dig("data")
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
metadata
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: gl_wallet
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Manoj Kumar
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-10-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: json
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: A Ruby gem for wrapping GLWallet API calls.
|
|
28
|
+
email:
|
|
29
|
+
- manoj_kumar@example.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- lib/gl_wallet.rb
|
|
35
|
+
homepage: https://github.com/manoj_kumar/gl_wallet
|
|
36
|
+
licenses:
|
|
37
|
+
- MIT
|
|
38
|
+
metadata: {}
|
|
39
|
+
post_install_message:
|
|
40
|
+
rdoc_options: []
|
|
41
|
+
require_paths:
|
|
42
|
+
- lib
|
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.7'
|
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
requirements: []
|
|
54
|
+
rubygems_version: 3.1.6
|
|
55
|
+
signing_key:
|
|
56
|
+
specification_version: 4
|
|
57
|
+
summary: A Ruby gem for GLWallet API wrapper.
|
|
58
|
+
test_files: []
|