Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.15.2
github.com/cloudevents/sdk-go/v2 v2.16.0
github.com/dominikbraun/graph v0.23.0
github.com/ethereum/go-ethereum v1.15.3
github.com/fxamacker/cbor/v2 v2.5.0
github.com/go-json-experiment/json v0.0.0-20231102232822-2e55bd4e08b0
github.com/go-playground/validator/v10 v10.4.1
Expand Down Expand Up @@ -60,7 +61,7 @@ require (
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.36.0
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/tools v0.26.0
golang.org/x/tools v0.29.0
gonum.org/v1/gonum v0.15.1
google.golang.org/grpc v1.72.0
google.golang.org/protobuf v1.36.6
Expand All @@ -69,26 +70,41 @@ require (
)

require (
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/apache/arrow-go/v18 v18.0.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.17.0 // indirect
github.com/bufbuild/protocompile v0.14.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/consensys/bavard v0.1.22 // indirect
github.com/consensys/gnark-crypto v0.14.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
github.com/ethereum/go-verkle v0.2.2 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/goccy/go-json v0.10.4 // indirect
github.com/goccy/go-yaml v1.12.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/holiman/uint256 v1.3.2 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.3 // indirect
github.com/jackc/pgio v1.0.0 // indirect
Expand All @@ -105,6 +121,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
Expand All @@ -117,8 +134,12 @@ require (
github.com/prometheus/common v0.63.0 // indirect
github.com/prometheus/procfs v0.16.0 // indirect
github.com/sanity-io/litter v1.5.5 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/smartcontractkit/chainlink-protos/workflows/go v0.0.0-20250430163438-97d324ef9061 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.14 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
Expand All @@ -134,4 +155,5 @@ require (
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)
140 changes: 134 additions & 6 deletions go.sum

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions pkg/capabilities/bindings/DataStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.6;

contract DataStorage {
// Mapping to store data keyed by an address and a string key
mapping(address => mapping(string => string)) private data;

// Event emitted when data is stored
event DataStored(address indexed sender, string key, string value);

// New event emitted by a different method
event AccessLogged(address indexed caller, string message);

// Custom error for when a key is not found
error DataNotFound(address requester, string key, string reason);

// Struct definition
struct UserData {
string key;
string value;
}

// Write method: Stores a key-value pair
function storeData(string calldata key, string calldata value) external {
data[msg.sender][key] = value;
emit DataStored(msg.sender, key, value);
}

// Read method: Retrieves the value for a given key
// No longer emits any event
function readData(address user, string calldata key) external view returns (string memory) {
string memory value = data[user][key];

if (bytes(value).length == 0) {
revert DataNotFound(user, key, "No data associated with this key.");
}

return value;
}

// New method: Emits a different event
function logAccess(string calldata message) external {
emit AccessLogged(msg.sender, message);
}

// New method: Accepts a struct and stores its data
function storeUserData(UserData calldata userData) external {
data[msg.sender][userData.key] = userData.value;
emit DataStored(msg.sender, userData.key, userData.value);
}

function onReport(bytes calldata metadata, bytes calldata payload) external {
UserData memory user = abi.decode(payload, (UserData));
// TODO implement logic to handle the report
data[msg.sender][user.key] = user.value;
emit DataStored(msg.sender, user.key, user.value);
}
}
34 changes: 34 additions & 0 deletions pkg/capabilities/bindings/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# CRE Generated Bindings (MVP)

## Prerequisites:
1. Install `go`
2. Install `solidity`

## Setup instructions:

1. Clone `geth` fork and checkout development branch
```
git clone https://github.com/pablolagreca/go-ethereum.git && git checkout abigen-configurable-template
```

2. Build custom abigen binary.
```
go build -o "$(go env GOPATH)/bin/abigen-cre" ./cmd/abigen
```

3. Generate the abi combined json file
```
solc --combined-json abi,bin,metadata {SOLIDITY_FILE_LOCATION} > {ABI_FILE_LOCATION}
```

4. Run abigen-cre, passing in the cre source template:
```
abigen-cre --v2 \
--abi {ABI_FILE_LOCATION} \
--pkg bindings \
--template ./sourcecre.go.tpl \
--out ./build/bindings.go
```



1 change: 1 addition & 0 deletions pkg/capabilities/bindings/build/DataStorage.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"internalType":"address","name":"requester","type":"address"},{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"reason","type":"string"}],"name":"DataNotFound","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"string","name":"message","type":"string"}],"name":"AccessLogged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"string","name":"key","type":"string"},{"indexed":false,"internalType":"string","name":"value","type":"string"}],"name":"DataStored","type":"event"},{"inputs":[{"internalType":"string","name":"message","type":"string"}],"name":"logAccess","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"metadata","type":"bytes"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"onReport","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"string","name":"key","type":"string"}],"name":"readData","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"name":"storeData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"internalType":"struct DataStorage.UserData","name":"userData","type":"tuple"}],"name":"storeUserData","outputs":[],"stateMutability":"nonpayable","type":"function"}]
1 change: 1 addition & 0 deletions pkg/capabilities/bindings/build/DataStorage.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
608060405234801561001057600080fd5b50610aa4806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80634ece5b4c1461005157806398458c5d1461006d578063ccf1582714610089578063f5bfa815146100a5575b600080fd5b61006b60048036038101906100669190610605565b6100d5565b005b61008760048036038101906100829190610686565b61019b565b005b6100a3600480360381019061009e91906105b8565b610296565b005b6100bf60048036038101906100ba9190610558565b6102ea565b6040516100cc9190610849565b60405180910390f35b81816000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020868660405161012592919061078c565b9081526020016040518091039020919061014092919061042b565b503373ffffffffffffffffffffffffffffffffffffffff167fc95c7d5d3ac582f659cd004afbea77723e1315567b6557f3c059e8eb9586518f8585858560405161018d949392919061080e565b60405180910390a250505050565b8080602001906101ab919061086b565b6000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208380600001906101f9919061086b565b60405161020792919061078c565b9081526020016040518091039020919061022292919061042b565b503373ffffffffffffffffffffffffffffffffffffffff167fc95c7d5d3ac582f659cd004afbea77723e1315567b6557f3c059e8eb9586518f82806000019061026b919061086b565b84806020019061027b919061086b565b60405161028b949392919061080e565b60405180910390a250565b3373ffffffffffffffffffffffffffffffffffffffff167fe2ab1536af9681ad9e5927bca61830526c4cd932e970162eef77328af1fdcfb583836040516102de9291906107ea565b60405180910390a25050565b606060008060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020848460405161033c92919061078c565b9081526020016040518091039020805461035590610969565b80601f016020809104026020016040519081016040528092919081815260200182805461038190610969565b80156103ce5780601f106103a3576101008083540402835291602001916103ce565b820191906000526020600020905b8154815290600101906020018083116103b157829003601f168201915b50505050509050600081511415610420578484846040517ff1e50209000000000000000000000000000000000000000000000000000000008152600401610417939291906107a5565b60405180910390fd5b809150509392505050565b82805461043790610969565b90600052602060002090601f01602090048101928261045957600085556104a0565b82601f1061047257803560ff19168380011785556104a0565b828001600101855582156104a0579182015b8281111561049f578235825591602001919060010190610484565b5b5090506104ad91906104b1565b5090565b5b808211156104ca5760008160009055506001016104b2565b5090565b6000813590506104dd81610a57565b92915050565b60008083601f8401126104f9576104f86109cf565b5b8235905067ffffffffffffffff811115610516576105156109ca565b5b602083019150836001820283011115610532576105316109e3565b5b9250929050565b60006040828403121561054f5761054e6109d9565b5b81905092915050565b600080600060408486031215610571576105706109f2565b5b600061057f868287016104ce565b935050602084013567ffffffffffffffff8111156105a05761059f6109ed565b5b6105ac868287016104e3565b92509250509250925092565b600080602083850312156105cf576105ce6109f2565b5b600083013567ffffffffffffffff8111156105ed576105ec6109ed565b5b6105f9858286016104e3565b92509250509250929050565b6000806000806040858703121561061f5761061e6109f2565b5b600085013567ffffffffffffffff81111561063d5761063c6109ed565b5b610649878288016104e3565b9450945050602085013567ffffffffffffffff81111561066c5761066b6109ed565b5b610678878288016104e3565b925092505092959194509250565b60006020828403121561069c5761069b6109f2565b5b600082013567ffffffffffffffff8111156106ba576106b96109ed565b5b6106c684828501610539565b91505092915050565b6106d8816108f5565b82525050565b60006106ea83856108d9565b93506106f7838584610927565b610700836109f7565b840190509392505050565b600061071783856108ea565b9350610724838584610927565b82840190509392505050565b600061073b826108ce565b61074581856108d9565b9350610755818560208601610936565b61075e816109f7565b840191505092915050565b60006107766021836108d9565b915061078182610a08565b604082019050919050565b600061079982848661070b565b91508190509392505050565b60006060820190506107ba60008301866106cf565b81810360208301526107cd8184866106de565b905081810360408301526107e081610769565b9050949350505050565b600060208201905081810360008301526108058184866106de565b90509392505050565b600060408201905081810360008301526108298186886106de565b9050818103602083015261083e8184866106de565b905095945050505050565b600060208201905081810360008301526108638184610730565b905092915050565b60008083356001602003843603038112610888576108876109de565b5b80840192508235915067ffffffffffffffff8211156108aa576108a96109d4565b5b6020830192506001820236038313156108c6576108c56109e8565b5b509250929050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600061090082610907565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b82818337600083830152505050565b60005b83811015610954578082015181840152602081019050610939565b83811115610963576000848401525b50505050565b6000600282049050600182168061098157607f821691505b602082108114156109955761099461099b565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e6f2064617461206173736f63696174656420776974682074686973206b657960008201527f2e00000000000000000000000000000000000000000000000000000000000000602082015250565b610a60816108f5565b8114610a6b57600080fd5b5056fea2646970667358221220a124db93ed569560f075e2bcc61bd20a4b0585d1c44842b0523350244a1a0f3664736f6c63430008060033
Loading
Loading