Skip to content

Commit 81ad7bf

Browse files
committed
Updated request for Post to send a minimum of 1 iota.
1 parent 87508e5 commit 81ad7bf

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

requestmanager/requestmanager.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func New(env *solo.Solo) *RequestManager {
1919
return requestManager
2020
}
2121

22-
// Post creates a request as requester or, if not specified, as the chain originator. The contract function in the chain is called with optional params.
22+
// Post creates a request as requester or, if not specified, as the chain originator. 1 IOTA is necessary to process the request.
23+
// The contract function in the chain is called with optional params.
2324
// Returns response as a Dict or an error.
2425
func (requestManager *RequestManager) Post(requesterKeyPair *ed25519.KeyPair, chain *solo.Chain, contractName string,
2526
functionName string, params ...interface{}) (dict.Dict, error) {
@@ -29,39 +30,40 @@ func (requestManager *RequestManager) Post(requesterKeyPair *ed25519.KeyPair, ch
2930

3031
// PostWithTransfer creates a request as requester or, if not specified, as the chain originator. The contract function in the chain is called with optional params.
3132
// It attaches 'amount' of 'color' to call. Returns response as a Dict or an error.
32-
func (requestManager *RequestManager) PostWithTransfer(requesterKeyPair *ed25519.KeyPair,
33-
color colored.Color, amount uint64,
34-
chain *solo.Chain, contractName string,
35-
functionName string, params ...interface{}) (dict.Dict, error) {
33+
func (requestManager *RequestManager) PostWithTransfer(requesterKeyPair *ed25519.KeyPair, color colored.Color, amount uint64,
34+
chain *solo.Chain, contractName string, functionName string, params ...interface{}) (dict.Dict, error) {
3635
response, err := post(true, color, amount, requesterKeyPair, chain, contractName, functionName, params...)
3736
return response, err
3837
}
3938

39+
// 1 IOTA is necessary to process the request if 'withTransfer' is 'false'.
4040
func post(withTransfer bool, color colored.Color, amount uint64,
4141
requesterKeyPair *ed25519.KeyPair, chain *solo.Chain, contractName string,
4242
functionName string, params ...interface{}) (dict.Dict, error) {
4343
request := solo.NewCallParams(contractName, functionName, params...)
4444
if withTransfer {
4545
request = request.WithTransfer(color, amount)
46+
} else {
47+
request = request.WithTransfer(colored.IOTA, uint64(1))
4648
}
4749
response, err := chain.PostRequestSync(request, requesterKeyPair)
4850
return response, err
4951
}
5052

51-
// MustPost creates a request to contract function in the chain as requester. Fails test if request fails.
53+
// MustPost creates a request to contract function in the chain as requester.
54+
// 1 IOTA is necessary to process the request.
55+
// Fails test if request fails.
5256
func (requestManager *RequestManager) MustPost(requesterKeyPair *ed25519.KeyPair, chain *solo.Chain, contractName string,
5357
functionName string, params ...interface{}) dict.Dict {
54-
response, err := requestManager.Post(requesterKeyPair, chain, contractName, functionName, params...)
58+
response, err := requestManager.PostWithTransfer(requesterKeyPair, colored.IOTA, 1, chain, contractName, functionName, params...)
5559
require.NoError(requestManager.env.T, err)
5660
return response
5761
}
5862

5963
// MustPostWithTransfer creates a request to contract function in the chain as requester.
6064
// It attaches 'amount' of 'color' to call. Fails test if request fails.
61-
func (requestManager *RequestManager) MustPostWithTransfer(requesterKeyPair *ed25519.KeyPair,
62-
color colored.Color, amount uint64,
63-
chain *solo.Chain, contractName string,
64-
functionName string, params ...interface{}) dict.Dict {
65+
func (requestManager *RequestManager) MustPostWithTransfer(requesterKeyPair *ed25519.KeyPair, color colored.Color, amount uint64,
66+
chain *solo.Chain, contractName string, functionName string, params ...interface{}) dict.Dict {
6567
response, err := requestManager.PostWithTransfer(requesterKeyPair, color, amount, chain, contractName, functionName, params...)
6668
require.NoError(requestManager.env.T, err)
6769
return response

0 commit comments

Comments
 (0)