I use the following two sdk to connect and interact with the local-network created by the extension.
package.json:
...
"fabric-ca-client": "^2.2.0",
"fabric-network": "^2.2.0",
...
What I did first was get the default wallets created here:
C:\Users\johnny.dacosta\.fabric-vscode\environments\chaincode-env
I copied it to my workspace and then added the `admin' identity to my wallets with the following function:
if(this.walletProxy == null){
//get wallet store
this.walletProxy = await createWalletProxy(this.configService.get('localnetwork.orgWalletPath'));
//build new identity
const certBasePath = joinPathFromCWD(this.configService.get('localnetwork.pathIdentityCert'));
const keyBasePath = joinPathFromCWD(this.configService.get('localnetwork.pathIdentityKey'));
const certFilename = getFilesFromPath(certBasePath)[0];
const keyFilename = getFilesFromPath(keyBasePath)[0];
if(!certFilename || !keyFilename){
throw new NotFoundException("certFilename or keyFilename not found");
}
const cert = readFileSyncUTF8(`${certBasePath}/${certFilename}`).toString();
const key = readFileSyncUTF8(`${keyBasePath}/${keyFilename}`).toString();
//add new identity
await this.walletProxy.addIdentity(this.configService.get('localnetwork.identity'), {
credentials: {
certificate: cert,
privateKey: key,
},
mspId: 'Org1MSP',
type: 'X.509',
})
}
//ENV
{
orgWalletPath: ["local-network", "wallets", "Org1", "admin", "user"],
pathIdentityCert: ["local-network", "wallets", "Org1", "admin", "signcerts"],
pathIdentityKey: ["local-network", "wallets", "Org1", "admin", "keystore"],
}
I manage to add the new identity admin:
{"credentials":{"certificate":"-----BEGIN CERTIFICATE-----\nMIICWTCCAf+gAwIBAgIUIcgD17E4QtTsYMfeUO9Gg4SdSyIwCgYIKoZIzj0EAwIw\nfzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNh\nbiBGcmFuY2lzY28xHzAdBgNVBAoTFkludGVybmV0IFdpZGdldHMsIEluYy4xDDAK\nBgNVBAsTA1dXVzEUMBIGA1UEAxMLZXhhbXBsZS5jb20wHhcNMjAwODEzMTIwNjAw\nWhcNMjEwODEzMTIxMTAwWjBdMQswCQYDVQQGEwJVUzEXMBUGA1UECBMOTm9ydGgg\nQ2Fyb2xpbmExFDASBgNVBAoTC0h5cGVybGVkZ2VyMQ8wDQYDVQQLEwZjbGllbnQx\nDjAMBgNVBAMTBWFkbWluMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfkO0UxnK\nfEKmESj0GxyjSh8ljFSgXOCFqINXo66hnBb8M5XQMNE4HJFrJ5Aa0bPfvlNjCLXp\nu4MGWN3mFf1qb6N7MHkwDgYDVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwHQYD\nVR0OBBYEFO/aOEcikRVj/j/coHPhFPS74x4WMB8GA1UdIwQYMBaAFBdnQj2qnoI/\nxMUdn1vDmdG1nEgQMBkGA1UdEQQSMBCCDmRvY2tlci1kZXNrdG9wMAoGCCqGSM49\nBAMCA0gAMEUCIQC/inkjTud4btEeECODuZQhEEZG0OgDDoSkfhNNJF82wgIgYYvF\nLK1NgJxMdYwxQYhGXSV568d+HJROXgb7+vsjd3g=\n-----END CERTIFICATE-----\n","privateKey":"-----BEGIN PRIVATE KEY-----\nMIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGRpFEGhHS95y2Fyr\nLk6s6gd0V5D61akQC4RkEC1xYzmhRANCAAR+Q7RTGcp8QqYRKPQbHKNKHyWMVKBc\n4IWog1ejrqGcFvwzldAw0TgckWsnkBrRs9++U2MItem7gwZY3eYV/Wpv\n-----END PRIVATE KEY-----\n"},"mspId":"Org1MSP","type":"X.509","version":1}
With this identity I can getState of my asset:
But if I try to do putState transaction I got this error:
2020-08-13T13:14:14.117Z - error: [DiscoveryHandler]: _build_endorse_group_member >> G1:0 - error on endorsement to peer0.org2.example.com:17097 error Error: Broadcast Client peer0.org2.example.com:17097 grpc://localhost:17097 is not connected
2020-08-13T13:14:14.118Z - error: [DiscoveryHandler]: _build_endorse_group_member >> G0:0 - error on endorsement to peer0.org1.example.com:17092 error Error: Broadcast Client peer0.org1.example.com:17092 grpc://localhost:17092 is not connected
[Nest] 22548 - 2020-08-13 3:14:14 PM [ExceptionsHandler] Cannot read property 'name' of undefined +747178ms
TypeError: Cannot read property 'name' of undefined
at newEndorsementError (C:\DEV\CIB\cib-ledger-api\node_modules\fabric-network\lib\transaction.js:33:36)
at getResponsePayload (C:\DEV\CIB\cib-ledger-api\node_modules\fabric-network\lib\transaction.js:17:23)
at Transaction.submit (C:\DEV\CIB\cib-ledger-api\node_modules\fabric-network\lib\transaction.js:214:28)
at process._tickCallback (internal/process/next_tick.js:68:7)
All the peer are up:
I'm just confused why is not working with putState transaction.
I already check my smartcontract is good I can manage to do putState operation with the extension:
Your Environment
IBM Blockchain Platform Extension Version: 1.0.36
Visual Studio Code version: 1.47.3
Environment name and version: Node.js v10.16.3, npm v6.14.7):
Operating System and version: Windows 10 Enterprise v1903
I got the problem...
Just before the transaction I disconnected from the network...
async submitTransaction(transactionConfig: ITransaction2HLF): Promise<void> {
console.log(transactionConfig.transactionName)
console.log(...transactionConfig.params)
await this.buildInstance(transactionConfig);
this.gateway.disconnect() // <-- ERROR
await this.contract.submitTransaction(transactionConfig.transactionName, ...transactionConfig.params);
this.gateway.disconnect()
}
I just removed the line and I downgrade the version 2.2 to 1.4.x due to the vscode extension ibm blockchain plateform requirements.
Related
I'm getting this error when I call my gRPC Golang server from Dart:
Caught error: gRPC Error (code: 12, codeName: UNIMPLEMENTED, message: grpc: Decompressor is not installed for grpc-encoding "gzip", details: [], rawResponse: null, trailers: {})
I have read https://github.com/bradleyjkemp/grpc-tools/issues/19, and it doesn't appear to apply to my issue.
The server is running 1.19.2 on Gcloud Ubuntu.
Dart is running 2.18.2 on Mac Monterey
I have a Dart client calling a Go server. Both appear to be using GZIP for compression.
Dart proto
syntax = "proto3";
option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";
package helloworld;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
GO proto:
syntax = "proto3";
option go_package = "google.golang.org/grpc/examples/helloworld/helloworld";
option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
package helloworld;
// The greeting service definition.
service Greeter {
// Sends a greeting
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
// The request message containing the user's name.
message HelloRequest {
string name = 1;
}
// The response message containing the greetings
message HelloReply {
string message = 1;
}
Dart Client code:
import 'package:grpc/grpc.dart';
import 'package:helloworld/src/generated/helloworld.pbgrpc.dart';
Future<void> main(List<String> args) async {
final channel = ClientChannel(
'ps-dev1.savup.com',
port: 54320,
options: ChannelOptions(
credentials: ChannelCredentials.insecure(),
codecRegistry:
CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),
),
);
final stub = GreeterClient(channel);
final name = args.isNotEmpty ? args[0] : 'world';
try {
final response = await stub.sayHello(
HelloRequest()..name = name,
options: CallOptions(compression: const GzipCodec()),
);
print('Greeter client received: ${response.message}');
} catch (e) {
print('Caught error: $e');
}
await channel.shutdown();
}
The Go gRPC server works fine with a Go gRPC client and BloomRPC.
I'm new to gRPC in general and very new to Dart.
Thanks in advance for any help resolving this issue.
That error that you shared shows that your server doesn't support gzip compression.
The quickest fix is to not use gzip compression in the client's call options, by removing the line:
options: CallOptions(compression: const GzipCodec()),
from your Dart code.
The go-grpc library has an implementation of a gzip compression encoding in package github.com/grpc/grpc-go/encoding/gzip, but it's experimental, so likely not wise to use it in production; or at least you should pay close attention to it:
// Package gzip implements and registers the gzip compressor
// during the initialization.
//
// Experimental
//
// Notice: This package is EXPERIMENTAL and may be changed or removed in a
// later release.
If you want to use it in your server, you just need to import the package; there is no user-facing code in the package:
import (
_ "github.com/grpc/grpc-go/encoding/gzip"
)
The documentation about compression for grpc-go mentions this above package as an example of how your implement such a compressor.
So you may also want to copy the code to a more stable location and take responsibility for maintaining it yourself, until there is a stable supported version of it.
Why am I getting the following error when trying to create a metadata account using createCreateMetadataAccountV2Instruction from the #metaplex-foundation/mpl-token-metadata library?
SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete
at Connection.sendEncodedTransaction (C:\xampp\htdocs\sol-tools\node_modules\#solana\web3.js\src\connection.ts:4464:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Connection.sendRawTransaction (C:\xampp\htdocs\sol-tools\node_modules\#solana\web3.js\src\connection.ts:4423:20)
at async Connection.sendTransaction (C:\xampp\htdocs\sol-tools\node_modules\#solana\web3.js\src\connection.ts:4411:12)
at async sendAndConfirmTransaction (C:\xampp\htdocs\sol-tools\node_modules\#solana\web3.js\src\util\send-and-confirm-transaction.ts:31:21)
at async addMetadataToToken (C:\xampp\htdocs\sol-tools\src\lib\metadata.ts:86:16)
at async Command.<anonymous> (C:\xampp\htdocs\sol-tools\src\cli.ts:48:7) {
logs: [
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]',
'Program log: Instruction: Create Metadata Accounts v2',
"Program log: panicked at 'range end index 36 out of range for slice of length 0', program/src/utils.rs:231:27",
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 6223 of 1400000 compute units',
'Program failed to complete: BPF program panicked',
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: Program failed to complete'
]
}
Here's my code:
import {
createCreateMetadataAccountV2Instruction,
PROGRAM_ID,
} from '#metaplex-foundation/mpl-token-metadata'
import {
Connection,
Keypair,
PublicKey,
sendAndConfirmTransaction,
Transaction,
} from '#solana/web3.js'
export const addMetadataToToken = async (
connection: Connection,
tokenMint: PublicKey,
tokenOwner: Keypair,
name: string,
symbol: string,
arweaveLink: string
) => {
const seed1 = Buffer.from('metadata', 'utf8')
const seed2 = PROGRAM_ID.toBuffer()
const seed3 = tokenMint.toBuffer()
const [metadataPDA, _bump] = PublicKey.findProgramAddressSync(
[seed1, seed2, seed3],
PROGRAM_ID
)
const accounts = {
metadata: metadataPDA,
mint: tokenMint,
mintAuthority: tokenOwner.publicKey,
payer: tokenOwner.publicKey,
updateAuthority: tokenOwner.publicKey,
}
const dataV2 = {
name,
symbol,
uri: arweaveLink,
// we don't need these
sellerFeeBasisPoints: 0,
creators: null,
collection: null,
uses: null,
}
const args = {
createMetadataAccountArgsV2: {
data: dataV2,
isMutable: true,
},
}
const ix = createCreateMetadataAccountV2Instruction(accounts, args)
const tx = new Transaction()
tx.add(ix)
const txid = await sendAndConfirmTransaction(connection, tx, [tokenOwner])
console.log(txid)
}
Turns out I was on trying to create metadata for a token on devnet, but was using a mainnet-beta rpc endpoint for the Connection class. Thus the token I was trying to create metadata for didn't exist.
This is a really Common Error Message that occurs when there is some issue with what you are passing to the program. So make sure everything that you are input to the program is correct. In 90% of the cases, it gets resolved when checking the inputs correctly.
The following Node.js code gives me error "Unhandled rejection Error: Invalid WSDL":
// Purpose: via node platform to access another system from my company
// This is the project url to get web service, already working on soapUI
var url = "https://w3(intranet-link)/webservices/ws_GetUserData.wss?wsdl";
var args = {
msg:"connecting!"
};
//define project access
var userid='';
var password='';
soap.createClientAsync(url).then((client) => {
//add project access to logon to url
client.setSecurity(new soap.BasicAuthSecurity(userid, password));
return client.MyFunctionAsync(args);
}).then((result) => {
console.log(result);
});
How can I fix this problem? Thank you!
I am using protobuf and gRPC to exchange information between a Flutter app and a python server (client in Flutter and the server in python). Server running on 0.0.0.0 and the client is using the IP address of the server machine.
import 'dart:async';
import 'User.pbgrpc.dart';
import 'User.pb.dart';
import 'package:grpc/grpc.dart';
Future<Null> main() async {
final channel = new ClientChannel('IP_ADDRESS',
port: 50051,
options: const ChannelOptions(
credentials: const ChannelCredentials.insecure()));
final stub = new StorageClient(channel);
Test input = new Test();
input.id = 1;
try {
var response = await stub.getPerson(input);
print('Greeter client received: ${response}');
} catch (e) {
print('Caught error: $e');
}
await channel.shutdown();
}
if I run this client using dart client.dart everything works fine and I get the expected response. But if I embed this method in a flutter app like:
#override
Widget build(BuildContext context) {
Future<Null> testRPC() async {
final channel = new ClientChannel('IP_ADDRESS',
port: 50051,
options: const ChannelOptions(
credentials: const ChannelCredentials.insecure()));
final stub = new StorageClient(channel);
Test input = new Test();
input.id = 1;
try {
var response = await stub.getPerson(input);
print('Greeter client received: ${response}');
} catch (e) {
print('Caught error: $e');
}
await channel.shutdown();
}
testRPC();
...etc
}
I get:
I/flutter (18824): Caught error: gRPC Error (14, Error connecting: SocketException: OS Error: No route to host, errno = 111, address = localhost, port = 45638)
UPDATE: It is working when I run the app with an emulator. So this is error is happening only when using a real device.
If you run AVD(Client) and the backend in same computer, you have to set the base URL instead of "localhost/127.0.0.1" to "10.0.2.2".
Here's the answer in Github.
In my case, it was a firewall problem. Running systemctl stop firewalld on the server solved it.
I had the same error, Flutter app as grpc client and C# as grpc server. The problem was in the server, I was using "localhost" as host parameter, changed to "0.0.0.0" and now is running fine.
Maybe you should add network permission to android project:
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.client">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:label="client"
android:name="${applicationName}"
android:icon="#mipmap/ic_launcher">
I had to pause my dev for a few months. My Letsencrypt certificate expired in the meantime and there some changes in the libs.
I deleted my Letsencrypt directory (the one whith the certificates inside).
I am using greenlock-express API
Now,I cannot manage to pass the http-01 challenge when obtaining the certificate.
I have no problem to curl the file :
http://myserver.com/.well-known/acme-challenge/hRsScb0ZHcFyaroe73h2lnFcQfCTeDwFhVB8PtKHfYs
But I get errors when running my app :
ERROR in le-sni-auto:
Error: The CA was unable to validate the file you provisioned.
Fetching http://myserver.com/.well-known/acme-challenge/hRsScb0ZHcFyaroe73h2lnFcQfCTeDwFhVB8PtKHfYs: Timeout
I cannot firgure out whet is happenning...
Any idea ?
Edit 170912 - Configuration details
var lex = require('greenlock-express').create({
server: 'staging'
,challenges: {'http-01': require('le-challenge-fs').create({ webrootPath: './letsencrypt/tmp' })}
,store: require('le-store-certbot').create({
configDir: './letsencrypt'
,privkeyPath: ':configDir/live/:hostname/privkey.pem'
,fullchainPath: ':configDir/live/:hostname/fullchain.pem'
,certPath: ':configDir/live/:hostname/cert.pem'
,chainPath: ':configDir/live/:hostname/chain.pem'
,webrootPath: ':configDir/tmp'
,debug: false
})
,approveDomains: approveDomains
});
function approveDomains(opts, certs, cb) {
if (certs) {
opts.domains = certs.altnames;
}
else {
opts.email = 'contact#myserver.com';
opts.agreeTos = true;
opts.domains = [ 'myserver.com'];
}
cb(null, { options: opts, certs: certs });
}
http.createServer(lex.middleware(require('redirect-https')())).listen(80, _ => {
console.log("Listening for ACME http-01 challenges on", this.address());
});
https.createServer(lex.httpsOptions, lex.middleware(app)).listen(443, function () {
console.log("Listening for ACME tls-sni-01 challenges and serve app on", this.address());
});