Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Fix: Allows timeout field to accept both uint64 and string durations #80

Merged
merged 5 commits into from
May 23, 2023

Conversation

boojamya
Copy link
Contributor

@boojamya boojamya commented May 19, 2023

Currently, the timeout field only works with time.duration types. So the example in the readme of using a time out of \"timeout\":\"10m\" does not work and causes the asset to get stuck on the middle chain.

Currently, if you want a 10 minute timeout you need to convert it to nanoseconds: \"timeout\": 600000000000.

This fixes the issue and allows users to use either a nanosecond uint64 OR a string format.

I've also confirmed this works using an interchaintest test case on noble chain. See lines 632
and 688 for both a uint64 version and a string version.

Once accepted, I can backport to v4, v5, v6, and main.

@@ -86,3 +89,28 @@ func (o JSONObject) MarshalJSON() ([]byte, error) {
// primitive, return raw bytes.
return o.primitive, nil
}

func (d Duration) MarshalJSON() ([]byte, error) {
return json.Marshal(time.Duration(d).String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should marshal to the nanoseconds value so it's backwards compatible with older PFM

@boojamya
Copy link
Contributor Author

Added logic to handle invalid unmarshalls.

router/ibc_middleware.go Outdated Show resolved Hide resolved
Co-authored-by: Andrew Gouin <andrew@gouin.io>
@boojamya boojamya self-assigned this May 22, 2023
@boojamya boojamya requested a review from agouin May 22, 2023 23:51
@boojamya boojamya merged commit d786894 into v3 May 23, 2023
@boojamya boojamya deleted the dan/timeoutV3 branch May 23, 2023 16:29
boojamya added a commit that referenced this pull request May 23, 2023
…80)

* timeout accetps both string and time.duration

* feedback

* handle invalid unmarshalls

* Update router/ibc_middleware.go

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* add test case for empty valid json

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
boojamya added a commit that referenced this pull request May 23, 2023
…80)

* timeout accetps both string and time.duration

* feedback

* handle invalid unmarshalls

* Update router/ibc_middleware.go

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* add test case for empty valid json

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
boojamya added a commit that referenced this pull request May 23, 2023
…80)

* timeout accetps both string and time.duration

* feedback

* handle invalid unmarshalls

* Update router/ibc_middleware.go

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* add test case for empty valid json

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
boojamya added a commit that referenced this pull request May 23, 2023
…80)

* timeout accetps both string and time.duration

* feedback

* handle invalid unmarshalls

* Update router/ibc_middleware.go

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* add test case for empty valid json

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
jackzampolin pushed a commit that referenced this pull request May 23, 2023
* Fix: Allows timeout field to accept both uint64 and string durations (#80)

* timeout accetps both string and time.duration

* feedback

* handle invalid unmarshalls

* Update router/ibc_middleware.go

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* add test case for empty valid json

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* timeout fix

* remove unused make command

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
jackzampolin pushed a commit that referenced this pull request May 23, 2023
* Fix same bool being used for all 3 (#81)

* fix: middleware panic upon receiving amount that is not int64; added test (#78)

resolves #77

* Fix: Allows timeout field to accept both uint64 and string durations (#80)

* timeout accetps both string and time.duration

* feedback

* handle invalid unmarshalls

* Update router/ibc_middleware.go

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* add test case for empty valid json

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* fix tests

* remove unused protos

* regen-protos

* fix lint

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
Co-authored-by: Max Kupriianov <max@kc.vc>
jackzampolin pushed a commit that referenced this pull request May 23, 2023
* Fix same bool being used for all 3 (#81)

* fix: middleware panic upon receiving amount that is not int64; added test (#78)

resolves #77

* Fix: Allows timeout field to accept both uint64 and string durations (#80)

* timeout accetps both string and time.duration

* feedback

* handle invalid unmarshalls

* Update router/ibc_middleware.go

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* add test case for empty valid json

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* fix for ibc-go version

* re gen protos

* remove unused make test command

* fix lint

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
Co-authored-by: Max Kupriianov <max@kc.vc>
jackzampolin pushed a commit that referenced this pull request May 23, 2023
* Fix same bool being used for all 3 (#81)

* fix: middleware panic upon receiving amount that is not int64; added test (#78)

resolves #77

* Fix: Allows timeout field to accept both uint64 and string durations (#80)

* timeout accetps both string and time.duration

* feedback

* handle invalid unmarshalls

* Update router/ibc_middleware.go

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* add test case for empty valid json

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>

* make compliant with ibc-go version and fix lint

* remove unused make test command

* regen protos

* add lint check to CI

---------

Co-authored-by: Andrew Gouin <andrew@gouin.io>
Co-authored-by: Max Kupriianov <max@kc.vc>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants