Skip to content

Commit 85ecf49

Browse files
authored
Merge pull request #280 from timewave-computer/backport-features-to-0.1.1
Backport ibc-transfer libraries and program-registry changes
2 parents 5724521 + 27b8511 commit 85ecf49

23 files changed

+244
-200
lines changed

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contracts/libraries/generic-ibc-transfer/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct LibraryConfig {
3737
// Account from which the funds are pulled (on the source chain)
3838
input_addr: LibraryAccountType,
3939
// Account to which the funds are sent (on the destination chain)
40-
output_addr: String,
40+
output_addr: LibraryAccountType,
4141
// Denom of the token to transfer
4242
denom: UncheckedDenom,
4343
// Amount to be transferred, either a fixed amount or the whole available balance.

contracts/libraries/generic-ibc-transfer/schema/valence-generic-ibc-transfer-library.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"type": "string"
121121
},
122122
"output_addr": {
123-
"type": "string"
123+
"$ref": "#/definitions/LibraryAccountType"
124124
},
125125
"remote_chain_info": {
126126
"$ref": "#/definitions/RemoteChainInfo"
@@ -513,9 +513,13 @@
513513
]
514514
},
515515
"output_addr": {
516-
"type": [
517-
"string",
518-
"null"
516+
"anyOf": [
517+
{
518+
"$ref": "#/definitions/LibraryAccountType"
519+
},
520+
{
521+
"type": "null"
522+
}
519523
]
520524
},
521525
"remote_chain_info": {
@@ -718,7 +722,7 @@
718722
"type": "string"
719723
},
720724
"output_addr": {
721-
"$ref": "#/definitions/Addr"
725+
"type": "string"
722726
},
723727
"remote_chain_info": {
724728
"$ref": "#/definitions/RemoteChainInfo"
@@ -872,7 +876,7 @@
872876
"type": "string"
873877
},
874878
"output_addr": {
875-
"type": "string"
879+
"$ref": "#/definitions/LibraryAccountType"
876880
},
877881
"remote_chain_info": {
878882
"$ref": "#/definitions/RemoteChainInfo"

contracts/libraries/generic-ibc-transfer/src/msg.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub enum QueryMsg {}
2929
#[derive(ValenceLibraryInterface)]
3030
pub struct LibraryConfig {
3131
pub input_addr: LibraryAccountType,
32-
pub output_addr: String,
32+
pub output_addr: LibraryAccountType,
3333
pub denom: UncheckedDenom,
3434
pub amount: IbcTransferAmount,
3535
pub memo: String,
@@ -61,7 +61,7 @@ impl RemoteChainInfo {
6161
impl LibraryConfig {
6262
pub fn new(
6363
input_addr: LibraryAccountType,
64-
output_addr: String,
64+
output_addr: LibraryAccountType,
6565
denom: UncheckedDenom,
6666
amount: IbcTransferAmount,
6767
memo: String,
@@ -80,7 +80,7 @@ impl LibraryConfig {
8080

8181
pub fn with_pfm_map(
8282
input_addr: LibraryAccountType,
83-
output_addr: String,
83+
output_addr: LibraryAccountType,
8484
denom: UncheckedDenom,
8585
amount: IbcTransferAmount,
8686
memo: String,
@@ -143,7 +143,7 @@ impl LibraryConfigValidation<Config> for LibraryConfig {
143143
Ok(Config {
144144
input_addr,
145145
// Can't validate output address as it's on another chain
146-
output_addr: Addr::unchecked(self.output_addr.clone()),
146+
output_addr: self.output_addr.to_string()?,
147147
denom: self
148148
.denom
149149
.clone()
@@ -169,7 +169,7 @@ impl LibraryConfigUpdate {
169169
}
170170

171171
if let Some(output_addr) = self.output_addr {
172-
config.output_addr = Addr::unchecked(output_addr);
172+
config.output_addr = output_addr.to_string()?;
173173
}
174174

175175
if let Some(denom) = self.denom {
@@ -224,7 +224,7 @@ pub struct Config {
224224
#[getset(get = "pub", set)]
225225
input_addr: Addr,
226226
#[getset(get = "pub", set)]
227-
output_addr: Addr,
227+
output_addr: String,
228228
#[getset(get = "pub", set)]
229229
denom: CheckedDenom,
230230
#[getset(get = "pub", set)]
@@ -240,7 +240,7 @@ pub struct Config {
240240
impl Config {
241241
pub fn new(
242242
input_addr: Addr,
243-
output_addr: Addr,
243+
output_addr: String,
244244
denom: CheckedDenom,
245245
amount: IbcTransferAmount,
246246
memo: String,
@@ -259,7 +259,7 @@ impl Config {
259259

260260
pub fn with_pfm_map(
261261
input_addr: Addr,
262-
output_addr: Addr,
262+
output_addr: String,
263263
denom: CheckedDenom,
264264
amount: IbcTransferAmount,
265265
memo: String,

contracts/libraries/generic-ibc-transfer/src/tests.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ struct IbcTransferTestSuite {
2424
#[getset(get)]
2525
input_addr: Addr,
2626
#[getset(get)]
27-
output_addr: Addr,
27+
output_addr: String,
2828
#[getset(get)]
2929
input_balance: Option<(u128, String)>,
3030
}
@@ -41,7 +41,7 @@ impl IbcTransferTestSuite {
4141
let mut inner = LibraryTestSuiteBase::new();
4242

4343
let input_addr = inner.get_contract_addr(inner.account_code_id(), "input_account");
44-
let output_addr = inner.api().addr_make("output_account");
44+
let output_addr = inner.api().addr_make("output_account").to_string();
4545

4646
// Template contract
4747
let ibc_transfer_code = ContractWrapper::new(
@@ -96,7 +96,7 @@ impl IbcTransferTestSuite {
9696
) -> LibraryConfig {
9797
LibraryConfig::new(
9898
valence_library_utils::LibraryAccountType::Addr(self.input_addr().to_string()),
99-
self.output_addr().to_string(),
99+
valence_library_utils::LibraryAccountType::Addr(self.output_addr().to_string()),
100100
valence_library_utils::denoms::UncheckedDenom::Native(denom),
101101
amount,
102102
memo,
@@ -343,7 +343,7 @@ fn update_config_with_valid_config() {
343343

344344
// Update config: swap input and output addresses
345345
cfg.input_addr = LibraryAccountType::Addr(suite.output_addr().to_string());
346-
cfg.output_addr = suite.input_addr().to_string();
346+
cfg.output_addr = LibraryAccountType::Addr(suite.input_addr().to_string());
347347
cfg.amount = IbcTransferAmount::FixedAmount(ONE_MILLION.into());
348348
cfg.memo = "Chancellor on brink of second bailout for banks.".to_string();
349349

@@ -355,8 +355,8 @@ fn update_config_with_valid_config() {
355355
assert_eq!(
356356
lib_cfg,
357357
Config::new(
358-
suite.output_addr().clone(),
359-
suite.input_addr().clone(),
358+
Addr::unchecked(suite.output_addr().clone()),
359+
suite.input_addr().clone().to_string(),
360360
CheckedDenom::Native(NTRN.into()),
361361
IbcTransferAmount::FixedAmount(ONE_MILLION.into()),
362362
"Chancellor on brink of second bailout for banks.".to_string(),

contracts/libraries/neutron-ibc-transfer/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct LibraryConfig {
3737
// Account from which the funds are pulled (on the source chain)
3838
input_addr: LibraryAccountType,
3939
// Account to which the funds are sent (on the destination chain)
40-
output_addr: String,
40+
output_addr: LibraryAccountType,
4141
// Denom of the token to transfer
4242
denom: UncheckedDenom,
4343
// Amount to be transferred, either a fixed amount or the whole available balance.

contracts/libraries/neutron-ibc-transfer/schema/valence-neutron-ibc-transfer-library.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"type": "string"
121121
},
122122
"output_addr": {
123-
"type": "string"
123+
"$ref": "#/definitions/LibraryAccountType"
124124
},
125125
"remote_chain_info": {
126126
"$ref": "#/definitions/RemoteChainInfo"
@@ -513,9 +513,13 @@
513513
]
514514
},
515515
"output_addr": {
516-
"type": [
517-
"string",
518-
"null"
516+
"anyOf": [
517+
{
518+
"$ref": "#/definitions/LibraryAccountType"
519+
},
520+
{
521+
"type": "null"
522+
}
519523
]
520524
},
521525
"remote_chain_info": {
@@ -718,7 +722,7 @@
718722
"type": "string"
719723
},
720724
"output_addr": {
721-
"$ref": "#/definitions/Addr"
725+
"type": "string"
722726
},
723727
"remote_chain_info": {
724728
"$ref": "#/definitions/RemoteChainInfo"
@@ -872,7 +876,7 @@
872876
"type": "string"
873877
},
874878
"output_addr": {
875-
"type": "string"
879+
"$ref": "#/definitions/LibraryAccountType"
876880
},
877881
"remote_chain_info": {
878882
"$ref": "#/definitions/RemoteChainInfo"

contracts/libraries/neutron-ibc-transfer/src/tests.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct IbcTransferTestSuite {
3636
#[getset(get)]
3737
input_addr: Addr,
3838
#[getset(get)]
39-
output_addr: Addr,
39+
output_addr: String,
4040
#[getset(get)]
4141
input_balance: Option<(u128, String)>,
4242
}
@@ -56,7 +56,7 @@ impl IbcTransferTestSuite {
5656
let mut inner = CustomLibraryTestSuiteBase::new(app);
5757

5858
let input_addr = inner.get_contract_addr(inner.account_code_id(), "input_account");
59-
let output_addr = inner.api().addr_make("output_account");
59+
let output_addr = inner.api().addr_make("output_account").to_string();
6060

6161
// Template contract
6262
let ibc_transfer_code = ContractWrapper::new(
@@ -111,7 +111,7 @@ impl IbcTransferTestSuite {
111111
) -> LibraryConfig {
112112
LibraryConfig::new(
113113
valence_library_utils::LibraryAccountType::Addr(self.input_addr().to_string()),
114-
self.output_addr().to_string(),
114+
valence_library_utils::LibraryAccountType::Addr(self.output_addr().to_string()),
115115
valence_library_utils::denoms::UncheckedDenom::Native(denom),
116116
amount,
117117
memo,
@@ -388,7 +388,7 @@ fn update_config_with_valid_config() {
388388

389389
// Update config: swap input and output addresses
390390
cfg.input_addr = LibraryAccountType::Addr(suite.output_addr().to_string());
391-
cfg.output_addr = suite.input_addr().to_string();
391+
cfg.output_addr = LibraryAccountType::Addr(suite.input_addr().to_string());
392392
cfg.amount = IbcTransferAmount::FixedAmount(ONE_MILLION.into());
393393
cfg.memo = "Chancellor on brink of second bailout for banks.".to_string();
394394

@@ -400,8 +400,8 @@ fn update_config_with_valid_config() {
400400
assert_eq!(
401401
lib_cfg,
402402
Config::new(
403-
suite.output_addr().clone(),
404-
suite.input_addr().clone(),
403+
Addr::unchecked(suite.output_addr().clone()),
404+
suite.input_addr().clone().to_string(),
405405
CheckedDenom::Native(NTRN.into()),
406406
IbcTransferAmount::FixedAmount(ONE_MILLION.into()),
407407
"Chancellor on brink of second bailout for banks.".to_string(),

0 commit comments

Comments
 (0)