Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookupmap for repository permission #41

Merged
merged 16 commits into from
Dec 26, 2023
Merged
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
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"image": "mcr.microsoft.com/devcontainers/universal",
"features": {
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"rust-lang.rust-analyzer"
]
}
},
"postCreateCommand": ".devcontainer/post-create.sh"
}
2 changes: 2 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
rustup target add wasm32-unknown-unknown
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ jobs:
- name: Rust smart contract for access control
run: |
cd nearcontract
rustup target add wasm32-unknown-unknown
cargo test --package rust-simple-access-control -- --nocapture
51 changes: 51 additions & 0 deletions nearboswidget/widget.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const [repositoryName, setRepositoryName] = useState("");
const [accountId, setAccountId] = useState("");

const permissionmap = {
'none': 0x00,
'owner': 0x01,
'contributor': 0x02,
'reader': 0x04
};

const [permission, setPermission] = useState(permissionmap['owner']);

function createRepository() {
Near.call("wasmgit.near", "set_permission", {
path: repositoryName,
account_id: accountId,
permission: parseInt(''+permission)
},
undefined
, "100000000000000000000000"
);
};
return (
<>
<h3>Set repository permission</h3>

<h6>Repository name</h6>
<input
placeholder="Repository name"
value={repositoryName}
onInput={(e) => setRepositoryName(e.target.value)}
></input>

<h6>Account id</h6>
<input
placeholder="Account id"
value={accountId}
onInput={(e) => setAccountId(e.target.value)}
></input>
<h6>Permission</h6>
<select value={permission} onChange={(e) => setPermission(e.target.value)}>
{
Object.keys(permissionmap).map(permissionName =>
<option value={permissionmap[permissionName]}>{permissionName}</option>
)
}
</select>
<br />
<button onClick={createRepository}>Create</button>
</>
);
Loading
Loading