Skip to content

Commit

Permalink
lookupmap for repository permission (#41)
Browse files Browse the repository at this point in the history
* lookupmap for repository permission
   replace hashmap with lookupmap
* add devcontainer setup
* update near-sdk-rs
* migration test
* compile and deploy contract in workspaces
* handle calling init twice
* remove invitation functionality
* bos widget for setting repository permission
* support access for implicit accounts
* npm audit fix
* relative URL for webworker
* add wasm32 target before testing
  • Loading branch information
petersalomonsen authored Dec 26, 2023
1 parent 6cefdd3 commit 64f5510
Show file tree
Hide file tree
Showing 14 changed files with 5,468 additions and 833 deletions.
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

0 comments on commit 64f5510

Please sign in to comment.