Skip to content

Commit 8863076

Browse files
authored
Merge pull request #1695 from SundaeSwap-finance/sg/cardano-updates
Update cardano connector integration
2 parents 296e796 + 4832786 commit 8863076

File tree

6 files changed

+73
-70
lines changed

6 files changed

+73
-70
lines changed

doc-site/docs/tutorials/custom_contracts/cardano.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ First, decide on the contract which your dApp will satisfy. FireFly uses [FireFl
101101
This is describing a contract with a single method, named `send_ada`. This method takes three parameters: a `fromAddress`, a `toAddress`, and an `amount`.
102102

103103
It also emits three events:
104+
104105
- `TransactionAccepted(string)` is emitted when the transaction is included in a block.
105106
- `TransactionRolledBack(string)` is emitted if the transaction was included in a block, and that block got rolled back. This happens maybe once or twice a day on the Cardano network, which is more likely than some other chains, so your code must be able to gracefully handle rollbacks.
106107
- `TransactionFinalized(string)` is emitted when the transaction has been on the chain for "long enough" that it is effectively immutable. It is up to your tolerance risk.
@@ -121,7 +122,7 @@ edition = "2021"
121122

122123
[dependencies]
123124
# The version of firefly-balius should match the version of firefly-cardano which you are using.
124-
firefly-balius = { git = "https://github.com/hyperledger/firefly-cardano", rev = "0.4.2" }
125+
firefly-balius = { git = "https://github.com/hyperledger/firefly-cardano", rev = "<firefly cardano version>" }
125126
pallas-addresses = "0.32"
126127
serde = { version = "1", features = ["derive"] }
127128

@@ -236,14 +237,15 @@ fn main() -> Worker {
236237

237238
You can use the `firefly-cardano-deploy` tool to deploy this dApp to your running FireFly instance.
238239
This tool will
240+
239241
- Compile your dApp to WebAssembly
240242
- Deploy that WebAssembly to a running FireFly node
241243
- Deploy your interface to that FireFly node
242244
- Create an API for that interface
243245

244246
```sh
245247
# The version here should match the version of firefly-cardano which you are using.
246-
cargo install --git https://github.com/hyperledger/firefly-cardano --version 0.3.1 firefly-cardano-deploy
248+
cargo install --git https://github.com/hyperledger/firefly-cardano --version <firefly cardano version> firefly-cardano-deploy
247249

248250
CONTRACT_PATH="/path/to/your/dapp"
249251
FIREFLY_URL="http://localhost:5000"
@@ -272,7 +274,8 @@ Now that we've set everything up, let's prove it works by sending 1 ADA back to
272274
"fromAddress": "<wallet address you set up before>",
273275
"toAddress": "addr_test1vqeux7xwusdju9dvsj8h7mca9aup2k439kfmwy773xxc2hcu7zy99",
274276
"amount": 1000000
275-
}
277+
},
278+
"key": "<wallet address you set up before>"
276279
}
277280
```
278281

internal/blockchain/cardano/cardano.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (c *Cardano) Init(ctx context.Context, cancelCtx context.CancelFunc, conf c
111111
}
112112

113113
if c.wsConfig.WSKeyPath == "" {
114-
c.wsConfig.WSKeyPath = "/ws"
114+
c.wsConfig.WSKeyPath = "/api/v1/ws"
115115
}
116116

117117
c.streamIDs = make(map[string]string)
@@ -243,7 +243,7 @@ func (c *Cardano) DeployContract(ctx context.Context, nsOpID, signingKey string,
243243
SetContext(ctx).
244244
SetBody(body).
245245
SetError(&resErr).
246-
Post("/contracts/deploy")
246+
Post("/api/v1/contracts/deploy")
247247
if err != nil || !res.IsSuccess() {
248248
return resErr.SubmissionRejected, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgCardanoconnectRESTErr)
249249
}
@@ -287,7 +287,7 @@ func (c *Cardano) InvokeContract(ctx context.Context, nsOpID string, signingKey
287287
SetContext(ctx).
288288
SetBody(body).
289289
SetError(&resErr).
290-
Post("/contracts/invoke")
290+
Post("/api/v1/contracts/invoke")
291291
if err != nil || !res.IsSuccess() {
292292
return resErr.SubmissionRejected, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgCardanoconnectRESTErr)
293293
}
@@ -324,7 +324,7 @@ func (c *Cardano) QueryContract(ctx context.Context, signingKey string, location
324324
SetContext(ctx).
325325
SetBody(body).
326326
SetError(&resErr).
327-
Post("/contracts/query")
327+
Post("/api/v1/contracts/query")
328328
if err != nil || !res.IsSuccess() {
329329
return nil, common.WrapRESTError(ctx, &resErr, res, err, coremsgs.MsgCardanoconnectRESTErr)
330330
}
@@ -488,7 +488,7 @@ func (c *Cardano) GetAndConvertDeprecatedContractConfig(ctx context.Context) (lo
488488
func (c *Cardano) GetTransactionStatus(ctx context.Context, operation *core.Operation) (interface{}, error) {
489489
txnID := (&core.PreparedOperation{ID: operation.ID, Namespace: operation.Namespace}).NamespacedIDString()
490490

491-
transactionRequestPath := fmt.Sprintf("/transactions/%s", txnID)
491+
transactionRequestPath := fmt.Sprintf("/api/v1/transactions/%s", txnID)
492492
client := c.client
493493
var resErr common.BlockchainRESTError
494494
var statusResponse fftypes.JSONObject

0 commit comments

Comments
 (0)