Skip to content

Commit a050481

Browse files
committed
Merge remote-tracking branch 'remotes/origin/fierce_fermion_6.0RC' into testnet
2 parents 8256505 + 7af3485 commit a050481

File tree

8 files changed

+94
-16
lines changed

8 files changed

+94
-16
lines changed

.github/workflows/boost_build.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
path: ${{runner.workspace}}\boost_prebuild
3939
if-no-files-found: error
4040

41-
4241
build_ubuntu:
4342
runs-on: ${{ matrix.os }}
4443
strategy:
@@ -89,3 +88,47 @@ jobs:
8988
name: boost_prebuild_${{matrix.os}}
9089
path: ${{runner.workspace}}/boost_prebuild
9190
if-no-files-found: error
91+
92+
build_osx:
93+
runs-on: macos-10.15
94+
steps:
95+
- name: Create Build Environment
96+
shell: bash
97+
run: |
98+
mkdir ${{runner.workspace}}/boost_prebuild
99+
100+
- name: Download
101+
shell: bash
102+
run: |
103+
wget -q https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.gz
104+
tar -xvf boost_1_75_0.tar.gz > /dev/null
105+
mv ./boost_1_75_0 ${{runner.workspace}}/boost
106+
107+
- name: Bootstrap
108+
shell: bash
109+
run: |
110+
cd ${{runner.workspace}}/boost
111+
./bootstrap.sh
112+
113+
- name: Build
114+
shell: bash
115+
run: |
116+
cd ${{runner.workspace}}/boost
117+
./b2 --target=static
118+
119+
- name: Install
120+
shell: bash
121+
run: |
122+
cd ${{runner.workspace}}/boost
123+
./b2 install --prefix=${{runner.workspace}}/boost_prebuild
124+
125+
- name: Pack
126+
shell: bash
127+
run:
128+
tar -zcvf boost_prebuild.tar.gz ${{runner.workspace}}/boost_prebuild
129+
130+
- uses: actions/upload-artifact@v2
131+
with:
132+
name: boost_prebuild_macos-10.15
133+
path: boost_prebuild.tar.gz
134+
if-no-files-found: error

.github/workflows/build.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,29 @@ jobs:
5151
run: |
5252
git clone --depth=1 https://github.com/BeamMW/libs.git c:/beam-libs
5353
echo "OPENSSL_ROOT_DIR=c:\beam-libs\openssl" >> $GITHUB_ENV
54-
git clone --depth=1 https://github.com/BeamMW/boost_prebuild_${{matrix.os}}.git c:/boost_prebuild
55-
echo "BOOST_ROOT=c:\boost_prebuild" >> $GITHUB_ENV
5654
55+
- name: Download boost
56+
shell: bash
57+
run: |
58+
git clone --depth=1 https://github.com/BeamMW/boost_prebuild_${{matrix.os}}.git ${{runner.workspace}}/boost_prebuild
5759
58-
- name: Download boost [macos-10.15]
59-
if: matrix.os == 'macos-10.15'
60+
- name: Configure boost path [windows]
61+
shell: bash
62+
if: matrix.os == 'windows-2019'
6063
run: |
61-
brew update
62-
brew install boost
63-
echo "LDFLAGS=-L/usr/local/opt/icu4c/lib" >> $GITHUB_ENV
64-
echo "CPPFLAGS=-I/usr/local/opt/icu4c/include" >> $GITHUB_ENV
64+
echo "BOOST_ROOT=${{runner.workspace}}/boost_prebuild" >> $GITHUB_ENV
6565
66-
- name: Download boost [ununtu all]
66+
- name: Configure boost path [ununtu all]
6767
shell: bash
6868
if: matrix.os == 'ubuntu-16.04' || matrix.os == 'ubuntu-18.04' || matrix.os == 'ubuntu-20.04'
6969
run: |
70-
git clone --depth=1 https://github.com/BeamMW/boost_prebuild_${{matrix.os}}.git ${{runner.workspace}}/boost_prebuild
70+
echo "BOOST_INCLUDEDIR=${{runner.workspace}}/boost_prebuild/include" >> $GITHUB_ENV
71+
echo "BOOST_LIBRARYDIR=${{runner.workspace}}/boost_prebuild/lib/" >> $GITHUB_ENV
72+
73+
- name: Configure boost path [macos-10.15]
74+
shell: bash
75+
if: matrix.os == 'macos-10.15'
76+
run: |
7177
echo "BOOST_INCLUDEDIR=${{runner.workspace}}/boost_prebuild/include" >> $GITHUB_ENV
7278
echo "BOOST_LIBRARYDIR=${{runner.workspace}}/boost_prebuild/lib/" >> $GITHUB_ENV
7379

wallet/api/v6_0/wallet_api.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,10 @@ namespace beam::wallet
8383
throw jsonrpc_exception(code, errmsg);
8484
}
8585
}
86+
87+
std::string WalletApi::getTokenType(TokenType type) const
88+
{
89+
auto it = _ttypesMap.find(type);
90+
return it != _ttypesMap.end() ? it->second : "unknown";
91+
}
8692
}

wallet/api/v6_0/wallet_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ namespace beam::wallet
145145

146146
virtual void OnComplete(proto::FlyClient::Request&) override;
147147

148+
std::string getTokenType(TokenType type) const;
149+
148150
protected:
149151
// Do not access these directly, use getters
150152
IWalletDB::Ptr _wdb;

wallet/api/v6_0/wallet_api_defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ namespace beam::wallet
148148
{
149149
bool isValid;
150150
bool isMine;
151+
TokenType type = TokenType::Unknown;
152+
boost::optional<size_t> payments;
151153
};
152154
};
153155

wallet/api/v6_0/wallet_api_handle.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,14 @@ namespace beam::wallet
205205
{
206206
LOG_DEBUG() << "ValidateAddress( address = " << data.token << ")";
207207

208+
209+
auto tokenType = GetTokenType(data.token);
210+
208211
auto p = ParseParameters(data.token);
209212

210213
bool isValid = !!p;
211214
bool isMine = false;
215+
boost::optional<size_t> offlinePayments;
212216

213217
if (p)
214218
{
@@ -226,11 +230,19 @@ namespace beam::wallet
226230
{
227231
isValid = isValid && !addr->isExpired();
228232
}
233+
if (tokenType == TokenType::Offline)
234+
{
235+
if (auto vouchers = p->GetParameter<ShieldedVoucherList>(TxParameterID::ShieldedVoucherList); vouchers)
236+
{
237+
storage::SaveVouchers(*walletDB, *vouchers, *v);
238+
}
239+
offlinePayments = walletDB->getVoucherCount(*v);
240+
}
229241
}
230242
}
231243
}
232244

233-
doResponse(id, ValidateAddress::Response{ isValid, isMine });
245+
doResponse(id, ValidateAddress::Response{ isValid, isMine, tokenType, offlinePayments });
234246
}
235247

236248
void WalletApi::doTxAlreadyExistsError(const JsonRpcId& id)

wallet/api/v6_0/wallet_api_parse.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,6 @@ namespace beam::wallet
989989
for (auto& addr : res.list)
990990
{
991991
auto type = GetTokenType(addr.m_Address);
992-
auto it = _ttypesMap.find(type);
993-
994992
msg["result"].push_back(
995993
{
996994
{"address", addr.m_Address},
@@ -1003,7 +1001,7 @@ namespace beam::wallet
10031001
{"own_id", addr.m_OwnID},
10041002
{"own_id_str", std::to_string(addr.m_OwnID)},
10051003
{"wallet_id", std::to_string(addr.m_walletID)},
1006-
{"type", it != _ttypesMap.end() ? it->second : "unknown"}
1004+
{"type", getTokenType(type)}
10071005
});
10081006

10091007
if (addr.m_Identity != Zero)
@@ -1022,10 +1020,15 @@ namespace beam::wallet
10221020
{"result",
10231021
{
10241022
{"is_valid", res.isValid},
1025-
{"is_mine", res.isMine},
1023+
{"is_mine", res.isMine},
1024+
{"type", getTokenType(res.type)}
10261025
}
10271026
}
10281027
};
1028+
if (res.payments)
1029+
{
1030+
msg["result"]["payments"] = *res.payments;
1031+
}
10291032
}
10301033

10311034
void WalletApi::getResponse(const JsonRpcId& id, const GetUtxo::Response& res, json& msg)

wallet/unittests/wallet_api_test.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,17 @@ namespace
650650

651651
validateResponce.isMine = true;
652652
validateResponce.isValid = valid;
653+
validateResponce.type = TokenType::Offline;
654+
validateResponce.payments = 12;
653655

654656
api.getResponse(123, validateResponce, res);
655657
testResultHeader(res);
656658

657659
WALLET_CHECK(res["id"] == 123);
658660
WALLET_CHECK(res["result"]["is_mine"] == true);
659661
WALLET_CHECK(res["result"]["is_valid"] == valid);
662+
WALLET_CHECK(res["result"]["type"] == "offline");
663+
WALLET_CHECK(res["result"]["payments"] == 12);
660664
}
661665
}
662666

0 commit comments

Comments
 (0)