xrpl-ruby 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/core/base_x.rb +58 -0
- data/lib/core/core.rb +2 -0
- data/lib/xrpl-ruby.rb +3 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fe5e22e400d255c2c834133232433c9c8a513d3c1fba93dc06f46e18d90b1c3d
|
4
|
+
data.tar.gz: 0512e71a026bef8893fa8855c702ccdb09e18ce219f286c3cea33b2b5d477e38
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7b52d5c38ead6d5d5910cbd5132be7ea783e24b8c21f452d56138c9e806d016d9186d3213913372b3d5cb8d1c0bdca9c6acf8f7c9de1c5416571bf9d0873b2e
|
7
|
+
data.tar.gz: '00914805ec76c9fe7a2b475881efde3408f6f609f3ffaedc30d21fe845d3dd247051158561c29fe69af688238d4c86fb5a4124747c806bfe6a64f4c31a244020'
|
data/lib/core/base_x.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Core
|
2
|
+
class BaseX
|
3
|
+
def initialize(alphabet)
|
4
|
+
@alphabet = alphabet
|
5
|
+
@base = alphabet.length
|
6
|
+
@alphabet_map = {}
|
7
|
+
alphabet.chars.each_with_index { |char, index| @alphabet_map[char] = index }
|
8
|
+
end
|
9
|
+
|
10
|
+
def encode(buffer)
|
11
|
+
return @alphabet[0] if buffer.empty?
|
12
|
+
|
13
|
+
digits = [0]
|
14
|
+
buffer.each_byte do |byte|
|
15
|
+
carry = byte
|
16
|
+
digits.each_with_index do |digit, i|
|
17
|
+
carry += digit << 8
|
18
|
+
digits[i] = (carry % @base).to_i
|
19
|
+
carry = (carry / @base).abs.to_i
|
20
|
+
end
|
21
|
+
|
22
|
+
while carry > 0 do
|
23
|
+
digits << (carry % @base).to_i
|
24
|
+
carry = (carry / @base).abs.to_i
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
buffer.each_byte.take_while { |byte| byte == 0 }.each { digits << 0 }
|
29
|
+
digits.reverse.map { |digit| @alphabet[digit] }.join
|
30
|
+
end
|
31
|
+
|
32
|
+
def decode(string)
|
33
|
+
return '' if string.empty?
|
34
|
+
|
35
|
+
bytes = [0]
|
36
|
+
string.each_char do |char|
|
37
|
+
raise ArgumentError, "Invalid character found: #{char}" unless @alphabet_map.key?(char)
|
38
|
+
|
39
|
+
carry = @alphabet_map[char]
|
40
|
+
bytes.each_with_index do |byte, i|
|
41
|
+
carry += byte * @base
|
42
|
+
bytes[i] = carry & 0xff
|
43
|
+
carry >>= 8
|
44
|
+
end
|
45
|
+
|
46
|
+
while carry > 0 do
|
47
|
+
bytes << (carry & 0xff)
|
48
|
+
carry >>= 8
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
string.chars.take_while { |char| char == @alphabet[0] }.each { bytes << 0 }
|
53
|
+
bytes.reverse.pack('C*')
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
data/lib/core/core.rb
ADDED
data/lib/xrpl-ruby.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xrpl-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Busse
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: This gem provides a Ruby interface to interact with the XRP Ledger (XRPL)
|
56
|
+
blockchain, allowing developers to easily integrate XRPL functionality into their
|
57
|
+
Ruby applications.
|
58
|
+
email:
|
59
|
+
- dev@ledger-direct.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- lib/core/base_x.rb
|
65
|
+
- lib/core/core.rb
|
66
|
+
- lib/xrpl-ruby.rb
|
67
|
+
homepage: https://github.com/AlexanderBuzz/xrpl-ruby
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubygems_version: 3.3.7
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: A Ruby library to interact with the XRP Ledger (XRPL) blockchain
|
90
|
+
test_files: []
|