-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from multiversx/esdt-construction-01
Implement construction of ESDT transfers (2)
- Loading branch information
Showing
32 changed files
with
831 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/multiversx/mx-chain-rosetta/server/resources" | ||
) | ||
|
||
func loadConfigOfCustomCurrencies(configFile string) ([]resources.Currency, error) { | ||
fileContent, err := os.ReadFile(configFile) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var customCurrencies []resources.Currency | ||
|
||
err = json.Unmarshal(fileContent, &customCurrencies) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return customCurrencies, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/multiversx/mx-chain-rosetta/server/resources" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestLoadConfigOfCustomCurrencies(t *testing.T) { | ||
t.Run("with success", func(t *testing.T) { | ||
customCurrencies, err := loadConfigOfCustomCurrencies("testdata/custom-currencies.json") | ||
require.NoError(t, err) | ||
require.NoError(t, err) | ||
require.Equal(t, []resources.Currency{ | ||
{ | ||
Symbol: "WEGLD-bd4d79", | ||
Decimals: 18, | ||
}, | ||
{ | ||
Symbol: "USDC-c76f1f", | ||
Decimals: 6, | ||
}, | ||
}, customCurrencies) | ||
}) | ||
|
||
t.Run("with error (missing file)", func(t *testing.T) { | ||
_, err := loadConfigOfCustomCurrencies("testdata/missing-file.json") | ||
require.Error(t, err) | ||
}) | ||
|
||
t.Run("with error (invalid file)", func(t *testing.T) { | ||
_, err := loadConfigOfCustomCurrencies("testdata/custom-currencies-bad.json") | ||
require.Error(t, err) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"symbol": "WEGLD-bd4d79", | ||
"decimals": 18 | ||
}, | ||
{ | ||
"symbol": "USDC-c76f1f", | ||
"decimals": 6 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.